Tcpreplay

Tcpreplay is very useful tool for testing of networks. You can use the tcpreplay to send predefined/previously saved network packets towards Linux network interface at a given rate and number of packets to send. It is possible also to send several different packets from the previously saved file in .pcap format. For example, you can easily save a single ethernet packet or whole DHCP-negotiation session on the Linux network interface in .pcap format using Wireshark (Ethereal) or tcpdump tool, then replay network traffic towards some Linux interface. In this manner you can emulate Network/Telecom sessions between Linux PC and device under test (DUT).

Some examples of using tcpreplay:

1. ~]# tcpreplay -i eth1 -l 10 dhcp-lease.pcap

the command above will send 10 dhcp-lease frames from eth1 Linux interface;

2.  ~]# tcpreplay -i eth1 -p 5 dhcp-lease.pcap

the command above will send 1 dhcp-lease frame from eth1 Linux interface at 5 packets/sec rate;

More than that, it is possible to change specific fields/pattern of the saved packets in pcap format. Using xxd Linux tool you can create a hex dump of a given file (pcap), change specific fields using some hex-editor and convert the hex dump back to its original binary form:

 xxd dhcp-lease.pcap dhcp-lease.txt: creates a hex dump of the dhcp-lease.pcap

 xxd -r dhcp-lease.txt dhcp-lease_modified.pcap: convert the hex dump back to its original binary form

No comments:

Post a Comment