Featured image

Table of Contents Link to heading

Tip
A node refers to a device communicating at this layer.

OSI Data Link Layer Link to heading

For packets to be transported from source host to destination host, they must traverse different physical networks (e.g., copper wires, microwaves, optical fibers, and satellite links), but network layer packets do not have a way to directly access these different media.

Info
The OSI data link layer prepares network layer packets for placement onto the physical media that transports data.
Tip
  1. Allow the upper layers to access the media using techniques such as framing
  2. Control how data is placed onto the media and is received from the media using techniques such as MAC and error detection

In any given exchange of network layer packets, there can be numerous data link layer and media transitions. At each hop along the path, an intermediary device, usually a router, processes the frame as follows:

  1. Accept the frame from a medium
  2. Decapsulate the frame into a packet
  3. Construct a new frame appropriate for the next media
  4. Forward the packet inside the new frame across the next segment of the physical network

At each hop, the received frame is also examined for errors. If an error is found in a received frame, the frame is discarded. If the frame is good, the data link layer directs the packet to an upper-layer protocol, in this case IPv4 or IPv6.

Perspectives of Other Layers Link to heading

The data link layer prepares communication for the media. The functions of the upper layers of the node are not aware what media the communication will use or over how many different media the communication can travel.

Data Link Sublayers Link to heading

To support a wide variety of network functions, the data link layer is divided into two sublayers:

  1. Logical Link Control (LLC): upper sublayer
  2. Media Access Control (MAC): lower sublayer

Logical Link Control (LLC) Sublayer Link to heading

Info
The LLC sublayer places information in the frame to identify which net IPv6, and IPX, work layer protocol is being used for the frame, allowing multiple L3 protocols to utilise the same network interface and media.

Ethernet Network Interface Cards (NICs) Link to heading

Note
Read more at ๐Ÿ”—.

In a computer, the LLC can be considered the driver software for the NIC.

The NIC driver is a program that interacts directly with the hardware on the NIC to enable the NIC to perform intermediary functions of preparing data for transmission and encoding the data as signals to be sent on the associated media.

Media Access Control (MAC) Sublayer Link to heading

Info
The MAC sublayer is responsible for data encapsulation and media access control.

Encapsulating Packets into Frames Link to heading

Info
Encapsulation, or framing, is the process of adding a header and a trailer to a network layer packet to form a frame that can be transmitted over the physical layer (according to the physical signalling requirements of the medium and the type of L2 protocol in use).

When packets have been encapsulated at the data link layer, they are referred to as frames.

Each L2 protocol uniquely describes what control information is required and how that information is included in the encapsulation.

Framing Link to heading

Info

Three basic elements of a frame:

  1. Data - the packet from the network layer
  2. Header - the control information, such as source/destination MAC addressing and frame type/length, located at the beginning of the PDU
  3. Trailer - the control information, such as a checksum/CRC, added to the end of the PDU

Minimum Frame Size Link to heading

Info
The minimum frame size is 64 bytes. Different network technologies have different maximum frame sizes (or MTU). For example, the original Ethernet has an MTU of 1518 byte, whereas the IEEE 802.3ac standadrd has an MTU of 1522 bytes.

Any frame less than 64 bytes in length is considered a collision fragment or runt frame, while any frame more than 1500 in length is considered a jumbo frame or baby giant frame.

If the frame size is less than 64 bytes, the receiving device automatically drops the frame.

Jumbo frames are supported by most Fast Ethernet and Gigabit Ethernet switches and NICs. However, if a receiving device does not support jumbo frames, it may discard the frame as invalid or oversized, or attempt to fragment it into smaller frames, which can result in data loss, errors, or reduced performance.

Role of Header Link to heading

Info
The frame header contains the control information specified by the L2 protocol for the specific logical topology and media used.
Header Field NameDescription
Start of FrameIndicates the beginning of the frame
Source and Destination addressIndicate the source and destination nodes on the media
Priority/Quality of ServiceIndicates a particular type of communication service for processing
TypeIndicates the upper-layer service contained in the frame
Logical connection controlUsed to establish a logical connection between nodes
Physical link controlUsed to establish the media link
Flow controlUsed to start and stop traffic over the media
Congestion controlIndicates congestion in the media

Different L2 protocols can use different field names from those mentioned.

Role of Trailer Link to heading

Info
The frame trailer contains the control information specified by the L2 protocol to allow for error detection, which determines whether the frame arrived without error.
Trailer Field NameDescription
Frame Check Sequence (FCS)Used for error checking of the frame contents
End of FrameUsed to indicate the end of the frame
Also, can be used to increase the size of a frame to an expected fixed size or minimum size.
Error Detection Link to heading
Info
Error detection (not error correction) is accomplished by placing a logical or mathematical summary of the bits that comprise the frame in the trailer.

Error detection is added at L2 because this is where data is transferred across the media which is a potentially unsafe environment for data. The signals on the media is susceptible to interference, distortion, or loss that would change the bit values that those signals represent.

Tip
The transmitting node places a checksum or cyclic redundancy check (CRC) value, a logical summary of the contents of the frame, in the FCS field of the frame.

When the frame arrives at the destination node, the receiving node calculates its own CRC of the frame. The receiving node compares the two CRC values. If the two values are the same, the frame is considered to have arrived as it was transmitted. If the CRC value in the FCS differs from the CRC calculated at the receiving node, the frame is discarded.

Some L2 protocols, such as HDLC or PPP, also use acknowledgement and retransmission to ensure reliable delivery of frames.

Info
A set of rules that defines how devices communicate and exchange data over a network medium, including the format and structure of the frames that carry the data, as well as the methods to encode and decode the frames into signals that can be transmitted over the physical layer.

Which L2 protocol is used depends on the logical topology of the network and the implementation of the physical layer.

Given the wide range of physical media used across the range of topologies in networking, there are a correspondingly high number of L2 protocols in use.

A number of different network devices can act as nodes that operate at L2 when implementing these protocols, including NICs on computers as well as the interfaces on routers and L2 switches.

Ethernet Protocol for LANs Link to heading

Info
Ethernet provides unacknowledged connectionless service over a shared media using CSMA/CD as the media access method.

Ethernet standards define both the L2 protocols and the L1 technologies.

Ethernet is the most widely used LAN technology and supports data bandwidths of 10, 100, 1000, or 10,000 Mbps.

There are two styles of Ethernet framing: IEEE 802.3 (original) and the revised IEEE 802.3 (the addition of a Start Frame Delimiter (SFD) field and a small change to the Type field to include the Length).

  1. The original Ethernet standard defined the minimum frame size as 64 bytes and the maximum as 1518 bytes. This includes all bytes from the Destination MAC Address field through the Frame Check Sequence (FCS) field. The Preamble and Start Frame Delimiter fields are not included when describing the size of a frame.
  2. The IEEE 802.3ac standard extended the maximum allowable frame size to 1522 bytes. The frame size increased to accommodate a technology used in switched networks called virtual local-area network (VLAN)
Preamble (7 bytes) and Start Frame Delimiter (SFD) (1 byte) Link to heading
Info
used to time synchronisation and contains a delimiter to mark the end of the timing information.

These first 8 bytes of the frame get the attention of the receiving nodes. Essentially, the first few bytes tell the receivers to get ready to receive a new frame.

Destination MAC Address (6 bytes) Link to heading
Info
the identifier for the destination node.

This L2 address assists devices in determining whether a frame is intended for them. The device compares its MAC address to this address in the frame. If there is a match, the device accepts the frame.

Switches also use this address to determine out which interface to forward the frame.

Source MAC Address (6 bytes) Link to heading
Info
identifies the source NIC or interface of the frame.

Switches also use this address to add to entries in their lookup tables.

Length/Type (2 bytes) Link to heading
Info
defines the exact length of the data field of the frame and indicates which upper-layer protocol will receive the data after the Ethernet process is complete.

This is used later as part of the CRC process to ensure that the message was received properly. This can be either a length or a type value. However, only one or the other can be used in a given implementation.

Once receiving a frame, the receiving node must examine the Length/Type field to determine which upper-layer protocol is present. If the two-octet value is equal to or greater than 0x0600 hexadecimal or 1536 decimal, the contents of the Data field are decoded according to the protocol indicated.

Data and Pad (46โ€“1500 bytes) Link to heading
Info
contain the encapsulated data from a higher layer (L3 PDU) that is to be transported over the media.

All frames must be at least 64 bytes long. If the encapsulated packet is small, the Pad increases the size of the frame to this minimum size.

Frame Check Sequence (FCS) (4 bytes) Link to heading
Info
used to check for damaged frames.

It uses a CRC. The sending device includes the results of a CRC in the FCS field of the frame. The receiving device receives the frame and generates a CRC from the frame contents. If the calculations match, no error has occurred. Calculations that do not match are an indication that the data has changed. Therefore, the frame is dropped. A change in the data could be the result of a disruption of the electrical signals that represent the bits.

Point-to-Point Protocol (PPP) for WANs Link to heading

Info
PPP is used to deliver frames between two nodes, such as in router-to-router and host-to-network connections.

PPP can be used on various physical media, including twisted-pair cable, fibre-optic lines, and satellite transmission, as well as for virtual connections.

PP uses a layered architecture. To accommodate the different types of media, PPP establishes logical connections, called sessions, between two nodes. The PPP session hides the underlying physical media from the upper-layer protocol. These sessions also provide PPP with a method for encapsulating multiple upper-layer protocols over a point-to-point link. Each protocol encapsulated over the link establishes its own PPP session.

A PPP frame contains the following fields:

  1. Flag: A single byte that indicates the beginning or end of a frame. The flag field consists of the binary sequence 01111110.
  2. Address: A single byte that contains the standard PPP broadcast address. PPP does not assign individual station addresses.
  3. Control: A single byte that contains the binary sequence 00000011, which calls for transmission of user data in an unsequenced frame.
  4. Protocol: Two bytes that identify the protocol encapsulated in the data field of the frame. The most up-to-date values of the protocol field are specified in the most recent Assigned Numbers RFC.
  5. Data: Zero or more bytes that contain the datagram for the protocol specified in the protocol field.
  6. FCS: Normally 16 bits (2 bytes). By prior agreement, consenting PPP implementations can use a 32-bit (4-byte) FCS for improved error detection.

Wireless Protocol (Wi-Fi) for LANs Link to heading

Info
Wi-Fi provides an acknowledged, contention-based system using a CSMA/CA media access process.

A 802.11 frame contains the following fields:

  1. Protocol Version: Version of 802.11 frame in use
  2. Type and Subtype: Identifies one of three functions and subfunctions of the frame: control, data, and management
  3. To DS: Set to 1 in data frames destined for the distribution system (devices in the wireless structure)
  4. From DS: Set to 1 in data frames exiting the distribution system
  5. More Fragments: Set to 1 for frames that have another fragment
  6. Retry: Set to 1 if the frame is a retransmission of an earlier frame
  7. Power Management: Set to 1 to indicate that a node will be in power-save mode
  8. More Data: Set to 1 to indicate to a node in power-save mode that more frames are buffered for that node
  9. Wired Equivalent Privacy (WEP): Set to 1 if the frame contains WEP-encrypted information for security
  10. Order: Set to 1 in a data type frame that uses Strictly Ordered service class (does not need reordering)
  11. Duration/ID: Depending on the type of frame, represents either the time, in microseconds, required to transmit the frame or an association identity (AID) for the station that transmitted the frame
  12. Destination Address (DA): MAC address of the final destination node in the network
  13. Source Address (SA): MAC address of the node that initiated the frame
  14. Receiver Address (RA): MAC address that identifies the wireless device that is the immediate recipient of the frame
  15. Transmitter Address (TA): MAC address that identifies the wireless device that transmitted the frame
  16. Sequence Number: Indicates the sequence number assigned to the frame; retransmitted frames are identified by duplicate sequence numbers
  17. Fragment Number: Indicates the number for each fragment of a frame
  18. Frame Body: Contains the information being transported; for data frames, typically an IP packet
  19. FCS: Contains a 32-bit cyclic redundancy check (CRC) of the frame

Other Protocols Link to heading

High-level Data Link Control (HDLC) is used in point-to-multipoint connections and most commonly used in point-to-point serial communications.

Frame Relay is used in nonbroadcast multiaccess (NBMA) networks, such as WAN-connected sites.

ATM is the international standard for cell relay in which devices send multiple service types, such as voice, video, or data, in fixed-length.

Placing Frames onto the Media Link to heading

IEEE 802.3 MAC sublayer includes the specifications for different Ethernet communications standards over various types of media.

Transferring Frames across Local Media Link to heading

At intermediary devices, such as routers, where the media type could change for each connected network, different physical interfaces encapsulate the packet into the appropriate frame and a suitable MAC method is used to access each link.

For example, a router has an Ethernet interface to connect to the LAN and a serial interface to connect to the WAN, the router processes the frame as follows:

  1. Use an Ethernet-supported data link layer protocol to receive the frame from one medium.
  2. Decapsulate the frame into a packet.
  3. Re-encapsulate the packet into a new frame supported by the protocol used in the WAN.
  4. Place the new frame onto the medium of the next link of the network.

MAC Method Link to heading

Info
A MAC method regulates the placement of frames onto the media by defining whether and how the nodes share the media.

The MAC method used depends on:

  1. Media sharing: If and how the nodes share the media
  2. Topology: How the connection between the nodes appears to the data link layer

Media Sharing Link to heading

MAC for Shared Media (Multiaccess Networks) Link to heading
Info
A multiaccess network is a network that allows more than two nodes to communicate and share data over a common medium (e.g., a cable, a wireless channel, or a switched fabric).

Some examples of multiaccess networks are Ethernet, WiFi, Frame Relay, and ATM.

A multiaccess network requires a MAC method to coordinate the access and avoid collisions or interference among the devices.

The two basic MAC methods for shared media are as follows:

  1. Controlled: Each node has its own time to use the medium.
  2. Contention-based: All nodes compete for the use of the medium.
Controlled Access (Deterministic Method) Link to heading
Info
When one device is placing a frame on the media, all other devices must remain idle until the frame has arrived and has been processed by the destination.

Examples: Token Ring and Fibre Distributed Data Interface (FDDI) networks.

A controlled access method provides predictable throughput and prevents collisions, but it can be inefficient because a device has to wait for its turn before it can use the medium.

Contention-Based Access (Nondeterministic Method) Link to heading
Info
A contention-based access method uses a carrier sense multiple access (CSMA) process to first detect whether the media is carrying a signal. If a carrier signal on the media from another node is detected, it means that another device is transmitting. When the device attempting to transmit sees that the media is busy, it will wait and try again after a short time period. If no carrier signal is detected, the device transmits its data.

Examples: legacy Ethernet and WLANs.

However, it is possible that the CSMA process will fail and two devices will transmit at the same time, resulting in a collision where the data sent by both devices will be corrupted and will need to be resent.

Unlike controlled access methods, a mechanism for tracking whose turn it is to access the media is not required, hence less overhead.

However, the contention-based systems do not scale well under heavy media use. The higher the use and the number of nodes, the higher the probability of a collision occurs, resulting in diminished throughput.

CSMA is usually implemented in conjunction with a mechanism for resolving the media contention.

Info
CSMA collision detect (CSMA/CD) - the device monitors the media for the presence of a data signal.

If a data signal is absent, indicating that the media is free, the device transmits the data. If signals are then detected that show another device was transmitting at the same time, all devices stop sending and try again later.

This method is used in Ethernet networks.

There are three steps in the CSMA/CD process:

  1. Listen before sending
    • A device with a frame to send must listen before transmitting the frame. If a device detects a signal from another device, it will wait for a specified amount of time before attempting to transmit.
    • If the device does not detect any signal, it will transmit its frame.
  2. Detect a collision
    • If a device does not detect the signal from a second device, the first device can also start to transmit. The media now has two devices transmitting their signals at the same time, creating a collision on the shared media.
    • Their messages will propagate across the media until they encounter each other. At that point, the signals mix, a collision occurs, and the message is destroyed.
    • Although the messages are corrupted, the jumble of remaining signals continues to propagate across the media. While this transmission is occurring, the device continues to listen to the media to determine whether a collision occurs.
    • If the frame is sent without a collision being detected, the device returns to its listening mode.
  3. Jam signal and random backoff
    • When a collision occurs, the transmitting devices that detect the collision will continue to transmit a 32-bit jam signal for a specific period to notify all devices on the network of a collision.
      • Being 32-bit in length ensures that a jam signal is not detected as a valid frame; otherwise, the collision would not be identified.
    • The device receiving the jam signal will invoke a random backoff timer that stop itself from transmitting for a random amount of time, which allows the collision signals to subside and the media to stabilise.
    • After the frame has been sent without collision or the backoff delay has expired on a device, the device goes back into the “listen before sending” mode.
Info
CSMA collision avoid (CSMA/CA) - the device examines the media for the presence of a data signal.

If the media is free, the device sends a notification across the media of its intent to use it. The device then sends the data.

This method is used in wireless networks.

MAC for Nonshared Media (Point-to-Point Networks) Link to heading
Info
A point-to-point network is a type of network that connects two nodes directly over a network medium (e.g., a cable, a wireless channel, or a switched fabric).

Since the nodes do not share the media with anyone or determine whether a frame is destined for that node, there is little or no control before placing frames onto the media.

In point-to-point connections, the data link layer has to consider whether the communication is half duplex or full duplex.

Half-Duplex Communication Link to heading
Info
There is a single, shared medium to transmit data and thus only one device can transmit or receive data at a time, and the other devices must wait until the shared channel is available.

Legacy Ethernet uses hubs operated in a physical star topology and a logical bus topology over a shared, half-duplex medium. Half-duplex communication requires access control through CSMA/CD to detect collisions and thus ensure that only one device is transmitting at a time.

  1. Timing and Synchronisation
    • If a collision has not occurred, the sending device will transmit 64 bits of timing synchronisation information, which is known as the Preamble. The sending device will then transmit the complete frame.
  2. Slot Time
    • Slot time for a network is the maximum time required to detect a collision. This is equal to twice the time it takes a signal to travel between the two most-distant stations on the network.
    • This ensures that all devices start to receive a frame before the transmitting NIC has finished sending it.
    • Slot time is used to establish the following:
      • The minimum size of an Ethernet frame
      • A limit on the maximum size of a network’s segment
Full-Duplex Communication Link to heading
Info
There are two media, each dedicated to one direction, and thus two devices can transmit and receive data simultaneously.
Duplex Mismatch Link to heading
Note
Read more at ๐Ÿ”—.

Current Ethernet uses switches operated in a physical star topology and a logical point-to-point topology over a full-duplex medium. Full-duplex communication with Ethernet switches does not require access control through CSMA/CD.

Topology Link to heading

Info
The topology of a network is the arrangement or relationship of the network devices and the interconnections between them.
Bus Topology Link to heading
Info
All end systems are chained to each other and terminated in some form on each end. Infrastructure devices such as switches are not required to interconnect the end devices. Bus topologies using coax cables were used in legacy Ethernet networks because it was inexpensive and easy to set up.

In a bus topology, where all devices are connected to a single cable, the MAC method needs to prevent collisions and handle contention among the devices.

A common MAC method for bus networks is CSMA/CD, which allows devices to sense the medium before transmitting and to stop and retry if a collision occurs.

Ring Topology Link to heading
Info
End systems are connected to their respective neighbour forming a ring. Unlike the bus topology, the ring does not need to be terminated. Ring topologies were used in legacy FDDI and Token Ring networks.

In a ring topology, where all devices are connected in a loop, the MAC method needs to ensure that each device gets a fair chance to transmit and to avoid deadlock.

A common MAC method for ring networks is token passing, which involves passing a special message called a token around the ring. Only the device that has the token can transmit, and it must release the token after a certain time.

Star Topology Link to heading
Info
End devices are connected to a central intermediate device (hubs/switches). The star topology is easy to install, very scalable (easy to add and remove end devices), and easy to troubleshoot.

In a star topology, where all devices are connected to a central device, such as a hub or a switch, the MAC method needs to manage the traffic and congestion at the central device.

A common MAC method for star networks is polling, which involves the central device asking each device in turn if it has data to send. This method avoids collisions and ensures that each device gets a turn, but it can be inefficient and slow.

Mesh Topology Link to heading
Info
The mesh topology provides high availability, but requires that every end system be interconnected to every other system. Therefore, the administrative and physical costs can be significant. Each link is essentially a point-to-point link to the other node.

In a mesh topology, where each device is connected to every other device, the MAC method needs to coordinate the transmissions and avoid interference among the devices.

A common MAC method for mesh networks is TDMA (time division multiple access). This method divides the medium into time slots and assigns each device a slot to transmit. This method avoids collisions and ensures high bandwidth, but it requires synchronisation and scheduling.

Point-to-Point and Hub-and-Spoke Topology Link to heading

For point-to-point and hub-and-spoke topologies, the MAC method is usually simpler and more efficient than for other topologies. This is because point-to-point and hub-and-spoke topologies have less contention and collision issues, as each device has a dedicated link to another device or to a central hub. Therefore, the MAC method does not need to implement complex mechanisms to avoid or resolve collisions. Instead, the MAC method can use simpler methods, such as polling or TDMA, to coordinate the access and transmission of data.

How L3 Routing Uses LANs Link to heading

Tip

The major steps in a router’s internal L3 routing for each packet beginning with a frame arriving in a router interface are:

  1. Use the data-link FCS field to ensure that the frame had no errors; if errors occurred, discard the frame.
  2. Assuming that the frame was not discarded at Step 1, discard the old data-link header and trailer, leaving the IP packet.
  3. Compare the IP packet’s destination IP address to the routing table, and find the route that best matches the destination address. This route identifies the outgoing interface of the router and possibly the next-hop router IP address.
  4. Encapsulate the IP packet inside a new data-link header and trailer, appropriate for the outgoing interface, and forward the frame.
Example

Consider the following scenario where PC1 needs to communicate with PC2:

Scenario

PC1 analyses the destination address and realises that PC2’s address is not on the same LAN as PC1. So PC1’s logic tells it to send the packet to a device whose job it is to know where to route data: a nearby router, on the same LAN, called PC1’s default router.

  1. To send the IP packet to R1, PC1 encapsulates the IP packet in an Ethernet frame with the destination MAC address of R1.
  2. R1 decapsulates the IP packet from the Ethernet frame and encapsulates the packet into a new Ethernet frame, with a new Ethernet header and trailer. The new destination MAC address is R2’s G0/0 MAC address, and the source MAC address is R1’s G0/1 MAC address.
  3. R2 decapsulates the IP packet from the Ethernet frame, encapsulates the packet into an Ethernet frame with the destination MAC address of PC2, and forwards the Ethernet frame to PC2.

Address Resolution Protocol (ARP) Link to heading

Because of the need to build new data-link headers and trailers, and because the new headers contain new data-link addresses, the PCs and routers must have some way to decide what data-link addresses to use. This introduces the need for the IP Address Resolution Protocol (ARP).

Note
Read more at ๐Ÿ”—.

IEEE 802 Standards Link to heading

Info
Applied to Ethernet, Bridging and Virtual Bridged LANs Wireless LAN, Wireless PAN, Wireless MAN, Wireless Coexistence, Media Independent Handover Services, and Wireless RAN with a dedicated Working Group (WG) providing focus for each area.
IEEE 802 StandardTopic
802.1LAN/MAN/WAN management; protocol layers above the MAC and LLC sublayers
802.2LLC sublayer
802.3MAC sublayer and Physical layer
802.3acVirtual LAN (VLAN)
802.4Token Passing Bus
802.5Token Passing Ring
802.6Distributed Queue Dual Bus (DQDB) Metropolitan Area Network (MAN)
802.7Broadband Local Area Networks
802.8Fibre-Optic LANs and MANs
802.9Isochronous LANs
802.10LAN/MAN Security
802.11Wireless LAN (WLAN)
802.12Demand Priority Access Method
802.15Wireless PAN (WPAN)
802.16Wireless Metropolitan Area Network (WiMAX)
802.17Resilient Packet Ring
802.18LAN/MAN Standards Committee