working to analyze timing issues
This commit is contained in:
8
analyzer/models/__init__.py
Normal file
8
analyzer/models/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
"""
|
||||
Data models for the Ethernet Traffic Analyzer
|
||||
"""
|
||||
|
||||
from .flow_stats import FlowStats, FrameTypeStats
|
||||
from .analysis_results import AnalysisResult
|
||||
|
||||
__all__ = ['FlowStats', 'FrameTypeStats', 'AnalysisResult']
|
||||
45
analyzer/models/analysis_results.py
Normal file
45
analyzer/models/analysis_results.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""
|
||||
Analysis result containers and summary structures
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Dict, Any, List, Set
|
||||
from .flow_stats import FlowStats
|
||||
|
||||
|
||||
@dataclass
|
||||
class AnalysisResult:
|
||||
"""Container for complete analysis results"""
|
||||
total_packets: int
|
||||
unique_flows: int
|
||||
unique_ips: int
|
||||
flows: Dict[tuple, FlowStats]
|
||||
|
||||
def get_summary(self) -> Dict[str, Any]:
|
||||
"""Get analysis summary dictionary"""
|
||||
unique_ips = set()
|
||||
for flow in self.flows.values():
|
||||
unique_ips.add(flow.src_ip)
|
||||
unique_ips.add(flow.dst_ip)
|
||||
|
||||
return {
|
||||
'total_packets': self.total_packets,
|
||||
'unique_flows': len(self.flows),
|
||||
'unique_ips': len(unique_ips),
|
||||
'flows': self.flows
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class DissectionResult:
|
||||
"""Container for packet dissection results"""
|
||||
frame_number: int
|
||||
timestamp: float
|
||||
size: int
|
||||
layers: Dict[str, Any]
|
||||
protocols: List[str]
|
||||
errors: List[str] = None
|
||||
|
||||
def __post_init__(self):
|
||||
if self.errors is None:
|
||||
self.errors = []
|
||||
40
analyzer/models/flow_stats.py
Normal file
40
analyzer/models/flow_stats.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
Data structures for flow and frame type statistics
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, List, Set, Tuple
|
||||
|
||||
|
||||
@dataclass
|
||||
class FrameTypeStats:
|
||||
"""Statistics for a specific frame type within a flow"""
|
||||
frame_type: str
|
||||
count: int = 0
|
||||
total_bytes: int = 0
|
||||
timestamps: List[float] = field(default_factory=list)
|
||||
frame_numbers: List[int] = field(default_factory=list)
|
||||
inter_arrival_times: List[float] = field(default_factory=list)
|
||||
avg_inter_arrival: float = 0.0
|
||||
std_inter_arrival: float = 0.0
|
||||
outlier_frames: List[int] = field(default_factory=list)
|
||||
outlier_details: List[Tuple[int, float]] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass
|
||||
class FlowStats:
|
||||
"""Statistics for a source-destination IP pair"""
|
||||
src_ip: str
|
||||
dst_ip: str
|
||||
frame_count: int
|
||||
timestamps: List[float]
|
||||
frame_numbers: List[int]
|
||||
inter_arrival_times: List[float]
|
||||
avg_inter_arrival: float
|
||||
std_inter_arrival: float
|
||||
outlier_frames: List[int]
|
||||
outlier_details: List[Tuple[int, float]] # (frame_number, time_delta)
|
||||
total_bytes: int
|
||||
protocols: Set[str]
|
||||
detected_protocol_types: Set[str] # Enhanced protocol detection (CH10, PTP, IENA, etc)
|
||||
frame_types: Dict[str, FrameTypeStats] = field(default_factory=dict) # Per-frame-type statistics
|
||||
Reference in New Issue
Block a user