Several changes to add IPv6 support: - Change structs in pping.h - replace ipv4_flow with network_tuple - rename ts_key to packet_id - rename ts_timestamp to packet_timestamp - Add map_ipv4_to_ipv4 in pping_helpers.h - Also remove obsolete fill_ipv4_flow - Rewrite pping_kern* - parse either IPv4 or IPv6 header (depending on proto) - Use map_ipv4_to_ipv6 to store IPv4 address in network_tuple Support printout of IPv6 addresses in pping.c - Add function format_ip_address as wrapper over inet_ntop - Change handle_rtt_event to first format IP-address strings in local buffers, then perform single printout While some steps have been taken to be more general towards different types of packet identifiers (not just the currently supported TCP timestamps), significant refactorization of pping_kern* will still be required. Also, pping_kern_xdp and pping_kern_tc also have large sections of very similar code that can be refactored into functions. Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
PPing using XDP and TC-BPF
An implementation of the passive ping (pping) utility based on XDP (for ingress) and TC-BPF (for egress)
Simple description
Passive Ping (PPing) makes use of the TCP Timestamp option to calculate the RTT for TCP traffic passing through. PPing can be used on measure RTTs on end hosts or any device which sees both directions of the TCP flow.
For outgoing packets, it checks for TCP timestamp TSval in the TCP header. If it finds one it creates a timestamp for when it saw that TSval in a particular flow. On incomming packets it parses the TCP timestamp TSecr (which is the TSval echoed by the receiving host) and checks it has seen any previous outgoing packets with that TCP timestamp. If it has, an RTT is calculated as the difference in time between when it saw an outgoing packet with a TSval, and when it received an incomming packet from the reverse flow with a matching TSecr.
Note that TCP timestamps may not be unique for every packet in a flow, therefore it only matches the first outgoing packet with a particular TSval with the first incomming packet with a matching TSecr. Duplicate TSval/TSecr are ignored.