]>
git.ipfire.org Git - thirdparty/lldpd.git/blob - tests/many-neighbors.py
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
8 from scapy
.all
import *
9 from optparse
import OptionParser
11 parser
= OptionParser()
12 parser
.add_option("-o", "--output", dest
="output",
13 help="write PCAP file to FILE", metavar
="FILE",
15 parser
.add_option("-n", "--neighbors", dest
="neighbors",
16 help="generate N neighbors", metavar
="N",
17 default
=60, type="int")
19 (options
, args
) = parser
.parse_args()
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"),
27 for i
in range(options
.neighbors
)])
29 # The generated pcap can be replayed with tcpreplay:
30 # tcpreplay -i veth0 -t out.pcap