Link/Data Link Layer

This layer concerns itself with identifying the device to which we want to send the data to. The devices are any tangible devices found on the physical network such as computers, switches, and routers.

This layer works like an interface between the physical layer and the logical layer above it.

The most commonly used and most famous protocol on this layer is the Ethernet protocol, governed by the IEEE standards.

Ethernet works using concepts called framing and addressing. We will review both.

Ethernet Frames

Ethernet Frames are a Protocol Data Unit (see #Networking Models) which encapsulate data from the Internet/Network layer above.

The Link/Data Link layer is the lowest layer at which encapsulation takes place.

On the physical layer, the data is a stream of bits without logical structure. An Ethernet Frame adds this missing structure to this binary data. The structure defines which bits are data payload and which are metadata (header or trailer/footer).

The purpose of the Layer 2 header is to get the data from hop to hop.

Ethernet-compliant device can identify the different parts of a frame because each “fields” of data have a specific lengths in bytes, and appear in an order. The frame described below follows the IEEE 802.3 Ethernet standard.

+---------------+----------+--------+------+------+---------+--------+-----+
|               |          |        |      |      |         |        |     |
|  Destination  |  Source  |        |      |      |         |        |     |
|      MAC      |   MAC    | Length | DSAP | SSAP | Control |  Data  | FCS |
|  Destination  |  Source  |        |      |      |         |        |     |
|               |          |        |      |      |         |        |     |
+---------------+----------+--------+------+------+---------+--------+-----+
 ^                                                         ^ ^      ^ ^   ^
 |                                                         | |      | |   |
  \__________________________+____________________________/   \____/   \_/
                             |                                  |       |
                        Frame header                       Data Payload |
                                                                        |
                                                            Frame footer/trailer

Note that the fields length are not at scale. Destination, Source and Data are normaly longer than the other field.

Here is a rundown of all the field:

  • Preamble and Start of Frame Delimiter (SFD): Not actual part of the frame but sent prior to the frame to let the receiving device to exoect frane comming next.
  • Source and Destination MAC address: Six bytes (48 bits) long fields each containing respectively the MAC address of the device that created the frame (can vary depending on where the data travels) and the MAC address of the device the data is ultimately intended. See MAC Addresses#.
  • Length: Two bytes (16 bits) length to indicate the size of the Data Payload
  • DSAP, SSAP, Control: One byte (8 bits) length each, used to identify the Network Protocol used for the Data Payload and additional information about the communication mode for the frame.
  • Data Payload: Between 42 and 1497 bytes in length, contains the data for the PDU from the layer above.
  • Frame Check Sequence (FCS): The final four bytes (32 bits) is a checksum generated by the device which created the frame. It is used by the receiving end to check if even one bit of the frame data was modified/lost along the way. If the check don’t match, the frame is dropped. Note that Ethernet doesn’t implement a retransmission functionality for dropped frames. This is the responsability of higher level protocols to manage retransmission (if this is even a requirement of the protocol).
  • Interframe Gap (IFG): Like the Preamble/SFD, this is not part of the frame. This is a brief pause between each frame transmission to let the receiver prepare for the next frame. The length varies according to the capability of the Ethernet connection but it contributes to the delay (latency, see Physical Network)

Developer should mainly concern themselves with Source and Destination MAC address being used to direct the frame between network devices and Data Payload being used as an encapsulation mechanism for the layer above.