nethash module

The nethash module is part of the nmeta suite

It provides functions for hashing packets and flows to unique identifiers

nethash.hash_flow(flow_5_tuple)

Generate a predictable flow_hash for the 5-tuple. For TCP the hash is the same no matter which direction the traffic is travelling for all packets that are part of that flow.

Pass this function a 5-tuple.

For TCP, this tuple should be: (ip_src, ip_dst, tp_src, tp_dst, ip_proto)

For other IP packets, the tuple should be: (eth_src, eth_dst, dpid, packet_timestamp, ip_proto)

For non-IP packets, the tuple should be: (eth_src, eth_dst, dpid, packet_timestamp, 0)

nethash.hash_packet(packet)

Generate a hash of flows packet object for use in deduplication where the same packet is received from multiple switches.

Retransmissions of a packet that is part of a flow should have same hash value, so that retransmissions can be measured.

The packet hash is a unique unidirectional packet identifier

For TCP packets, the hash is derived from:
ip_src, ip_dst, proto, tp_src, tp_dst, tp_seq_src, tp_seq_dst
For non-flow packets, the hash is derived from:
eth_src, eth_dst, eth_type, dpid, timestamp
nethash.hash_tuple(hash_tuple)

Simple function to hash a tuple with MD5. Returns a hash value for the tuple