-
Notifications
You must be signed in to change notification settings - Fork 33
PktgenTx
This test module is capable of fast packet generation, with the use of pktgen kernel module. The test module provides an easy interface to use this kernel module within your recipes.
The pktgen kernel module creates multiple threads, one for each processor, our test module makes use of these when you specify multiple network devices where you want packets to be generated. Multiple devices are assigned to threads in a round-robin fashion, to spread out the workload.
This test module can be used to test the throughput of the network or to test DoS attacks.
netdev_name
|
values are names of network devices on which the module should generate packets. The module will assign new devices to threads in a round-robin fashion. This option is mandatory and accepts multiple values. |
pktgen_option
|
values are options that will be passed to the pktgen kernel module. These will be merged with a set of defaults. The resulting options will be shared across all the devices. This option is mandatory and accepts multiple values. |
thread_option
|
is optional. It accepts a list of options specific for individual pktgen threads. The list needs to be the same length as the number of threads (devices) used by pktgen. Individual values are comma-sepparated options recognized by pktgen. |
The default values of pktgen_option
are:
count : 10000000 |
clone_skb : 100000 |
pkt_size : 60 |
These configuration options are passed directly to the devices that were already assigned to a thread.
It is also important to add that the option max_before_softirq 5000 is passed to all the threads that are assigned to at least one device. This is so that pktgen doesn't monopolize kernel resources while running.
The packet generation runs while the packet counter is non-zero or it receives an interrupt signal. The command can therefore be run both in the foreground and in the background. In the following commands I'm capturing the generated packets on the receiving machine with the command PacketAssert that uses tcpdump.
<run module="PacketAssert" host="testmachine2" bg_id="test">
<options>
<option name="interface" value="{devname(testmachine2, testifc2)}"/>
<option name="filter" value="udp"/>
<option name="max" value="1000"/>
</options>
</run>
<run module="PktgenTx" host="testmachine1">
<options>
<option name="netdev_name" value="{devname(testmachine1, testifc1)}"/>
<option name="pktgen_option" value="dst {ip(testmachine2, testifc2)}"/>
<option name="pktgen_option" value="dst_mac {hwaddr(testmachine2, testifc2)}"/>
<option name="pktgen_option" value="count 1000"/>
</options>
</run>
<intr host="testmachine2" bg_id="test"/>
As was mentioned before, packet generation with this module is very quick. This can be seen in the test results of the command sequence from the previous section. However after the PktgenTx command is finished the PacketAssert is immediately interrupted. But since the tcpdump application is slowed down by I/O operations the result is not 1000 received packets as we would expect but much lower.
07/02 13:16:06| (127.0.0.1) INFO: Executing command: [type (test), machine_id (testmachine2), value (PacketAssert), bg_id (test)]
07/02 13:16:05| (192.168.122.30) DEBUG: Running in background with id "test", pid "2172"
07/02 13:16:07| (127.0.0.1) DEBUG: Result: {'passed': True}
07/02 13:16:07| (127.0.0.1) INFO: Executing command: [type (test), machine_id (testmachine1), value (PktgenTx)]
07/02 13:16:05| (192.168.122.109) DEBUG: Executing: "modprobe pktgen"
07/02 13:16:05| (192.168.122.109) DEBUG: Executing: "echo "rem_device_all" > /proc/net/pktgen/kpktgend_0"
07/02 13:16:05| (192.168.122.109) DEBUG: Executing: "echo "max_before_softirq 5000" > /proc/net/pktgen/kpktgend_0"
07/02 13:16:05| (192.168.122.109) DEBUG: Executing: "echo "add_device eth6" > /proc/net/pktgen/kpktgend_0"
07/02 13:16:05| (192.168.122.109) DEBUG: Executing: "echo "clone_skb 100000" > /proc/net/pktgen/eth6"
07/02 13:16:05| (192.168.122.109) DEBUG: Executing: "echo "pkt_size 60" > /proc/net/pktgen/eth6"
07/02 13:16:05| (192.168.122.109) DEBUG: Executing: "echo "dst 192.168.200.3" > /proc/net/pktgen/eth6"
07/02 13:16:05| (192.168.122.109) DEBUG: Executing: "echo "dst_mac 52:54:00:11:1E:33" > /proc/net/pktgen/eth6"
07/02 13:16:05| (192.168.122.109) DEBUG: Executing: "echo "count 1000" > /proc/net/pktgen/eth6"
07/02 13:16:05| (192.168.122.109) DEBUG: Executing: "echo "start" > /proc/net/pktgen/pgctrl"
07/02 13:16:05| (192.168.122.109) DEBUG: PASSED
07/02 13:16:07| (127.0.0.1) DEBUG: Result: {'passed': True}
07/02 13:16:07| (127.0.0.1) INFO: Executing command: [type (intr), machine_id (testmachine2), value (test)]
07/02 13:16:06| (192.168.122.30) DEBUG: Interrupting background command with id "test", pid "2172"
07/02 13:16:05| (192.168.122.30) INFO: Capturing started
07/02 13:16:06| (192.168.122.30) INFO: Capturing finished. Received 407 packets
07/02 13:16:06| (192.168.122.30) DEBUG: PASSED
07/02 13:16:07| (127.0.0.1) DEBUG: Result: {'res_data': {'received': 407, 'max': 1000, 'min': 1}, 'passed': True}
07/02 13:16:07| (127.0.0.1) INFO: Result data: {'max': 1000, 'min': 1, 'received': 407}