offline pcap reading working
[netsniff-ng.git] / src / trafgen_rpr_quadrimodal.pl
blobcde59c56f65a87cd191a9fcc25f66354bad4861b
1 #!/usr/bin/perl
3 # netsniff-ng - the packet sniffing beast
4 # Copyright 2011 Daniel Borkmann <daniel@netsniff-ng.org>
5 # Subject to the GPL.
6 # Configuration file generator for trafgen.
7 # Generates RPR Quadrimodal packet distribution (64:50, 512:15, 1518:15, 9218:20)
8 # In lengths the Frame Check Sequence of 4 Byte is not counted
10 # FIXME: http://en.wikipedia.org/wiki/Jumbo_frame#Super_jumbo_frames
11 # As it has been a relatively difficult, and somewhat lengthy, process
12 # to increase the path MTU of high performance national research and
13 # education networks from 1518 bytes to 9000 bytes or so, a subsequent
14 # increase, possibly to 64000 bytes for example, may take some time.
15 # So we use 9000 - 4 in this example instaed of 9218 - 4. RFC!
17 use warnings;
18 use strict;
20 my %conf = (
21 60 => 50, # 64 - 4
22 508 => 15, # 512 - 4
23 1514 => 15, # 1518 - 4
24 8996 => 20 # 9000 - 4
27 print "# Run in round-robin mode with trafgen!\n";
28 print "# E.g. trafgen --dev eth0 --conf <this-as-file> --bind 0\n\n";
30 my $sum = 0;
31 foreach (values(%conf)) {
32 $sum = $sum + $_;
35 for (my $pkt = 0; $pkt < $sum; ++$pkt) {
36 my ($len, $done) = (0, 0);
38 do {
39 my @list = keys(%conf);
40 my $index = int(rand(scalar(@list)));
41 my $key = $list[$index];
42 if ($conf{$key} > 0) {
43 $conf{$key}--;
44 $len = $key;
45 $done = 1;
47 } while ($done == 0);
49 print "\$P$pkt {\n";
50 for (my $byte = 0; $byte < $len;) {
51 for (my $off = 0; $off < 13 && $byte < $len; ++$off, ++$byte) {
52 my $cur = sprintf("0x%02x", int(rand(256)));
53 print "$cur, ";
55 print "\n";
57 print "}\n\n";