-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpacket_monitoring.h
More file actions
41 lines (33 loc) · 965 Bytes
/
packet_monitoring.h
File metadata and controls
41 lines (33 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#include <chrono>
#include <cstdint>
#include <iostream>
#include <string>
class PacketMonitor {
public:
PacketMonitor();
void start_monitoring();
void print_stats();
bool process_packet(uint16_t seq_number, size_t bytes_read);
private:
// Packet tracking
uint64_t packet_count_;
uint16_t last_seq_number_;
uint64_t dropped_packets_;
uint64_t out_of_order_packets_;
// Timing metrics
std::chrono::steady_clock::time_point start_time_;
std::chrono::steady_clock::time_point first_packet_time_;
std::chrono::steady_clock::time_point last_packet_time_;
std::chrono::steady_clock::time_point last_stats_time_;
// Bandwidth tracking
uint64_t bytes_received_;
uint64_t bytes_received_in_interval_;
std::chrono::steady_clock::time_point last_bandwidth_time_;
// Jitter tracking
double last_jitter_;
double avg_jitter_;
// Helper methods
void clear_line() const;
std::string format_stats() const;
};