Basic Encapsulation Example (#64)
* 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.
This commit is contained in:
20
P4D2_2017_Fall/exercises/basic_tunnel/myTunnel_header.py
Normal file
20
P4D2_2017_Fall/exercises/basic_tunnel/myTunnel_header.py
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
from scapy.all import *
|
||||
import sys, os
|
||||
|
||||
TYPE_MYTUNNEL = 0x1212
|
||||
TYPE_IPV4 = 0x0800
|
||||
|
||||
class MyTunnel(Packet):
|
||||
name = "MyTunnel"
|
||||
fields_desc = [
|
||||
ShortField("pid", 0),
|
||||
ShortField("dst_id", 0)
|
||||
]
|
||||
def mysummary(self):
|
||||
return self.sprintf("pid=%pid%, dst_id=%dst_id%")
|
||||
|
||||
|
||||
bind_layers(Ether, MyTunnel, type=TYPE_MYTUNNEL)
|
||||
bind_layers(MyTunnel, IP, pid=TYPE_IPV4)
|
||||
|
||||
Reference in New Issue
Block a user