A colleague of mine was recently discussing a connectivity monitoring system he is working on with me. It’s nothing fancy, just sending ICMP Echo Requests to a couple of different servers, and monitoring latency and dropped packet averages over 1-minute, 5-minute, and 15-minute periods. Up came the topic of how this data should be stored, the natural thought was a 512 entry ring buffer, containing entries like the following: struct ping_timestamp { uint64_t sent_ns; // when the packed was sent (unit: ns) uint64_t received_ns; // when the packet was received (unit: ns) in_addr_t source_addr; // source address uint16_t seq_no; // echo request sequence number bool received; // has the request been received? }; And backed by the following array struct ping_timestamp pings_rb[512]; //…
Premature Optimization is Fun Sometimes
Advertisement