#flow #hashing #networking #ids

communityid

A practical implementation of the Community ID standard for network flow hashing

3 releases

0.1.2 Sep 24, 2024
0.1.1 Sep 23, 2024
0.1.0 Sep 23, 2024

#781 in Network programming

Download history 401/week @ 2024-09-22 37/week @ 2024-09-29 28/week @ 2024-10-06 40/week @ 2024-10-13 15/week @ 2024-10-20 2/week @ 2024-10-27 34/week @ 2024-11-03 10/week @ 2024-11-10

62 downloads per month

GPL-3.0 license

21KB
420 lines

Crates.io Version docs.rs GitHub Actions Workflow Status Crates.io MSRV

This crate provides a practical implementation of the Community ID standard for network flow hashing.

Features

  • serde: when enabled implements serde::Serialize and serde::Deserialize traits

Example

use communityid::{Protocol, Flow};
use std::net::Ipv4Addr;

let f = Flow::new(Protocol::UDP, Ipv4Addr::new(192,168,1,42).into(), 4242, Ipv4Addr::new(8,8,8,8).into(), 53);
let f2 = Flow::new(Protocol::UDP,  Ipv4Addr::new(8,8,8,8).into(), 53, Ipv4Addr::new(192,168,1,42).into(), 4242);

// community-id can be base64 encoded
assert_eq!(f.community_id_v1(0).base64(), "1:vTdrngJjlP5eZ9mw9JtnKyn99KM=");

// community-id can be hex encoded
assert_eq!(f2.community_id_v1(0).hexdigest(), "1:bd376b9e026394fe5e67d9b0f49b672b29fdf4a3");

// we can test equality between two community-ids
assert_eq!(f.community_id_v1(0), f2.community_id_v1(0));

Dependencies

~530–790KB
~17K SLoC