Networks Lecture 19

Link Layer

Link layer: transmitting data between "directly connected" nodes. Issues:

  1. Error detection
  2. Retransmission
  3. Flow control
  4. Random access
  5. Point to point vs. broadcast

Framing: link layer header. In some cases may include "trailer" fields. Framing should mark where frame begins and ends.

Link layer services

Medium Access
Point to point: trivial. In a broadcast network, the link layer protocol needs to mediate access to the shared communication medium.
Reliable delivery (optional)
May be provided by the link layer if the communication medium has a high error rate. E.g., wireless networks.
Flow control (optional)
Ensure that frames are not sent faster than receiver can process them
Error detection (optional)
Bit errors may arise for various reasons: primarily, attentuation, interference.
Error correction (optional)
Redundant bits may allow recovery from some errors

Half vs. Full Duplex

In a half-duplex link, a node can be either sending or receiving, but not both. In a full-duplex link, node can send and receive at the same time.

Network Interface Card (NIC)

Network interface devices perform many link-layer functions autonomously (without explicit control by the host CPU). Host CPU programs the NIC with the address of buffers containing frame to be sent, and the NIC physically transmits the frame when the link is available. Host CPU also programs the NIC with the address of buffers where incoming frames can be placed: when a frame has arrived, the NIC interrupts the host CPU so it can handle the frame.

Error Detection and Correction

Parity

Parity: a 1-bit checksum. Can detect any single-bit error. If errors are rare and errors do not cluster, parity could be sufficient. However, many types of errors that occur in practice do cluster. Any two bit error in a chunk of data covered by a single parity bit does not violate parity, so it goes undetected.

Two-dimensional Parity

Two-dimensional parity can detect all 1 and 2 bit errors, and recover from all 1 bit errors. The data bits are arranged in a grid, and parity is computed for each row and column. Example:

1 0 0 1 | 0
1 1 0 0 | 0
0 1 1 0 | 0
0 1 1 1 | 1
--------+--
0 1 0 0 | 0

A single bit error will cause a parity violation in exactly one row and one column. The intersection of that row and column must contain the incorrect bit:

1 0 0 1 | 0
1 1 0 0 | 0
0 1 0 0 | 0 <-- does not check
0 1 1 1 | 1
--------+--
0 1 0 0 | 0
    ^
    |
   does not check

A two bit error will cause parity violations in either:

However, none of these cases reveals enough information to precisely pinpoint the corrupted bits.

A three bit error can go undetected. For example:

1 0 0 1 | 0
1 1 0 0 | 0
0 1 0 0 | 1
0 1 1 1 | 1
--------+--
0 1 1 0 | 0

Checksum

As we saw in Lecture 11, checksums can allow multiple bit errors to go undetected. The necessary and sufficient condition for a set of errors going undetected is that the sum of the differences induced by the errors is 0.

Cyclical Redundancy Check (CRC)

A stronger form of error detection: an r-bit CRC will detect all errors of r bits or less, and will detect errors in a larger number of bits with high probability.

Procedure: treat data D as the integer represented by D's bit pattern. Given generator value G, compute (D * 2^r) / G. The remainder is the CRC. The division is performed in a particular way: subtraction is done using XOR (bitwise exclusive or), with no borrows.

Multiple Access Protocols

Many LAN network technologies, e.g. ethernet, are broadcast networks. Generally, in a broadcast network if two nodes are transmitting at the same time, the result is a collision. When two transmitted frames collide, the electrical signals interfer with each other and each transmission is garbled. A multiple access protocol attempts to (1) prevent collisions, and (2) resolve collisions by allowing both senders to (eventually) transmit without interference.

Multiple access approaches:

TDM - Time Division Multiplexing
Each sender is allotted particular time slots in which it has the exclusive right to transmit
FDM - Frequence Division Multiplexing
Each sender gets its own frequency. Simultaneous transmissions on different frequencies do not interfere.
CDMA - Code Division Multiple Access
Each sender encodes data with a unique code word. The codes allow the original message from each sender to be reconstructed at the receiver, even if there are multiple (interfering) transmissions.
Taking turns
Similar to TDM, except that instead of precisely allocated slots, nodes may transmit when it is their turn to transmit. Turns may be decided by a central authority (the "master"), or they may be decided more cooperatively.
Random Access
A free-for-all: senders try to send when they can, but collisions will occur. A means of detecting collisions and allowing nodes to retransmit without interference is needed.

Token Ring

Nodes are arranged in a ring. Frames travel in only one direction: around the ring. A node may only transmit frames when it is holding the token. The token is passed around in the same order as data is sent.

The sender is responsible for removing (not repeating) frames that it sent.

ALOHA, Slotted ALOHA

Originally a wireless broadcast network technology, it was the inspiration for ethernet.

In Slotted ALOHA, time is divided into slots. When a station has a frame to transmit, it simply sends the frame. When a collision occurs, it flips a biased coin in subsequent slots: in each slot, it retransmits with probability p. Example:

In this example, the first two slots are wasted because of collisions. The last two slots are both used successfully because only one node transmitted in those slots. In four time slots, only two nodes transmitted successfully, and node C was not able to transmit.