[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Generating ns traffic from a trace file
Gentlemen:
The section "The class TrafficGenerator" in "ns Notes and Documentation"
(May 11, 1999) states:
"TrafficTrace--generates traffic according to a trace file. Each
record in the trace file consists of two 32-bit fields. The first
contains the time in microseconds until the next packet is generated.
The second contains the length in bytes of the next packet."
The ns distribution includes a canned example ns-2/tcl/ex/tg.tcl that
works with a trace-file-generated traffic. It uses its own trace file,
ns-2/tcl/ex/example-trace, which turns out to be a BINARY file, not ASCII.
(Note that the above description does NOT say anything about that!!!...)
But HOW can one create such a binary file?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To be specific, we shall first describe here what we tried:
We started with a file "VIDEO" containing a video streaming dump:
13:30:19.620586 zeno.gte.com.1031 > 132.197.109.42.6970: udp 300
13:30:19.653737 zeno.gte.com.1031 > 132.197.109.42.6970: udp 541
13:30:19.723736 zeno.gte.com.1031 > 132.197.109.42.6970: udp 596
13:30:19.803739 zeno.gte.com.1031 > 132.197.109.42.6970: udp 604
13:30:19.894091 zeno.gte.com.1031 > 132.197.109.42.6970: udp 571
13:30:19.973717 zeno.gte.com.1031 > 132.197.109.42.6970: udp 610
13:30:20.053712 zeno.gte.com.1031 > 132.197.109.42.6970: udp 349
13:30:20.103723 zeno.gte.com.1031 > 132.197.109.42.6970: udp 617
13:30:20.183714 zeno.gte.com.1031 > 132.197.109.42.6970: udp 368
13:30:20.233723 zeno.gte.com.1031 > 132.197.109.42.6970: udp 611
.
.
.
The first column is the time stamp, the last is the packet size.
Extracting these only and expressing the time stamp in microseconds
(using a short Perl 5 program) one obtains a decimal ASCII file "DEC":
48619620586 300
48619653737 541
48619723736 596
48619803739 604
48619894091 571
48619973717 610
48620053712 349
48620103723 617
48620183714 368
48620233723 611
.
.
.
Expressing that in binary notation, using 32-bit fields, results
in the following file called "ZERO_ONE":
01010001111101001000100011101010 00000000000000000000000100101100
01010001111101010000101001101001 00000000000000000000001000011101
01010001111101100001101111011000 00000000000000000000001001010100
01010001111101110101010001011011 00000000000000000000001001011100
01010001111110001011010101001011 00000000000000000000001000111011
01010001111110011110110001010101 00000000000000000000001001100010
01010001111110110010010011010000 00000000000000000000000101011101
01010001111110111110100000101011 00000000000000000000001001101001
01010001111111010010000010100010 00000000000000000000000101110000
01010001111111011110001111111011 00000000000000000000001001100011
.
.
.
Now, this "ZERO_ONE" is again an ASCII file. Replacing the aforementioned
file example-trace by this "ZERO_ONE" did not make tg.tcl work.
Then, we attempted to convert "ZERO_ONE" to a _binary_ file called "BINARY",
using the following Perl 5 program:
#! /usr/bin/perl
$z = "ZERO_ONE";
$b = "BINARY";
open(IN,"$z") || die "cannot open $z for reading";
open(OUT,">$b") || die "cannot create $b";
while (<IN>){
$line = $_;
$bline = pack("B*", $line);
print OUT $bline;
}
close(IN);
close(OUT);
To our dismay, replacing the file "example-trace" by this "BINARY" did not
make tg.tcl work either.
(Incidentally, eliminating the blank space between the two 32-bit fields
in the file "ZERO_ONE" and then converting the result to a binary file
did not help!)
What was wrong?
In summary:
Could you please describe how to create a trace file from above VIDEO record?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thank you.
Regards,
Miroslav I. Klun
Network Infrastructure Laboratory
GTE Laboratories
Waltham, MA 02451
[email protected]
(781)466-3830