fragment_packet

Function fragment_packet 

Source
pub fn fragment_packet(packet: &[u8], mtu: usize, base_seq: u64) -> Vec<Bytes>
Expand description

Fragment a network-layer packet into NDNLPv2 LpPacket fragments.

Each fragment is an independently-decodable LpPacket containing:

  • Sequence = base_seq (same for all fragments of one packet)
  • FragIndex = 0-based index
  • FragCount = total number of fragments
  • Fragment = the chunk of the original packet

If the packet fits in a single fragment, a single LpPacket is returned (still carrying the fragmentation fields, as required by NDNLPv2 when the sender uses fragmentation).

ยงPanics

Panics if mtu is too small to fit even the fragmentation overhead.