L2

Within the Bristlemouth stack, the L2 layer is responsible for monitoring how the upper layers of the IP stack interact with the 10BASE-T1L ethernet driver. The code itself interacts and follows the below diagram:

../_images/l2.png

Responsibilities

The L2 layer is the glue between the network layer of the IP stack and the network device (AKA the 10BASE-T1L ethernet driver). It controls the flow of data to and from each of those layers. The following is an in-depth explanation of how each of its responsibilities work:

  • Receive Events

    • The network device will receive a packet and pass the raw data to bm_l2_rx

    • Then creates a new buffer through the IP stack abstraction and copies the raw data from the packet to this buffer,

    • Following, it then queues up this data to be handled in the bm_l2_thread

    • During handling, if the packet is a multicast packet (a packet that is sent to a group of interested receivers), it is transmitted down the wire to other nodes

    • The packet is then submitted to the upper layers of the IP stack with bm_l2_submit, so that it may processed

  • Transmit Events

    • Transmission messages are sent through the IP stack from upper layers, and are then fed through bm_l2_link_output

    • bm_l2_link_output then preps the message, utilizing the bm_l2_prep function, and sends it to a queue which is handled in the bm_l2_thread

    • When processed, the message is then sent to the network device to be transmitted on the line

  • Link Up/Down Events

    • During initialization, a callback is passed into the network device as a trait in order to handle when the link to a port has been dropped or opened

    • When a link is brought up or down, an event is queued up to be handled in the bm_l2_thread, which has the port associated with the event and whether or not the link is up or down

    • When handled, a variable is set to report to outside modules whether or not the port is up or down (utilizing bm_l2_get_port_state), and a callback is invoked to report to other concerned parties about the state of the port