Updates to basic_tunnel and basic (#78)
* Adding initial implementation of basic_encap example * Updated basic_encap example to count the number of valid packets * Updated basic_encap example to put encapsulation layer after Ethernet header. * Added solution file for basic_encap example * Changed the name of the basic_encap example to basic_tunnel and called the new header myTunnel. Also changed the myTunnel field names slightly. * Updated the README file for the basic_tunnel exercise. Also added topo.pdf image to serve as a reference during implementation. * Updated basic/README.md to point to basic_tunnel as the next exercise. * Updated the README for basic to point to basic_tunnel. Updated the starter code for basic_tunnel to look like basic solution with todo comments. Updated send.py and receive.py to be able to send both plain IP packets and tunneled IP packets. Updated basic_tunnel.p4 to have same control flow as p4runtime exercise.
This commit is contained in:
@@ -6,7 +6,7 @@ import os
|
||||
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, UDP, Raw
|
||||
from scapy.all import IP, TCP, UDP, Raw
|
||||
from scapy.layers.inet import _IPOption_HDR
|
||||
|
||||
def get_if():
|
||||
@@ -34,10 +34,11 @@ class IPOption_MRI(IPOption):
|
||||
IntField("", 0),
|
||||
length_from=lambda pkt:pkt.count*4) ]
|
||||
def handle_pkt(pkt):
|
||||
print "got a packet"
|
||||
pkt.show2()
|
||||
# hexdump(pkt)
|
||||
sys.stdout.flush()
|
||||
if TCP in pkt and pkt[TCP].dport == 1234:
|
||||
print "got a packet"
|
||||
pkt.show2()
|
||||
# hexdump(pkt)
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def main():
|
||||
@@ -45,7 +46,7 @@ def main():
|
||||
iface = ifaces[0]
|
||||
print "sniffing on %s" % iface
|
||||
sys.stdout.flush()
|
||||
sniff(filter="tcp", iface = iface,
|
||||
sniff(iface = iface,
|
||||
prn = lambda x: handle_pkt(x))
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user