first working
This commit is contained in:
53
frametypes/iena.py
Normal file
53
frametypes/iena.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from typing import Dict, List, Any
|
||||
from scapy.all import Packet
|
||||
|
||||
from .base import FrameTypeInterface
|
||||
|
||||
|
||||
class IENAStats(FrameTypeInterface):
|
||||
"""IENA Protocol Statistics"""
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.name = "IENA"
|
||||
self.count = 0
|
||||
self.bytes = 0
|
||||
self.first_time = None
|
||||
self.last_time = None
|
||||
self.key_fields = set()
|
||||
self.sequence_gaps = 0
|
||||
self.last_sequence = None
|
||||
|
||||
def add(self, timestamp: float, size: int, packet: Packet):
|
||||
self.count += 1
|
||||
self.bytes += size
|
||||
if self.first_time is None:
|
||||
self.first_time = timestamp
|
||||
self.last_time = timestamp
|
||||
|
||||
# Simulate IENA specific processing
|
||||
if packet:
|
||||
# Example: extract IENA key field and sequence
|
||||
# key_field = extract_iena_key(packet)
|
||||
# sequence = extract_iena_sequence(packet)
|
||||
pass
|
||||
|
||||
def get_summary_dict(self) -> Dict[str, Any]:
|
||||
duration = (self.last_time or 0) - (self.first_time or 0)
|
||||
return {
|
||||
'Pkts': self.count,
|
||||
'Bytes': self.bytes,
|
||||
'Duration': round(duration, 3),
|
||||
'Key Fields': len(self.key_fields),
|
||||
'Seq Gaps': self.sequence_gaps,
|
||||
'Pkt/s': round(self.count / duration, 1) if duration > 0 else 0
|
||||
}
|
||||
|
||||
def get_column_definitions(self) -> List[tuple]:
|
||||
return [
|
||||
('Pkts', 'd'),
|
||||
('Bytes', 'd'),
|
||||
('Duration', '.3f'),
|
||||
('Key Fields', 'd'),
|
||||
('Seq Gaps', 'd'),
|
||||
('Pkt/s', '.1f')
|
||||
]
|
||||
Reference in New Issue
Block a user