first working

This commit is contained in:
2025-08-03 20:20:55 -04:00
commit cde56494ec
52 changed files with 1893 additions and 0 deletions

52
frametypes/ch10_time.py Normal file
View File

@@ -0,0 +1,52 @@
from typing import Dict, List, Any
from scapy.all import Packet
from .base import FrameTypeInterface
class Ch10TimeStats(FrameTypeInterface):
"""Chapter 10 Time Data Statistics"""
def __init__(self):
super().__init__()
self.name = "Chapter 10 Time"
self.count = 0
self.bytes = 0
self.first_time = None
self.last_time = None
self.time_sources = set()
self.time_format_changes = 0
self.leap_second_events = 0
self.time_discontinuities = 0
self.max_time_delta = 0
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
# In real implementation, decode time packets
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,
'Time Sources': len(self.time_sources),
'Format Changes': self.time_format_changes,
'Leap Seconds': self.leap_second_events,
'Discontinuities': self.time_discontinuities,
'Max Delta': round(self.max_time_delta, 6)
}
def get_column_definitions(self) -> List[tuple]:
return [
('Pkts', 'd'),
('Bytes', 'd'),
('Time Sources', 'd'),
('Format Changes', 'd'),
('Leap Seconds', 'd'),
('Discontinuities', 'd'),
('Max Delta', '.6f')
]