Aaron Turner wrote:
On 5/14/07, Andrew Edgecombe <[EMAIL PROTECTED]> wrote:
Hi all,
I've come across an issue when using the -M option on tcpreplay to
specify the outgoing data rate.
I tend to use tcpreplay to replay pcap files that contain small numbers
of packets, but replay them with -l loops.
The issue that I found was that when replaying pcap files containing
single packets that the -M option would replay at
full speed instead of the requested rate.
Attached is a (very simple!) patch file against tcpreplay-3.0.1. I've
found this useful as it allows me to set rates for my
single packet pcap files.
Hi Andrew,
I'm going to have to think about this corner case a little more.
Unfortunately your patch breaks the common case where people have
pcap's with many packets and use the loop option.
For the record, the test I ran was:
./src/tcpreplay -i en0 -l 3 test/test.pcap
should take ~15sec to run (test/test.pcap is about 5 seconds long),
but with your patch it took about 5.5sec.
-Aaron
Hi Aaron,
Sorry about that - I left off the "ymmv" clause :-)
I've had a bit more of a solid look at it and I think that I've got
something that should work for all cases.
The attached patch is against tcpreplay-3.0.1.
To apply the patch from within the tcpreplay-3.0.1 directory:
patch -p1 < tcpreplay-3.0.1.patch2
The results that I'm seeing now:
tcpreplay -i eth0 -q -C -l3 ./test/test.pcap
Actual: 300 packets (31887 bytes) sent in 15.16 seconds
Rated: 2125.6 bps, 0.02 Mbps/sec, 20.00 pps
Statistics for network device: eth0
Attempted packets: 300
Successful packets: 300
Failed packets: 0
Retried packets: 0
tcpreplay -i eth0 -q -C -l3 -m3 ./test/test.pcap
Actual: 300 packets (31887 bytes) sent in 5.16 seconds
Rated: 6355.9 bps, 0.05 Mbps/sec, 59.80 pps
Statistics for network device: eth0
Attempted packets: 300
Successful packets: 300
Failed packets: 0
Retried packets: 0
tcpreplay -i eth0 -q -C -l1000000 -M250 singlepkt.pcap
Actual: 1000000 packets (1024000000 bytes) sent in 31.34 seconds
Rated: 32995528.0 bps, 251.74 Mbps/sec, 32222.20 pps
Statistics for network device: eth0
Attempted packets: 1000000
Successful packets: 1000000
Failed packets: 0
Retried packets: 0
cheers,
Andrew Edgecombe
diff -Naur tcpreplay-3.0.1.clean/src/send_packets.c
tcpreplay-3.0.1/src/send_packets.c
--- tcpreplay-3.0.1.clean/src/send_packets.c 2007-05-02 14:40:41.000000000
+1000
+++ tcpreplay-3.0.1/src/send_packets.c 2007-05-16 15:14:09.000000000 +1000
@@ -80,7 +80,7 @@
void
send_packets(pcap_t *pcap, int cache_file_idx)
{
- struct timeval last = { 0, 0 };
+ struct timeval last = { 0, 0 };
COUNTER packetnum = 0;
struct pcap_pkthdr pkthdr;
const u_char *pktdata = NULL;
@@ -339,7 +339,8 @@
dbgx(3, "Now time: " TIMEVAL_FORMAT, now.tv_sec, now.tv_usec);
/* First time through for this file */
- if (!timerisset(last)) {
+ if( pkts_sent == 0 ||
+ ((options.speed.mode != SPEED_MBPSRATE) && (counter ==
0))) {
start = now;
timerclear(&delta);
timerclear(&didsleep);
@@ -372,7 +373,7 @@
* Ignore the time supplied by the capture file and send data at
* a constant 'rate' (bytes per second).
*/
- if (timerisset(last)) {
+ if (pkts_sent != 0) {
n = (float)len / (options.speed.speed * 1024 * 1024 / 8); /*
convert Mbps to bps */
nap.tv_sec = n;
nap.tv_usec = (n - nap.tv_sec) * 1000000;
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Tcpreplay-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tcpreplay-users