Friday, August 2, 2013

Simple Traffic Generation

Through the day, you might want to generate traffic to test some QoS or IP SLA configuration before deploying it to your live network. Traffic Generators are expensive ( Like really expensive ) and rarely seen at home setups. There are other ways to generate traffic in you GNS3 labs like using 2 QEMU Virtual machines and route them to each other, but that's a hassle to do every time you create a lab and it needs a monster PC.

a simple way to generate a decent amount of traffic using a Cisco router or switch is to enable the tcp-small-servers which uses port 19 to generate some downstream telnet charachters patterns to the client. Actually this can become very hands when you need to match a small amount of traffic. here's how to do it

Consider R1 is directly connected to R2

we'll configure R1 as the server
R1(config)#service tcp-small-servers
now let's telnet from R2

you can use any of the two commands below, they're both the same

R2#telnet 10.1.2.1 chargen
or 
R2#telnet 10.1.2.2 19
Trying 10.1.2.1, 19 ... Open !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghi#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijk%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkl&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklm'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmn()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmno)*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnop*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopq+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqr,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrs-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrst./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuv0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvw123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwx23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxy3456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz 

Now let's see the amount of traffic generated with Chargen, just make sure you set the load-interval to 30 sec under the interface and give it sometime to calculate the maximum bandwidth.

R1#show interfaces f0/0 | i sec
MTU 10000 bytes, BW 10000 Kbit/sec, DLY 1000 usec,
Keepalive set (10 sec)
30 second input rate 0 bits/sec, 1 packets/sec
30 second output rate 78000 bits/sec, 70 packets/sec 


The traffic will keep going on forever, also, make sure you know how to exit using the escape sequence which is CRTL+SHIFT+6 then X , thereafter you type disconnect to disconnect from the server back to the client

Another way to generate more traffic is to use the extended ping option, What's good about this method is that it can generate traffic up to 7 Megs ( my personal experience ), but only ICMP traffic. Of course if you want to use it for QoS to test class-maps to match certain traffic and the behavior of the queues, you can always use Precedence or DSCP instead of the traffic type just to monitor your queues.

Simply, to generate large amounts of traffic from a ping command, all you need is to increase the size of the packet and make sure you increase Layer 2 and Layer 3 MTU so that the processor won't be busy fragmenting and defragmenting the packets, which will result in faster forwarding of packets that in my case might reach 7 Megs on a Cisco 2800 router. on higher end platforms, i'm sure you can get more than that since it has faster processors.

R2#ping 10.1.2.1 repeat 1000000 size 10000
Type escape sequence to abort.
Sending 1000000, 10000-byte ICMP Echos to 10.1.2.1, timeout is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

R1#show interfaces f0/0 | i sec
  MTU 10000 bytes, BW 10000 Kbit/sec, DLY 1000 usec,
  Keepalive set (10 sec)
  30 second input rate 5538000 bits/sec, 428 packets/sec
  30 second output rate 5539000 bits/sec, 431 packets/sec

as you can see, after about half a mintue, the sessions built up to reach around 5 Megs which can be very handy if you need to stress test a serial connection, monitor QoS behaviout on small links or even congest it to trigger some SNMP or SLAs

Same technique  can be achieved in Juniper 

ping 10.1.2.1 rapid count 100000 size 10000 
One final trick that can generate even more traffic is to set timeout to zero, but the traffic will be one direction only since the processor will not wait for the ICMP packet to return ( reply)

R2#ping 10.1.2.1 repeat 1000000 size 10000 timeout 0
Type escape sequence to abort.
Sending 1000000, 10000-byte ICMP Echos to 10.1.2.1, timeout is 2 seconds:

......................................................................
......................................................................
......................................................................

......................................................................

R1#show interfaces f0/0 | i sec
  MTU 10000 bytes, BW 10000 Kbit/sec, DLY 1000 usec,
  Keepalive set (10 sec)
  30 second input rate 11076000 bits/sec, 942 packets/sec
  30 second output rate 12431000 bits/sec, 970 packets/sec

Now that's around 12 Mb of traffic, pretty neat huh!


Note: It is NOT RECOMMENDED to enable tcp-small-servers on a production router or switch, an attacker can easily use it as a vulnerability to attack and take down the box.


No comments:

Post a Comment