Link Layer

Datagram transferred by different link protocols over different links

Analogy

  • Trip from Princeton to Lausanne
    • Car: Princeton to JFK
    • Plane: JFK to Geneva
    • Train: Geneva to Lausanne
  • tourist = datagram
  • transport segment = communication link
  • transportation mode = link layer protocol
  • travel agent = routing algorithm

Framing, Link Access:

Adaptors Communicating

Sending Side:

Error Detection

Pasted image 20241216234301.png
EDC = Error Detection and Correction bits (redundancy)
D = Data protected by error checking, may include header fields

Parity Checking

Single bit parity:

Pasted image 20241216234731.png

Two-dimensional bit parity:

Pasted image 20241216234804.png

Internet Checksum

Goal: detect “errors” in transmitted packet

Cyclic Redundancy Check

Example

Pasted image 20241219122144.png

Multiple Access Protocols

Single shared broadcast channel

Distributed algorithm that determines how nodes share channel

  • Determine how nodes share channel
  • Communication about channel sharing must use channel itself

Two types of links:

Random Access Protocols

Slotted ALOHA

Assumptions

Operations

Pros

Cons

Efficiency

At best, channel used for useful transmission 37% of time

Np(1p)N1

N is number of nodes
p is probability of transmission

Pure ALOHA

Simpler, no synchronization

Efficiency

Np(1-p)^{2(N-1)}$$$N$ is number of nodes $p$ is probability of transmission ### CSMA **Carrier Sense Multiple Access** * Listen before transmit * If channel sensed idle: transmit entire frame * If channel sensed busy: defer transmission #### Collisions Propagation delay: * Two nodes may not hear each other’s transmission Collision: * Entire packet transmission time wasted * Distance & propagation delay play role in determining collision probability ### CSMA/CD (collision detection) Carrier sensing, deferral as in CSMA * Collisions detected within short time * Colliding transmissions aborted, reducing channel wastage **Collision detection:** * Easy in wired LANs: Measure signal strengths, compare transmitted, received signals * Difficult in wireless LANs: received signal strength overwhelmed by local transmission strength ![Pasted image 20241219143635.png](/img/user/assets/Pasted%20image%2020241219143635.png) #### Ethernet CSMA/CD Algorithm 1. NIC receives datagram from network layer, creates frame 2. If NIC senses channel idle, starts frame transmission 3. If NIC senses channel busy, waits until channel idle, then transmits 4. If NIC transmits entire frame without detecting another transmission, NIC is done with frame 5. If NIC detects another transmission while transmitting, aborts and sends jam signal 6. After aborting, NIC enters binary backoff 1. After $m$th collision, NIC chooses $K$ at random from {0,1,2, …, $2^m-1$}} 2. NIC waits $K\times 512$ bit times 3. Return to step 2 #### Efficiency $t_{\text{prop}}$ = max prop delay between 2 nodes in LAN $t_{\text{trans}}$ = time to transmit max-size frame $$\text{efficiency} = \frac{1}{1+5t_{\text{prop}}/t_{\text{trans}}}

Efficiency goes to 1

Taking turns MAC protocols

MAC addresses and ARP

32-bit IP address:

MAC Address:

Used locally to get frame from one interface to another physically-connected interface

ARP (Address resolution protocol)

Each IP node on LAN has table

Switch

Link-layer device:

Switch forwarding table

Each switch has a switch table with entries:

How are entries created, maintained in switch table?

Self-learning

  • Switch learns which hosts can be reached through which interfaces
    • When frame received, switch learns location of sender: incoming LAN segment
    • Records sender/location pair in switch table

If location unknown, flood

Switches VS. Routers

Both are store-and-forward: