clean up unused Python imports (#454)
* Remove unused python imports These changes have been auto-generated with: pip3 install isort autoflake isort -rc -sl . autoflake --remove-all-unused-imports -i -r . isort -rc -m 3 . Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org> * python: remove redundant parenthesis Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
parent
50f397b249
commit
d84179e42f
@ -1,14 +1,20 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import sys
|
|
||||||
import struct
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr
|
from scapy.all import (
|
||||||
from scapy.all import Packet, IPOption
|
TCP,
|
||||||
from scapy.all import ShortField, IntField, LongField, BitField, FieldListField, FieldLenField
|
FieldLenField,
|
||||||
from scapy.all import IP, TCP, UDP, Raw
|
FieldListField,
|
||||||
|
IntField,
|
||||||
|
IPOption,
|
||||||
|
ShortField,
|
||||||
|
get_if_list,
|
||||||
|
sniff
|
||||||
|
)
|
||||||
from scapy.layers.inet import _IPOption_HDR
|
from scapy.layers.inet import _IPOption_HDR
|
||||||
|
|
||||||
|
|
||||||
def get_if():
|
def get_if():
|
||||||
ifs=get_if_list()
|
ifs=get_if_list()
|
||||||
iface=None
|
iface=None
|
||||||
@ -44,7 +50,7 @@ def handle_pkt(pkt):
|
|||||||
def main():
|
def main():
|
||||||
ifaces = [i for i in os.listdir('/sys/class/net/') if 'eth' in i]
|
ifaces = [i for i in os.listdir('/sys/class/net/') if 'eth' in i]
|
||||||
iface = ifaces[0]
|
iface = ifaces[0]
|
||||||
print(("sniffing on %s" % iface))
|
print("sniffing on %s" % iface)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
sniff(iface = iface,
|
sniff(iface = iface,
|
||||||
prn = lambda x: handle_pkt(x))
|
prn = lambda x: handle_pkt(x))
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
import socket
|
|
||||||
import random
|
import random
|
||||||
import struct
|
import socket
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from scapy.all import IP, TCP, Ether, get_if_hwaddr, get_if_list, sendp
|
||||||
|
|
||||||
from scapy.all import sendp, send, get_if_list, get_if_hwaddr
|
|
||||||
from scapy.all import Packet
|
|
||||||
from scapy.all import Ether, IP, UDP, TCP
|
|
||||||
|
|
||||||
def get_if():
|
def get_if():
|
||||||
ifs=get_if_list()
|
ifs=get_if_list()
|
||||||
@ -30,7 +27,7 @@ def main():
|
|||||||
addr = socket.gethostbyname(sys.argv[1])
|
addr = socket.gethostbyname(sys.argv[1])
|
||||||
iface = get_if()
|
iface = get_if()
|
||||||
|
|
||||||
print(("sending on interface %s to %s" % (iface, str(addr))))
|
print("sending on interface %s to %s" % (iface, str(addr)))
|
||||||
pkt = Ether(src=get_if_hwaddr(iface), dst='ff:ff:ff:ff:ff:ff')
|
pkt = Ether(src=get_if_hwaddr(iface), dst='ff:ff:ff:ff:ff:ff')
|
||||||
pkt = pkt /IP(dst=addr) / TCP(dport=1234, sport=random.randint(49152,65535)) / sys.argv[2]
|
pkt = pkt /IP(dst=addr) / TCP(dport=1234, sport=random.randint(49152,65535)) / sys.argv[2]
|
||||||
pkt.show2()
|
pkt.show2()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
from scapy.all import *
|
from scapy.all import *
|
||||||
import sys, os
|
|
||||||
|
|
||||||
TYPE_MYTUNNEL = 0x1212
|
TYPE_MYTUNNEL = 0x1212
|
||||||
TYPE_IPV4 = 0x0800
|
TYPE_IPV4 = 0x0800
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import sys
|
|
||||||
import struct
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr
|
|
||||||
from scapy.all import Packet, IPOption
|
|
||||||
from scapy.all import ShortField, IntField, LongField, BitField, FieldListField, FieldLenField
|
|
||||||
from scapy.all import IP, TCP, UDP, Raw
|
|
||||||
from scapy.layers.inet import _IPOption_HDR
|
|
||||||
from myTunnel_header import MyTunnel
|
from myTunnel_header import MyTunnel
|
||||||
|
from scapy.all import TCP, get_if_list, sniff
|
||||||
|
|
||||||
|
|
||||||
def get_if():
|
def get_if():
|
||||||
ifs=get_if_list()
|
ifs=get_if_list()
|
||||||
@ -34,7 +30,7 @@ def handle_pkt(pkt):
|
|||||||
def main():
|
def main():
|
||||||
ifaces = [i for i in os.listdir('/sys/class/net/') if 'eth' in i]
|
ifaces = [i for i in os.listdir('/sys/class/net/') if 'eth' in i]
|
||||||
iface = ifaces[0]
|
iface = ifaces[0]
|
||||||
print(("sniffing on %s" % iface))
|
print("sniffing on %s" % iface)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
sniff(iface = iface,
|
sniff(iface = iface,
|
||||||
prn = lambda x: handle_pkt(x))
|
prn = lambda x: handle_pkt(x))
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
|
||||||
import socket
|
|
||||||
import random
|
import random
|
||||||
import struct
|
import socket
|
||||||
import argparse
|
|
||||||
|
|
||||||
from scapy.all import sendp, send, get_if_list, get_if_hwaddr, hexdump
|
|
||||||
from scapy.all import Packet
|
|
||||||
from scapy.all import Ether, IP, UDP, TCP
|
|
||||||
from myTunnel_header import MyTunnel
|
from myTunnel_header import MyTunnel
|
||||||
|
from scapy.all import IP, TCP, Ether, get_if_hwaddr, get_if_list, sendp
|
||||||
|
|
||||||
|
|
||||||
def get_if():
|
def get_if():
|
||||||
ifs=get_if_list()
|
ifs=get_if_list()
|
||||||
@ -35,11 +31,11 @@ def main():
|
|||||||
iface = get_if()
|
iface = get_if()
|
||||||
|
|
||||||
if (dst_id is not None):
|
if (dst_id is not None):
|
||||||
print(("sending on interface {} to dst_id {}".format(iface, str(dst_id))))
|
print("sending on interface {} to dst_id {}".format(iface, str(dst_id)))
|
||||||
pkt = Ether(src=get_if_hwaddr(iface), dst='ff:ff:ff:ff:ff:ff')
|
pkt = Ether(src=get_if_hwaddr(iface), dst='ff:ff:ff:ff:ff:ff')
|
||||||
pkt = pkt / MyTunnel(dst_id=dst_id) / IP(dst=addr) / args.message
|
pkt = pkt / MyTunnel(dst_id=dst_id) / IP(dst=addr) / args.message
|
||||||
else:
|
else:
|
||||||
print(("sending on interface {} to IP addr {}".format(iface, str(addr))))
|
print("sending on interface {} to IP addr {}".format(iface, str(addr)))
|
||||||
pkt = Ether(src=get_if_hwaddr(iface), dst='ff:ff:ff:ff:ff:ff')
|
pkt = Ether(src=get_if_hwaddr(iface), dst='ff:ff:ff:ff:ff:ff')
|
||||||
pkt = pkt / IP(dst=addr) / TCP(dport=1234, sport=random.randint(49152,65535)) / args.message
|
pkt = pkt / IP(dst=addr) / TCP(dport=1234, sport=random.randint(49152,65535)) / args.message
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
import socket
|
|
||||||
import random
|
|
||||||
import struct
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from scapy.all import sendp, send, srp1
|
from scapy.all import (
|
||||||
from scapy.all import Packet, hexdump
|
Ether,
|
||||||
from scapy.all import Ether, StrFixedLenField, XByteField, IntField
|
IntField,
|
||||||
from scapy.all import bind_layers
|
Packet,
|
||||||
import readline
|
StrFixedLenField,
|
||||||
|
XByteField,
|
||||||
|
bind_layers,
|
||||||
|
srp1
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class P4calc(Packet):
|
class P4calc(Packet):
|
||||||
name = "P4calc"
|
name = "P4calc"
|
||||||
@ -84,7 +84,7 @@ def main():
|
|||||||
if resp:
|
if resp:
|
||||||
p4calc=resp[P4calc]
|
p4calc=resp[P4calc]
|
||||||
if p4calc:
|
if p4calc:
|
||||||
print((p4calc.result))
|
print(p4calc.result)
|
||||||
else:
|
else:
|
||||||
print("cannot find P4calc header in the packet")
|
print("cannot find P4calc header in the packet")
|
||||||
else:
|
else:
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import sys
|
import sys
|
||||||
import struct
|
|
||||||
|
|
||||||
from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr
|
from scapy.all import get_if_list, sniff
|
||||||
from scapy.all import Packet
|
|
||||||
from scapy.all import IP, UDP, Raw
|
|
||||||
from scapy.layers.inet import _IPOption_HDR
|
|
||||||
|
|
||||||
def get_if():
|
def get_if():
|
||||||
ifs=get_if_list()
|
ifs=get_if_list()
|
||||||
@ -28,7 +25,7 @@ def handle_pkt(pkt):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
iface = 'eth0'
|
iface = 'eth0'
|
||||||
print(("sniffing on %s" % iface))
|
print("sniffing on %s" % iface)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
sniff(filter="udp and port 4321", iface = iface,
|
sniff(filter="udp and port 4321", iface = iface,
|
||||||
prn = lambda x: handle_pkt(x))
|
prn = lambda x: handle_pkt(x))
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
import socket
|
import socket
|
||||||
import random
|
import sys
|
||||||
import struct
|
|
||||||
|
|
||||||
from scapy.all import sendp, send, hexdump, get_if_list, get_if_hwaddr
|
|
||||||
from scapy.all import Packet, IPOption
|
|
||||||
from scapy.all import Ether, IP, UDP
|
|
||||||
from scapy.all import IntField, FieldListField, FieldLenField, ShortField
|
|
||||||
from scapy.layers.inet import _IPOption_HDR
|
|
||||||
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
from scapy.all import IP, UDP, Ether, get_if_hwaddr, get_if_list, sendp
|
||||||
|
|
||||||
|
|
||||||
def get_if():
|
def get_if():
|
||||||
ifs=get_if_list()
|
ifs=get_if_list()
|
||||||
iface=None # "h1-eth0"
|
iface=None # "h1-eth0"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from probe_hdrs import *
|
from probe_hdrs import *
|
||||||
|
|
||||||
|
|
||||||
def expand(x):
|
def expand(x):
|
||||||
yield x
|
yield x
|
||||||
while x.payload:
|
while x.payload:
|
||||||
@ -14,11 +15,11 @@ def handle_pkt(pkt):
|
|||||||
print("")
|
print("")
|
||||||
for sw in data_layers:
|
for sw in data_layers:
|
||||||
utilization = 0 if sw.cur_time == sw.last_time else 8.0*sw.byte_cnt/(sw.cur_time - sw.last_time)
|
utilization = 0 if sw.cur_time == sw.last_time else 8.0*sw.byte_cnt/(sw.cur_time - sw.last_time)
|
||||||
print(("Switch {} - Port {}: {} Mbps".format(sw.swid, sw.port, utilization)))
|
print("Switch {} - Port {}: {} Mbps".format(sw.swid, sw.port, utilization))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
iface = 'eth0'
|
iface = 'eth0'
|
||||||
print(("sniffing on {}".format(iface)))
|
print("sniffing on {}".format(iface))
|
||||||
sniff(iface = iface,
|
sniff(iface = iface,
|
||||||
prn = lambda x: handle_pkt(x))
|
prn = lambda x: handle_pkt(x))
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from probe_hdrs import *
|
from probe_hdrs import *
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
probe_pkt = Ether(dst='ff:ff:ff:ff:ff:ff', src=get_if_hwaddr('eth0')) / \
|
probe_pkt = Ether(dst='ff:ff:ff:ff:ff:ff', src=get_if_hwaddr('eth0')) / \
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import sys
|
|
||||||
import struct
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr
|
from scapy.all import (
|
||||||
from scapy.all import Packet, IPOption
|
FieldLenField,
|
||||||
from scapy.all import ShortField, IntField, LongField, BitField, FieldListField, FieldLenField
|
FieldListField,
|
||||||
from scapy.all import IP, UDP, Raw
|
IntField,
|
||||||
|
IPOption,
|
||||||
|
ShortField,
|
||||||
|
get_if_list,
|
||||||
|
sniff
|
||||||
|
)
|
||||||
from scapy.layers.inet import _IPOption_HDR
|
from scapy.layers.inet import _IPOption_HDR
|
||||||
|
|
||||||
|
|
||||||
def get_if():
|
def get_if():
|
||||||
ifs=get_if_list()
|
ifs=get_if_list()
|
||||||
iface=None
|
iface=None
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
import socket
|
|
||||||
import random
|
import random
|
||||||
import struct
|
import socket
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from scapy.all import IP, TCP, Ether, get_if_hwaddr, get_if_list, sendp
|
||||||
|
|
||||||
from scapy.all import sendp, send, get_if_list, get_if_hwaddr
|
|
||||||
from scapy.all import Packet
|
|
||||||
from scapy.all import Ether, IP, UDP, TCP
|
|
||||||
|
|
||||||
def get_if():
|
def get_if():
|
||||||
ifs=get_if_list()
|
ifs=get_if_list()
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import sys
|
import sys
|
||||||
import struct
|
|
||||||
|
|
||||||
from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr
|
from scapy.all import (
|
||||||
from scapy.all import Packet, IPOption
|
FieldLenField,
|
||||||
from scapy.all import PacketListField, ShortField, IntField, LongField, BitField, FieldListField, FieldLenField
|
IntField,
|
||||||
from scapy.all import IP, UDP, Raw
|
IPOption,
|
||||||
|
Packet,
|
||||||
|
PacketListField,
|
||||||
|
ShortField,
|
||||||
|
get_if_list,
|
||||||
|
sniff
|
||||||
|
)
|
||||||
from scapy.layers.inet import _IPOption_HDR
|
from scapy.layers.inet import _IPOption_HDR
|
||||||
|
|
||||||
|
|
||||||
def get_if():
|
def get_if():
|
||||||
ifs=get_if_list()
|
ifs=get_if_list()
|
||||||
iface=None
|
iface=None
|
||||||
|
@ -1,18 +1,25 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
import socket
|
import socket
|
||||||
import random
|
import sys
|
||||||
import struct
|
from time import sleep
|
||||||
|
|
||||||
from scapy.all import sendp, send, hexdump, get_if_list, get_if_hwaddr
|
from scapy.all import (
|
||||||
from scapy.all import Packet, IPOption
|
IP,
|
||||||
from scapy.all import Ether, IP, UDP
|
UDP,
|
||||||
from scapy.all import IntField, FieldListField, FieldLenField, ShortField, PacketListField
|
Ether,
|
||||||
|
FieldLenField,
|
||||||
|
IntField,
|
||||||
|
IPOption,
|
||||||
|
Packet,
|
||||||
|
PacketListField,
|
||||||
|
ShortField,
|
||||||
|
get_if_hwaddr,
|
||||||
|
get_if_list,
|
||||||
|
sendp
|
||||||
|
)
|
||||||
from scapy.layers.inet import _IPOption_HDR
|
from scapy.layers.inet import _IPOption_HDR
|
||||||
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
def get_if():
|
def get_if():
|
||||||
ifs=get_if_list()
|
ifs=get_if_list()
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import argparse
|
import argparse
|
||||||
import grpc
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
import grpc
|
||||||
|
|
||||||
# Import P4Runtime lib from parent utils dir
|
# Import P4Runtime lib from parent utils dir
|
||||||
# Probably there's a better way of doing this.
|
# Probably there's a better way of doing this.
|
||||||
sys.path.append(
|
sys.path.append(
|
||||||
os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
||||||
'../../utils/'))
|
'../../utils/'))
|
||||||
import p4runtime_lib.bmv2
|
import p4runtime_lib.bmv2
|
||||||
|
import p4runtime_lib.helper
|
||||||
from p4runtime_lib.error_utils import printGrpcError
|
from p4runtime_lib.error_utils import printGrpcError
|
||||||
from p4runtime_lib.switch import ShutdownAllSwitchConnections
|
from p4runtime_lib.switch import ShutdownAllSwitchConnections
|
||||||
import p4runtime_lib.helper
|
|
||||||
|
|
||||||
SWITCH_TO_HOST_PORT = 1
|
SWITCH_TO_HOST_PORT = 1
|
||||||
SWITCH_TO_SWITCH_PORT = 2
|
SWITCH_TO_SWITCH_PORT = 2
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import argparse
|
import argparse
|
||||||
import grpc
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
import grpc
|
||||||
|
|
||||||
# Import P4Runtime lib from parent utils dir
|
# Import P4Runtime lib from parent utils dir
|
||||||
# Probably there's a better way of doing this.
|
# Probably there's a better way of doing this.
|
||||||
sys.path.append(
|
sys.path.append(
|
||||||
os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
||||||
'../../utils/'))
|
'../../utils/'))
|
||||||
import p4runtime_lib.bmv2
|
import p4runtime_lib.bmv2
|
||||||
from p4runtime_lib.switch import ShutdownAllSwitchConnections
|
|
||||||
import p4runtime_lib.helper
|
import p4runtime_lib.helper
|
||||||
|
from p4runtime_lib.switch import ShutdownAllSwitchConnections
|
||||||
|
|
||||||
SWITCH_TO_HOST_PORT = 1
|
SWITCH_TO_HOST_PORT = 1
|
||||||
SWITCH_TO_SWITCH_PORT = 2
|
SWITCH_TO_SWITCH_PORT = 2
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from scapy.all import sniff, get_if_list
|
|
||||||
|
from scapy.all import sniff
|
||||||
|
|
||||||
|
|
||||||
def handle_pkt(pkt):
|
def handle_pkt(pkt):
|
||||||
|
@ -2,12 +2,10 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
from scapy.all import sendp, send, hexdump, get_if_list, get_if_hwaddr
|
|
||||||
from scapy.all import Ether, IP, UDP, TCP
|
|
||||||
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
from scapy.all import IP, TCP, UDP, Ether, get_if_hwaddr, get_if_list, sendp
|
||||||
|
|
||||||
|
|
||||||
def get_if():
|
def get_if():
|
||||||
iface = None
|
iface = None
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import sys
|
import sys
|
||||||
import struct
|
|
||||||
|
|
||||||
from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr, bind_layers
|
from scapy.all import Ether, IPOption, Packet, bind_layers, get_if_list, sniff
|
||||||
from scapy.all import Packet, IPOption
|
|
||||||
from scapy.all import IP, UDP, Raw, Ether
|
|
||||||
from scapy.layers.inet import _IPOption_HDR
|
|
||||||
from scapy.fields import *
|
from scapy.fields import *
|
||||||
|
from scapy.layers.inet import _IPOption_HDR
|
||||||
|
|
||||||
|
|
||||||
def get_if():
|
def get_if():
|
||||||
ifs=get_if_list()
|
ifs=get_if_list()
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
import socket
|
import socket
|
||||||
import random
|
import sys
|
||||||
import struct
|
|
||||||
|
|
||||||
from scapy.all import sendp, send, get_if_list, get_if_hwaddr, bind_layers
|
from scapy.all import (
|
||||||
from scapy.all import Packet
|
IP,
|
||||||
from scapy.all import Ether, IP, UDP
|
UDP,
|
||||||
|
Ether,
|
||||||
|
Packet,
|
||||||
|
bind_layers,
|
||||||
|
get_if_hwaddr,
|
||||||
|
get_if_list,
|
||||||
|
sendp
|
||||||
|
)
|
||||||
from scapy.fields import *
|
from scapy.fields import *
|
||||||
import readline
|
|
||||||
|
|
||||||
def get_if():
|
def get_if():
|
||||||
ifs=get_if_list()
|
ifs=get_if_list()
|
||||||
|
@ -2,6 +2,7 @@ import subprocess
|
|||||||
|
|
||||||
from shortest_path import ShortestPath
|
from shortest_path import ShortestPath
|
||||||
|
|
||||||
|
|
||||||
class AppController:
|
class AppController:
|
||||||
|
|
||||||
def __init__(self, manifest=None, target=None, topo=None, net=None, links=None):
|
def __init__(self, manifest=None, target=None, topo=None, net=None, links=None):
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from mininet.topo import Topo
|
from mininet.topo import Topo
|
||||||
|
|
||||||
|
|
||||||
class AppTopo(Topo):
|
class AppTopo(Topo):
|
||||||
|
|
||||||
def __init__(self, links, latencies={}, manifest=None, target=None,
|
def __init__(self, links, latencies={}, manifest=None, target=None,
|
||||||
|
@ -15,25 +15,21 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import signal
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import subprocess
|
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
|
||||||
import importlib
|
import importlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
from mininet.net import Mininet
|
|
||||||
from mininet.topo import Topo
|
|
||||||
from mininet.link import TCLink
|
|
||||||
from mininet.log import setLogLevel, info
|
|
||||||
from mininet.cli import CLI
|
|
||||||
|
|
||||||
from p4_mininet import P4Switch, P4Host
|
|
||||||
import apptopo
|
|
||||||
import appcontroller
|
import appcontroller
|
||||||
|
import apptopo
|
||||||
|
from mininet.cli import CLI
|
||||||
|
from mininet.link import TCLink
|
||||||
|
from mininet.log import setLogLevel
|
||||||
|
from mininet.net import Mininet
|
||||||
|
from p4_mininet import P4Host, P4Switch
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Mininet demo')
|
parser = argparse.ArgumentParser(description='Mininet demo')
|
||||||
parser.add_argument('--behavioral-exe', help='Path to behavioral executable',
|
parser.add_argument('--behavioral-exe', help='Path to behavioral executable',
|
||||||
|
@ -13,15 +13,16 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from mininet.net import Mininet
|
import os
|
||||||
from mininet.node import Switch, Host
|
import socket
|
||||||
from mininet.log import setLogLevel, info, error, debug
|
import tempfile
|
||||||
from mininet.moduledeps import pathCheck
|
|
||||||
from sys import exit
|
from sys import exit
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import os
|
|
||||||
import tempfile
|
from mininet.log import debug, error, info
|
||||||
import socket
|
from mininet.moduledeps import pathCheck
|
||||||
|
from mininet.node import Host, Switch
|
||||||
|
|
||||||
|
|
||||||
class P4Host(Host):
|
class P4Host(Host):
|
||||||
def config(self, **params):
|
def config(self, **params):
|
||||||
|
@ -15,17 +15,16 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from mininet.net import Mininet
|
|
||||||
from mininet.topo import Topo
|
|
||||||
from mininet.log import setLogLevel, info
|
|
||||||
from mininet.cli import CLI
|
|
||||||
|
|
||||||
from p4_mininet import P4Switch, P4Host
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
from subprocess import PIPE, Popen
|
from subprocess import PIPE, Popen
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
from mininet.cli import CLI
|
||||||
|
from mininet.log import setLogLevel
|
||||||
|
from mininet.net import Mininet
|
||||||
|
from mininet.topo import Topo
|
||||||
|
from p4_mininet import P4Host, P4Switch
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Mininet demo')
|
parser = argparse.ArgumentParser(description='Mininet demo')
|
||||||
parser.add_argument('--behavioral-exe', help='Path to behavioral executable',
|
parser.add_argument('--behavioral-exe', help='Path to behavioral executable',
|
||||||
type=str, action="store", required=True)
|
type=str, action="store", required=True)
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
|
|
||||||
def check_listening_on_port(port):
|
def check_listening_on_port(port):
|
||||||
for c in psutil.net_connections(kind='inet'):
|
for c in psutil.net_connections(kind='inet'):
|
||||||
if c.status == 'LISTEN' and c.laddr[1] == port:
|
if c.status == 'LISTEN' and c.laddr[1] == port:
|
||||||
|
@ -13,16 +13,14 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from mininet.net import Mininet
|
|
||||||
from mininet.node import Switch, Host
|
|
||||||
from mininet.log import setLogLevel, info, error, debug
|
|
||||||
from mininet.moduledeps import pathCheck
|
|
||||||
from sys import exit
|
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import socket
|
from sys import exit
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
from mininet.log import debug, error, info
|
||||||
|
from mininet.moduledeps import pathCheck
|
||||||
|
from mininet.node import Host, Switch
|
||||||
from netstat import check_listening_on_port
|
from netstat import check_listening_on_port
|
||||||
|
|
||||||
SWITCH_START_TIMEOUT = 10 # seconds
|
SWITCH_START_TIMEOUT = 10 # seconds
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
from collections import OrderedDict
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import tarfile
|
import tarfile
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='p4apprunner')
|
parser = argparse.ArgumentParser(description='p4apprunner')
|
||||||
parser.add_argument('--build-dir', help='Directory to build in.',
|
parser.add_argument('--build-dir', help='Directory to build in.',
|
||||||
|
@ -12,9 +12,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
from .switch import SwitchConnection
|
|
||||||
from p4.tmp import p4config_pb2
|
from p4.tmp import p4config_pb2
|
||||||
|
|
||||||
|
from .switch import SwitchConnection
|
||||||
|
|
||||||
|
|
||||||
def buildDeviceConfig(bmv2_json_file_path=None):
|
def buildDeviceConfig(bmv2_json_file_path=None):
|
||||||
"Builds the device config for BMv2"
|
"Builds the device config for BMv2"
|
||||||
|
@ -12,11 +12,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
import math
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
import math
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
This package contains several helper functions for encoding to and decoding from byte strings:
|
This package contains several helper functions for encoding to and decoding from byte strings:
|
||||||
- integers
|
- integers
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from google.rpc import status_pb2, code_pb2
|
|
||||||
import grpc
|
import grpc
|
||||||
|
from google.rpc import code_pb2, status_pb2
|
||||||
from p4.v1 import p4runtime_pb2
|
from p4.v1 import p4runtime_pb2
|
||||||
from p4.v1 import p4runtime_pb2_grpc
|
|
||||||
|
|
||||||
# Used to indicate that the gRPC error Status object returned by the server has
|
# Used to indicate that the gRPC error Status object returned by the server has
|
||||||
# an incorrect format.
|
# an incorrect format.
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import google.protobuf.text_format
|
import google.protobuf.text_format
|
||||||
from p4.v1 import p4runtime_pb2
|
|
||||||
from p4.config.v1 import p4info_pb2
|
from p4.config.v1 import p4info_pb2
|
||||||
|
from p4.v1 import p4runtime_pb2
|
||||||
|
|
||||||
from .convert import encode
|
from .convert import encode
|
||||||
|
|
||||||
|
|
||||||
class P4InfoHelper(object):
|
class P4InfoHelper(object):
|
||||||
def __init__(self, p4_info_filepath):
|
def __init__(self, p4_info_filepath):
|
||||||
p4info = p4info_pb2.P4Info()
|
p4info = p4info_pb2.P4Info()
|
||||||
|
@ -19,11 +19,10 @@ import json
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from . import bmv2
|
|
||||||
from . import helper
|
|
||||||
|
|
||||||
from p4.config.v1 import p4info_pb2
|
from p4.config.v1 import p4info_pb2
|
||||||
|
|
||||||
|
from . import bmv2, helper
|
||||||
|
|
||||||
|
|
||||||
def error(msg):
|
def error(msg):
|
||||||
print(' - ERROR! ' + msg, file=sys.stderr)
|
print(' - ERROR! ' + msg, file=sys.stderr)
|
||||||
|
@ -12,14 +12,13 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
from queue import Queue
|
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from queue import Queue
|
||||||
|
|
||||||
import grpc
|
import grpc
|
||||||
from p4.v1 import p4runtime_pb2
|
|
||||||
from p4.v1 import p4runtime_pb2_grpc
|
|
||||||
from p4.tmp import p4config_pb2
|
from p4.tmp import p4config_pb2
|
||||||
|
from p4.v1 import p4runtime_pb2, p4runtime_pb2_grpc
|
||||||
|
|
||||||
MSG_LOG_MAX_LEN = 1024
|
MSG_LOG_MAX_LEN = 1024
|
||||||
|
|
||||||
|
@ -14,15 +14,16 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys, os, tempfile, socket
|
import os
|
||||||
|
import tempfile
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
from mininet.node import Switch
|
from mininet.log import debug, error, info
|
||||||
from mininet.moduledeps import pathCheck
|
from mininet.moduledeps import pathCheck
|
||||||
from mininet.log import info, error, debug
|
from mininet.node import Switch
|
||||||
|
|
||||||
from p4_mininet import P4Switch, SWITCH_START_TIMEOUT
|
|
||||||
from netstat import check_listening_on_port
|
from netstat import check_listening_on_port
|
||||||
|
from p4_mininet import SWITCH_START_TIMEOUT, P4Switch
|
||||||
|
|
||||||
|
|
||||||
class P4RuntimeSwitch(P4Switch):
|
class P4RuntimeSwitch(P4Switch):
|
||||||
"BMv2 switch with gRPC support"
|
"BMv2 switch with gRPC support"
|
||||||
|
@ -19,18 +19,20 @@
|
|||||||
# We encourage you to dissect this script to better understand the BMv2/Mininet
|
# We encourage you to dissect this script to better understand the BMv2/Mininet
|
||||||
# environment used by the P4 tutorial.
|
# environment used by the P4 tutorial.
|
||||||
#
|
#
|
||||||
import os, sys, json, subprocess, re, argparse
|
import argparse
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
from p4_mininet import P4Switch, P4Host
|
import p4runtime_lib.simple_controller
|
||||||
|
from mininet.cli import CLI
|
||||||
|
from mininet.link import TCLink
|
||||||
from mininet.net import Mininet
|
from mininet.net import Mininet
|
||||||
from mininet.topo import Topo
|
from mininet.topo import Topo
|
||||||
from mininet.link import TCLink
|
from p4_mininet import P4Host, P4Switch
|
||||||
from mininet.cli import CLI
|
|
||||||
|
|
||||||
from p4runtime_switch import P4RuntimeSwitch
|
from p4runtime_switch import P4RuntimeSwitch
|
||||||
import p4runtime_lib.simple_controller
|
|
||||||
|
|
||||||
def configureP4Switch(**switch_args):
|
def configureP4Switch(**switch_args):
|
||||||
""" Helper class that is called by mininet to initialize
|
""" Helper class that is called by mininet to initialize
|
||||||
|
Loading…
x
Reference in New Issue
Block a user