MCPcopy Create free account
hub / github.com/FDio/vpp / IPFIXDecoder

Class IPFIXDecoder

test/ipfix.py:517–557  ·  view source on GitHub ↗

IPFIX data set decoder

Source from the content-addressed store, hash-verified

515
516
517class IPFIXDecoder:
518 """IPFIX data set decoder"""
519
520 def __init__(self):
521 self._templates = []
522
523 def add_template(self, template):
524 """
525 Add IPFIX template
526
527 :param template: IPFIX template
528 """
529 templateID = template.templateID
530 fields = []
531 rec_len = 0
532 for field in template.templateFields:
533 fields.append({"name": field.informationElement, "len": field.fieldLength})
534 rec_len += field.fieldLength
535 self._templates.append({"id": templateID, "fields": fields, "rec_len": rec_len})
536
537 def decode_data_set(self, data_set):
538 """
539 Decode IPFIX data
540
541 :param data_set: IPFIX data set
542 :returns: List of decoded data records.
543 """
544 data = []
545 for template in self._templates:
546 if template["id"] == data_set.setID:
547 offset = 0
548 d = data_set[Data].data
549 for i in range(len(d) // template["rec_len"]):
550 record = {}
551 for field in template["fields"]:
552 f = d[offset : offset + field["len"]]
553 offset += field["len"]
554 record.update({field["name"]: f})
555 data.append(record)
556 break
557 return data

Callers 15

test_0001Method · 0.90
test_0002Method · 0.90
test_cflow_packetMethod · 0.90
test_flow_entry_reuseMethod · 0.90
test_L2onL2Method · 0.90
test_L3onL2Method · 0.90
test_L234onL2Method · 0.90
test_L4onL2Method · 0.90
test_L2onIP4Method · 0.90
test_L3onIP4Method · 0.90
test_L4onIP4Method · 0.90
test_L2onIP6Method · 0.90

Calls

no outgoing calls

Tested by 15

test_0001Method · 0.72
test_0002Method · 0.72
test_cflow_packetMethod · 0.72
test_flow_entry_reuseMethod · 0.72
test_L2onL2Method · 0.72
test_L3onL2Method · 0.72
test_L234onL2Method · 0.72
test_L4onL2Method · 0.72
test_L2onIP4Method · 0.72
test_L3onIP4Method · 0.72
test_L4onIP4Method · 0.72
test_L2onIP6Method · 0.72