Use Your Routers as Traffic Generators
07.7.2010

While I was testing some remote labs for the Cisco TSHOOT course, I came across a very interesting but undocumented command that turns a router into a traffic generator. Even though this command was introduced awhile ago, in IOS version 11.2, please keep in mind that such activity heavily utilizes even a modern router’s CPUs, and its use should be avoided in production networks unless you’re performing stress tests. If you’re looking for a way to perform regular measures of bandwidth availability in your production network, look for a solution like Bandwidth Monitor.

For this demonstration, I’ll use two common Cisco 2800 series routers. One will be configured as a generator of traffic, while the other takes the role of the receiver.

First, let’s take a look how to configure the receiver. In privileged mode, enter the #ttcp command. Accept each suggested parameter value by pressing Enter, and your receiving side will be all set up.

Receiver#ttcp
transmit or receive [receive]:
perform tcp half close [n]:
receive buflen [8192]:
bufalign [16384]:
bufoffset [0]:
port [5001]:
sinkmode [y]:
rcvwndsize [4128]:
delayed ACK [y]:
show tcp information at end [n]:

ttcp-r: buflen=8192, align=16384/0, port=5001
rcvwndsize=4128, delayedack=yes  tcp

Now log into the second router. Again using privileged mode, execute the #ttcp command. This time, specify transmit for the first option, followed by the target IP address of the receiver for the second option.

Sender#ttcp
transmit or receive [receive]: transmit
Target IP address: 172.31.1.2
perform tcp half close [n]:
send buflen [8192]:
send nbuf [2048]:
bufalign [16384]:
bufoffset [0]:
port [5001]:
sinkmode [y]:
buffering on writes [y]:
show tcp information at end [n]:

ttcp-t: buflen=8192, nbuf=2048, align=16384/0, port=5001  tcp  -> 172.31.1.2
ttcp-t: connect (mss 1260, sndwnd 64260, rcvwnd 4128)

Once you’re finished with the configuration, traffic will start flowing. At the end of the data transfer you’ll see a report that looks similar to the following:

ttcp-t: 16777216 bytes in 14588 ms (14.588 real seconds) (~1123 kB/s) +++
ttcp-t: 2048 I/O calls

By default, the sender will send a little more than 16 megabytes of traffic. I was able to reach speeds of around 8 Mbps between two 2811 routers with the default settings. By increasing the parameter “receive window size” on the receiver, I was able to generate more than 16 Mbps of traffic, which should be enough to utilize most of today’s WAN connections to smaller remote locations.

You can also test throughput with TTCP between a router and a PC by using a simple, small TTCP tool on a workstation. It was developed primarily for the BSD operating system, but today you can also find a Windows port of TTCP.

What surprised me was the fact that, even when I used the PC as a generator of traffic and the router as a receiver, I was unable to achieve better speeds. The history of CPU utilization on the router revealed that receiving data and acknowledging segments is very process-intensive for a device like a router, which is meant not to receive traffic but rather to forward it.