I remember that in Linux (when doing make menuconfig) somewhere there was an option that said something like this:

Use this only if you want to generate network traffic, or if you want to create faulty network traffic

Unfortunately I can't remember where this was or even remember any tool that allows me to actually create such traffic.

What I'm after is

  • creating erroneous ICMP packets
  • injecting high latency or packet loss

on a network which is otherwise perfectly fine.

The purpose is to test the behavior of some applications that have to work with links that are between EU and US. I'd like to "stress test" the application how much latency it will swallow or how much packet loss it can deal with.

6 Answers 6


The option you are thinking of is CONFIG_NET_PKTGEN.

  • I whish I could upvote twice, it seems like the option I was looking for, plus the link is great. I didn't know there was some "make menuconfig" explanation on the web. Seem like the linuxfoundation site is worth investigating, I filed it under "yeah another enterprise linux site thingie" originally Commented Jun 17, 2009 at 16:30
  • Server Horror, I'll upvote for you :-)
    – rkthkr
    Commented Jun 17, 2009 at 17:09

Linux is not so well equipped than FreeBSD here. But you can try Netem with tc (package iproute).

Load Netem

modprobe sch_netem

Drop half of the packets on device tap0:

tc qdisc add dev  tap0 root netem delay 50ms loss 50% 
  • tc seems like the userspace tool I was looking for. Thanks. Commented Jun 18, 2009 at 8:39

hping lets you generate TCP, UDP, ICMP and RAW-IP protocol packets.

  • True, but not to simulate high latency or packet drop.
    – bortzmeyer
    Commented Jun 18, 2009 at 6:16

There is also tool called scapy. It can generate almost any type of packet. As author says:

Scapy is a powerful interactive packet manipulation program. It is able to forge or decode packets of a wide number of protocols, send them on the wire, capture them, match requests and replies, and much more. It can easily handle most classical tasks like scanning, tracerouting, probing, unit tests, attacks or network discovery (it can replace hping, 85% of nmap, arpspoof, arp-sk, arping, tcpdump, tethereal, p0f, etc.)

And about packet loss and delay:

  • iptables have --probability option
  • IIRC it can QUEUE packets to insert delay

You might also consider using a combination of:

Mixing this with the expected levels of traffic generated by your app.


You might also consider using PcapPlusPlus. It has a packet creation engine that supports ICMP and a way to send packets to the network. Here is an example code for what you want (sending high-latency erroneous ICMP packets):

// open a pcap live device for interface with IP (put your IP address instead)
IPv4Address ipToSearch("");
PcapLiveDevice* liveDev = PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIp(ipToSearch);;


// send NUM_OF_ERRONEOUS_PACKETS_TO_GENERATE echo request packets
for (int i = 0; i < NUM_OF_ERRONEOUS_PACKETS_TO_GENERATE; i++)
    // create an Eth layer with whatever MAC addresses you want
    MacAddress srcMac(std::string("11:22:33:44:55:66")); // put the MAC address you want here
    MacAddress destMac(std::string("66:55:44:33:22:11")); // put the MAC address you want here
    EthLayer ethLayer(srcMac, destMac, ETHERTYPE_IP);

    // create IPv4 layer with whatever IPs you want (put the IPs you want instead)
    IPv4Layer ipLayer(IPv4Address(std::string("")), IPv4Address(std::string("")));

    // Create ICMP echo (ping) request layer
    IcmpLayer echoReqLayer;
    icmp_echo_request* echoReq = echoReqLayer.setEchoRequestData(100, 0, 0xe45104007dd6a751ULL, NULL, 0);

    // make the echo request erroneous. You can do whatever manipulation you want here
    echoReq->header->checksum = 0x1111;
    echoReq->header->code = 100;

    // create a packet with Eth, IPv4, ICMP echo layers;
    Packet echoRequestPacket(100);

    // send the packet


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .