简体   繁体   中英

Linux: packets reordering simulation

I would like to simulate packets reordering for UDP packets on Linux to measure the performance and fault tolerance of my application. Is there a simple way to do this?

look into WANEM

WANem thus allows the application development team to setup a transparent application gateway which can be used to simulate WAN characteristics like Network delay, Packet loss, Packet corruption, Disconnections, Packet re-ordering, Jitter, etc.

You can use the "netem" feature built-into the Linux kernel. It is shipped with most modern distributions. netem is a traffic control discipline module which deliberately delays, drops and reorders packets and is highly configurable.

This only works for sending packets (because the queues are outbound only), so you may wish to place a router host with netem between the two test machines, and run netem on both interfaces (with differing parameters if you like).

The easiest way to achieve this is to run netem in a VM to route between two VM networks. I've found this to be quite handy.

You could try scapy . It's a python library to manipulate packets. You could capture a pcap session, with tcpdump , wireshark, whatever, and then replay the captured packets in arbitrary order with scapy.

a=rdpcap("/spare/captures/isakmp.cap")
for pkt in a.reverse():
   sendp(pkt)

Depending on how you catpured the packets you may need send(layer 3) rather than sendp(layer 2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM