NEWSLabNTU / ddshark

A live monitoring tool for RTPS protocol.
MIT License
2 stars 2 forks source link

Implement IP fragments reassembler in `rtps.rs` #8

Open st9540808 opened 1 year ago

st9540808 commented 1 year ago

I just write an IP fragments reassembler to assemble fragmented DATA or DATA_FRAG submessage. I will make a PR after the last PR is merged.

The PacketDecoder will have the definition below:

struct PacketDecoder {
    /// Map of (source, destination, id) to (fragment offset, payload)
    fragments: HashMap<(Ipv4Addr, Ipv4Addr, u16), BTreeMap<u16, Vec<u8>>>,
    /// Map of (source, destination, id) to (total received length, total length)
    assemblers: HashMap<(Ipv4Addr, Ipv4Addr, u16), (usize, usize)>,
}

The id in the map key corresponds to the identification field of IP header.

This field is an identification field and is primarily used for uniquely identifying the group of fragments of a single IP datagram. https://en.wikipedia.org/wiki/Internet_Protocol_version_4#Identification

st9540808 commented 1 year ago

Related PR at #9

st9540808 commented 1 year ago

Here are some test files that I used for testing reassembler.

  1. autoware_logging_cropped_frag.pcap: In-order fragments, containing two DATA_FRAG
  2. autoware_logging_cropped_frag_oo.pcap: Out-of-order fragments, containing two DATA_FRAG

autoware_logging_cropped_frag.zip