From 3bd96fcb13a5370086a6eddc03104e21a5f085be Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 30 Mar 2013 15:27:57 +0100 Subject: [PATCH] test: add an helper to generate many neighbors Using scapy, we generate a pcap with as many neighbors we need. --- tests/many-neighbors.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/many-neighbors.py diff --git a/tests/many-neighbors.py b/tests/many-neighbors.py new file mode 100644 index 00000000..c016e347 --- /dev/null +++ b/tests/many-neighbors.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +# Simple script to generate a lot of neighbors. This uses scapy. It +# needs a version of Scapy that contains an LLDP dissector. There is +# one in the scapy community repository: +# https://hg.secdev.org/scapy-com/file/dc0876d1c302/scapy/layers/lldp.py + +from scapy.all import * +from optparse import OptionParser + +parser = OptionParser() +parser.add_option("-o", "--output", dest="output", + help="write PCAP file to FILE", metavar="FILE", + default="out.pcap") +parser.add_option("-n", "--neighbors", dest="neighbors", + help="generate N neighbors", metavar="N", + default=60, type="int") + +(options, args) = parser.parse_args() + +wrpcap(options.output, + [Ether(dst="01:80:c2:00:00:0e", src="00:17:d1:a8:35:be")/ + LLDP(tlvlist=[LLDPChassisId(subtype="Locally assigned", value="titi-%03d" % i), + LLDPPortId(subtype="Interface name", value="eth0"), + LLDPTTL(seconds=120), + LLDPDUEnd()]) + for i in range(options.neighbors)]) + +# The generated pcap can be replayed with tcpreplay: +# tcpreplay -i veth0 -t out.pcap -- 2.39.5