Brendan Ang

Search

Search IconIcon to open search

Link Layer

Last updated Feb 26, 2023 Edit Source

# Link Layer

The link layer is responsible for data transfer between nodes over links.

Where is it implemented?: usually in a Network Interface Card (NIC), which contains the hardware to send datagrams to the link, and also software in terms of the controller which bridges the interface between the host CPU and hardware.

# Multiple Access Problem

How to coordinate the access of multiple sending and receiving nodes to a shared link? The link layer implements multiple access protocols.

# Channel Partitioning Protocols

Partition the broadcast channel’s bandwidth among nodes sharing the channel. 500

# Random Access Protocols

Each node transmit at full rate, when a collision occurs, independently choose a random delay before retransmission. Probable for the node to sneak in its packet.

# Carrier Sense Multiple Access Collision Detection (CSMA/CD)

Rather than independently making a decision:

# Taking turns

Each node take turns to transmit some data.

The link layer requires its own addresses (MAC address) in order to forward datagrams to the correct network adapter. Each MAC address is unique no matter the location, unlike IP addresses which change depending on the network the host is connected to.

Why link layer address + network layer address (IP)?: the network is not meant for just IP, without MAC addresses, it cannot easily support other protocols.

# Address Resolution Protocol (ARP)

When a host wants to send a datagram to another over IP, it must give the IP datagram and the destination MAC address. ARP is used to determine the MAC address given an IP address on the same LAN or subnet. What if there is no entry in the ARP table for a desired destination?

  1. Sender construct ARP packet and indicate to use the MAC broadcast address FF-FF-FF-FF-FF-FF before passing to the adapter (consequently, this also reaches any other connected switches, populating their address tables)
  2. Adapter encapsulates the packet into the link layer frame and transmits
  3. Each adapter on the subnet passes the frame to its own ARP module which checks if the destination IP is its own. If it is, sends the packet back with the desired mapping

# Sending across different subnets

ARP can only be used to obtain MAC addresses of IP addresses on the same subnet. To send a packet outside:

  1. Sender construct the datagram with the IP address of the final destination but the destination MAC address of the router interface.
  2. Router deconstructs the datagram (because its own MAC address was found), and forwards the datagram to the MAC address of the final destination IP address (obtained with ARP) using its forwarding table.

# Ethernet

A switch receives incoming link-layer frames and forwards them onto outgoing links.

# Forwarding and filtering

Filtering determines whether a frame should be forwarded or dropped Forwarding takes the frame’s destination MAC address and forwards it to the interface. This is unlike a router which forwards based on IP addresses Switch table: The switch table is built automatically without any intervention:

  1. Switch table is initially empty
  2. For each incoming frame received on an interface, store the MAC address of the frame’s source address, interface which it arrived and the current time
  3. Delete address if no frame received with that address as its source after some period of time Elimination of collisions: a switch buffers frames and never transmits more than 1 frame on a segment at any 1 time. This means that no collision can occur and the Multiple Access Problem is solved.