Skip to main content

Module raw_link_layer

Module raw_link_layer 

Source
Expand description

Raw Ethernet link layer for GeoNetworking.

RawLinkLayer opens two pnet datalink channels on the same interface (one for RX, one for TX) and runs each in a dedicated thread.

§Concurrency design

  NIC ──RX──► rx_thread ──Sender<Vec<u8>>──► GeoNetworking router
  NIC ◄─TX──  tx_thread ◄──Receiver<Vec<u8>>── GeoNetworking router

Both threads communicate exclusively through std::sync::mpsc channels — no Arc/Mutex is needed. The pnet library handles all low-level socket access; two separate channel objects are opened because pnet requires a distinct handle per thread.

§Graceful shutdown

Dropping the tx side of the GN→NIC channel causes the TX thread to exit its while let Ok(...) loop naturally. The RX thread polls a stop_flag AtomicBool shared via Arc so it can also be stopped.

§Concurrency correctness

On Linux, AF_PACKET sockets used by pnet are per-open-socket — two sockets on the same interface do not conflict; the kernel delivers received packets to all matching sockets independently.

Structs§

RawLinkLayer
Ethernet link-layer driver for GeoNetworking.