]> git.ipfire.org Git - thirdparty/lldpd.git/blob - tests/many-neighbors.py
tests: report complete Linux version as well
[thirdparty/lldpd.git] / tests / many-neighbors.py
1 #!/usr/bin/env python
2
3 # Simple script to generate a lot of neighbors. This uses scapy. It
4 # needs a version of Scapy that contains an LLDP dissector. There is
5 # one in the scapy community repository:
6 # https://hg.secdev.org/scapy-com/file/dc0876d1c302/scapy/layers/lldp.py
7
8 from scapy.all import *
9 from optparse import OptionParser
10
11 parser = OptionParser()
12 parser.add_option("-o", "--output", dest="output",
13 help="write PCAP file to FILE", metavar="FILE",
14 default="out.pcap")
15 parser.add_option("-n", "--neighbors", dest="neighbors",
16 help="generate N neighbors", metavar="N",
17 default=60, type="int")
18
19 (options, args) = parser.parse_args()
20
21 wrpcap(options.output,
22 [Ether(dst="01:80:c2:00:00:0e", src="00:17:d1:a8:35:be")/
23 LLDP(tlvlist=[LLDPChassisId(subtype="Locally assigned", value="titi-%03d" % i),
24 LLDPPortId(subtype="Interface name", value="eth0"),
25 LLDPTTL(seconds=120),
26 LLDPDUEnd()])
27 for i in range(options.neighbors)])
28
29 # The generated pcap can be replayed with tcpreplay:
30 # tcpreplay -i veth0 -t out.pcap