]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/lib/send_bsr_packet.py
2 # Copyright (c) 2019 by VMware, Inc. ("VMware")
3 # Used Copyright (c) 2018 by Network Device Education Foundation, Inc.
4 # ("NetDEF") in this file.
6 # Permission to use, copy, modify, and/or distribute this software
7 # for any purpose with or without fee is hereby granted, provided
8 # that the above copyright notice and this permission notice appear
11 # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
15 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
16 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
17 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 from scapy
.all
import Raw
, sendp
27 def send_packet(packet
, iface
, interval
, count
):
29 Read BSR packet in Raw format and send it to specified interface
33 * `packet` : BSR packet in raw format
34 * `interface` : Interface from which packet would be send
35 * `interval` : Interval between the packets
36 * `count` : Number of packets to be sent
39 data
= binascii
.a2b_hex(packet
)
42 sendp(p
, inter
=int(interval
), iface
=iface
, count
=int(count
))
45 if __name__
== "__main__":
46 parser
= argparse
.ArgumentParser(description
="Send BSR Raw packet")
47 parser
.add_argument("packet", help="Packet in raw format")
48 parser
.add_argument("iface", help="Packet send to this ineterface")
49 parser
.add_argument("--interval", help="Interval between packets", default
=0)
51 "--count", help="Number of times packet is sent repetitively", default
=0
53 args
= parser
.parse_args()
55 if not args
.packet
or not args
.iface
:
58 send_packet(args
.packet
, args
.iface
, args
.interval
, args
.count
)