{'fraction_non_alphanumeric': 0.02127659574468085, 'fraction_numerical': 0.0009671179883945841, 'mean_word_length': 5.124260355029586, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
SWAP: a sliding window algorithm for in-network packet measurement

Network traffic measurement is a fundamental part of many network applications, such as DDOS detection, capacity planning, and quality-of-service improvement. To achieve this, we need to count the number of packets passed during a past time interval. Traditionally, switches sample the packets and send them to the CPU for analysis. It is unavoidable that the sampling will sacrifice the measuring accuracy. Nowadays, programmable switches can keep the counters in the data plane. However, they still rely on the CPU to drain and clear the records periodically, which brings in too much communication latency. To overcome these disadvantages, we propose a metering mechanism under the RMT architectural model called SWAP. SWAP is carefully designed to count the number of packets during an interval accurately with little hardware resource usage. We prototype it using P4 and simulation results show SWAP achieves high efficiency and moderate accuracy at line speed.