Generating erroneous traffic for testing

Solution 1:

The option you are thinking of is CONFIG_NET_PKTGEN.

Solution 2:

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% 

Solution 3:

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

Solution 4:

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