using odd veths for packet injection and sniffing in examples
This commit is contained in:
parent
ca39826949
commit
e81db93021
@ -3,4 +3,4 @@ from scapy.all import *
|
|||||||
p = Ether() / IP(options=IPOption('\x44\x0c\x05\x00\x01\x02\x03\x04\x05\x06\x07\x08') / IPOption('\x82\x0b\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9')) / IPOption('\x00') / TCP() / "aaaaaaaaaaa"
|
p = Ether() / IP(options=IPOption('\x44\x0c\x05\x00\x01\x02\x03\x04\x05\x06\x07\x08') / IPOption('\x82\x0b\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9')) / IPOption('\x00') / TCP() / "aaaaaaaaaaa"
|
||||||
# p.show()
|
# p.show()
|
||||||
hexdump(p)
|
hexdump(p)
|
||||||
sendp(p, iface = "veth0")
|
sendp(p, iface = "veth1")
|
||||||
|
@ -24,9 +24,9 @@ We provide a small demo to let you test the program. It consists of the
|
|||||||
following scripts:
|
following scripts:
|
||||||
- [run_switch.sh] (run_switch.sh): compile the P4 program and starts the switch,
|
- [run_switch.sh] (run_switch.sh): compile the P4 program and starts the switch,
|
||||||
also configures the data plane by running the CLI [commands] (commands.txt)
|
also configures the data plane by running the CLI [commands] (commands.txt)
|
||||||
- [receive.py] (receive.py): sniff packets on port 3 (veth6) and print a hexdump
|
- [receive.py] (receive.py): sniff packets on port 3 (veth7) and print a hexdump
|
||||||
of them
|
of them
|
||||||
- [send_one.py] (send_one.py): send one simple IPv4 packet on port 0 (veth0)
|
- [send_one.py] (send_one.py): send one simple IPv4 packet on port 0 (veth1)
|
||||||
|
|
||||||
If you take a look at [commands.txt] (commands.txt), you'll notice the following
|
If you take a look at [commands.txt] (commands.txt), you'll notice the following
|
||||||
command: `mirroring_add 250 3`. This means that all the cloned packets with
|
command: `mirroring_add 250 3`. This means that all the cloned packets with
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
from scapy.all import *
|
from scapy.all import *
|
||||||
|
|
||||||
sniff(iface = "veth6", prn = lambda x: hexdump(x))
|
sniff(iface = "veth7", prn = lambda x: hexdump(x))
|
||||||
|
@ -3,4 +3,4 @@ from scapy.all import *
|
|||||||
p = Ether(dst="aa:bb:cc:dd:ee:ff") / IP(dst="10.0.1.10") / TCP() / "aaaaaaaaaaaaaaaaaaa"
|
p = Ether(dst="aa:bb:cc:dd:ee:ff") / IP(dst="10.0.1.10") / TCP() / "aaaaaaaaaaaaaaaaaaa"
|
||||||
# p.show()
|
# p.show()
|
||||||
hexdump(p)
|
hexdump(p)
|
||||||
sendp(p, iface = "veth0")
|
sendp(p, iface = "veth1")
|
||||||
|
@ -17,7 +17,7 @@ class Receiver(threading.Thread):
|
|||||||
big_lock.release()
|
big_lock.release()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
sniff(iface="veth2", prn=lambda x: self.received(x))
|
sniff(iface="veth3", prn=lambda x: self.received(x))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -34,7 +34,7 @@ def main():
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
big_lock.acquire()
|
big_lock.acquire()
|
||||||
sendp(p, iface="veth0", verbose=0)
|
sendp(p, iface="veth1", verbose=0)
|
||||||
print "Sent one"
|
print "Sent one"
|
||||||
big_lock.release()
|
big_lock.release()
|
||||||
time.sleep(packet_int)
|
time.sleep(packet_int)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user