class entry_hdr(Packet): """ Entry Header """ name = "entry" fields_desc = [ BitField("frame_type", 0, 8), IntField("number_of_entries", 10), IntField("tree_id", 1), # BitField('flush', 0, 8), BitField('key0', 0, 128), BitField('value0', 0, 32), BitField('key1', 0, 128), BitField('value1', 0, 32), BitField('key2', 0, 128), BitField('value2', 0, 32), BitField('key3', 0, 128), BitField('value3', 0, 32), BitField('key4', 0, 128), BitField('value4', 0, 32), BitField('key5', 0, 128), BitField('value5', 0, 32), BitField('key6', 0, 128), BitField('value6', 0, 32), BitField('key7', 0, 128), BitField('value7', 0, 32), BitField('key8', 0, 128), BitField('value8', 0, 32), BitField('key9', 0, 128), BitField('value9', 0, 32), ]
class KeyValPair(Packet): fields_desc = [ IntField("schema", 0), IntField("key", 0), IntField("val", 0), BitField("unprocessed", 0, 8) ] #add bit field
class Payload(Packet): fields_desc = [ IntField("data", None), IntField("encrypt", None), IntField("type", None), IntField("index", None) ]
class preamble(Packet): """ preamble Header """ name = "preamble" fields_desc = [ IntField("number_of_entries", 10), IntField("seg_number", 0), ]
class Query(Packet): name = "Query" fields_desc = [ BitField("protocol", 0, 8), IntField("port2count", 0), IntField("port2size", 0), IntField("port3count", 0), IntField("port3size", 0)]
class MetadataHeader_hoplatency(Packet): name = 'Metadata hop latency Header' fields_desc = [ IntField('Hop_Latency1', 0), IntField('Hop_Latency2', 0), IntField('Hop_Latency3', 0), IntField('Hop_Latency4', 0) ]
class PacketHeader(Packet): name = "PacketHeader" fields_desc = [ IntField("type", 0), IntField("seq_num", 0), IntField("length", 0), SignedIntField("checksum", 0), ]
class frame_type(Packet): """ Frame_type Header """ name = "frame_type" fields_desc = [ BitField("frame_type", 0, 8), IntField("number_of_entries", 10), IntField("tree_id", 1), ]
class MetadataHeader_switchid(Packet): name = 'Metadata switch id Header' fields_desc = [ IntField('SwitchID1', 0), IntField('SwitchID2', 0), IntField('SwitchID3', 0), IntField('SwitchID4', 0) ]
class KeyValue(Packet): name = "KeyValue" fields_desc = [ LongField("preamble", 1), ByteField("mtype", 0), IntField("key", 0), IntField("value", 0), ]
class STATS(Packet): name = "STATS" fields_desc = [ IntField("port2", 0), IntField("port3", 0), ShortField("enable",0), ShortField("prot_id", 0) ]
class SwitchTrace(Packet): fields_desc = [ IntField("swid", 0), IntField("qdepth", 0), IntField("qlatency", 0), IntField("plength", 0), IntField("txtotal", 0)] def extract_padding(self, p): return "", p
class P4calc(Packet): name = "P4calc" fields_desc = [ StrFixedLenField("op", "+", length=1), IntField("operand_a", 0), IntField("operand_b", 0), IntField("result", 0) ]
class SwitchTrace(Packet): fields_desc = [ IntField("swid", 0), IntField("qdepth", 0), IntField("qtdelta", 0) ] def extract_padding(self, p): return "", p
class NetChain(Packet): name = "KeyValue" fields_desc = [ LongField("preamble", 2), ByteField("mtype", 0), ByteField("dest", 0), IntField("key", 0), IntField("value", 0), ]
class CoLoR_Data(Packet): name = 'CoLoR_Data' fields_desc = [ BitField("Version", 7, 4, tot_size=1), BitField("Package", 3, 4, end_tot_size=1), ByteField("TTL", 64), LEShortField("pkg_length", None), XShortField("checksum", None), ByteField("header_length", None), ByteField("PID_pt", None), FieldLenField("PID_num", None, fmt="B", count_of="PIDs", adjust=lambda pkt, x: x - (pkt.Flags.R == True)), FlagsField("Flags", 0, 8, "rSCQMRBF"), ConditionalField(ShortField("Minimal_PID_CP", None), lambda pkt: pkt.Flags.M), StrFixedLenField("N_sid", "", 16), StrFixedLenField("L_sid", "", 20), StrFixedLenField("nid_cus", "", 16), ConditionalField( StrFixedLenField("nid_pro", "", 16), lambda pkt: pkt.Flags.B == False and pkt.Flags.R == True), ConditionalField( FieldLenField("QoS_len", None, fmt="B", length_of="QoS_requirements"), lambda pkt: pkt.Flags.Q == True), ConditionalField( StrLenField("QoS_requirements", "", length_from=lambda pkt: pkt.QoS_len), lambda pkt: pkt.Flags.Q == True), ConditionalField(IntField("HMAC", None), lambda pkt: pkt.Flags.C == True), ConditionalField(IntField("Seg_ID", None), lambda pkt: pkt.Flags.S == True), FieldListField("PIDs", [""], StrFixedLenField("", "", 4), count_from=lambda pkt: pkt.PID_num + (pkt.Flags.R == True)) ] def post_build(self, pkt, pay): if self.header_length is None: self.header_length = len(pkt) pkt = pkt[:6] + int2Bytes(self.header_length, 1) + pkt[7:] if self.pkg_length is None: self.pkg_length = len(pkt) + len(pay) pkt = pkt[:2] + int2BytesLE(self.pkg_length, 2) + pkt[4:] if self.checksum is None: self.checksum = CalcChecksum(pkt) pkt = pkt[:4] + int2Bytes(self.checksum, 2) + pkt[6:] # print(self.pkg_length, self.header_length, self.checksum) return pkt + pay
class ECMP(Packet): name = "ECMP" fields_desc = [ ShortField("is_load_balance", 1), ShortField("type", 0), ShortField("is_track", 0), IntField("port2_bytes", 0), IntField("port3_bytes", 0) ]
class P4calc(Packet): name = "P4calc" fields_desc = [ StrFixedLenField("P", "P", length=1), StrFixedLenField("Four", "4", length=1), XByteField("version", 0x01), StrFixedLenField("op", "+", length=1), IntField("operand_a", 0), IntField("operand_b", 0), IntField("result", 0xDEADBABE)]
class IPFIX(Packet): name = "IPFIX" fields_desc = [ ShortField("version", 10), ShortField("length", None), IntField("exportTime", None), IntField("sequenceNumber", 1), IntField("observationDomainID", 1), ]
class MetadataHeader(Packet): name = 'Metadata Header' fields_desc = [ IntField('SwitchID', 0), #ShortField('IngressPort', 0), #ShortField('EgressPort', 0), # ShortField means 16 bytes IntField('Hop_Latency', 0), ByteField('qid', 0), BitField('qdepth', 0, 24) ]
class KeyValue(Packet): name = "KeyValue" fields_desc = [ LongField("preamble", 1), #set to 1 IntField("num_valid", 1), ByteField("port", 0), ByteField("mtype", 0), IntField("key", 0), IntField("value", 0), ]
class P4inc(Packet): name = "P4inc" fields_desc = [ StrFixedLenField("P", "P", length=1), # P StrFixedLenField("Four", "4", length=1), # 4 XByteField("version", 0x01), # version XByteField("bos", 0x00), # bottom of stack, last packet 0/1 IntField("data", 0), # data packet IntField("result", 112) ] # aggregated data
class P4inc(Packet): name = "P4inc" fields_desc = [ StrFixedLenField("P", "P", length=1), # P StrFixedLenField("Four", "4", length=1), # 4 XByteField("version", 0x01), # version XByteField("bos", 0x00), IntField("data", 0), IntField("result", 0) ]
class Migration(Packet): name = "Migration" fields_desc = [BitField("protocol", 0, 8), BitField("stage", 0, 8), ShortField("index", 0), IntField("state", 0), BitField("mac", 0, 64), IntField("verify", 0), ShortField("mainProg", 0), ShortField("deltaProg", 0)]
class P4tcp(Packet): name = "P4tcp" fields_desc = [ StrFixedLenField("P", "P", length=1), StrFixedLenField("Four", "4", length=1), XByteField("version", 0x01), StrFixedLenField("packetType", "D", length=1), StrFixedLenField("srcPort", "0", length=2), StrFixedLenField("dstPort", "0", length=2), IntField("seqNo", 0), IntField("ackNo", 0), StrFixedLenField("dataPayload", "", length=PAYLOAD_LENGTH)]
class preamble(Packet): """ preamble Header """ name = "preamble" fields_desc = [ BitField("k", 0, 7), BitField("end", 0, 1), BitField("worker_id", 1, 8), BitField("epoch", 1, 16), IntField("seg_number", 0), BitField("pool_version", 1, 8), IntField("pool_index", 1), ]
class OpenFlowMeterBand_v1_3(Packet): """ OpenFlow Meter Band Field """ name = 'OpenFlowMeterBand_v1_3' fields_desc = [ ShortField('Type', None), ShortField('Length', None), IntField('Rate', None), IntField('BurstSize', None), ]
class IPOption_MRI(IPOption): name = "MRI" option = 31 fields_desc = [ _IPOption_HDR, FieldLenField("length", None, fmt="B", length_of="swtraces", adjust=lambda pkt,l:l*2+4), ShortField("count", 0), IntField("pathid", 0), IntField("pcount", 0), PacketListField("swtraces", [], SwitchTrace, count_from=lambda pkt:(pkt.count*1)) ]
class NSH(Packet): """Define the NSH protocol for the packet analysis.""" name = "nsh" fields_desc = [ XBitField("flags", 0x0, 10), XBitField("length", 0x6, 6), XByteField("MDtype", 0x1), XByteField("nextproto", 0x3), IntField("nsp_nsi", 0), IntField("c1", 0), IntField("c2", 0), IntField("c3", 0), IntField("c4", 0) ]
class OpenFlowPacketQueue_v1_3(Packet): """ OpenFlow Bucket Field """ name = 'OpenFlowBucket_v1_3' fields_desc = [ IntField('QueueID', None), IntField('Port', None), ShortField('Length', None), XByteField('Pad', None), _PacketField('QueueProprieties', None, OpenFlowQueueProprieties_v1_3, 5), ]