Ece cs 372 introduction to computer networks lecture 16
Sponsored Links
This presentation is the property of its rightful owner.
1 / 52

ECE/CS 372 – introduction to computer networks Lecture 16 PowerPoint PPT Presentation

  • Uploaded on
  • Presentation posted in: General

Announcements:. ECE/CS 372 – introduction to computer networks Lecture 16. Acknowledgement: slides drawn heavily from Kurose & Ross. Our goals: understand principles behind data link layer services: error detection, correction sharing a broadcast channel: multiple access

Download Presentation

ECE/CS 372 – introduction to computer networks Lecture 16

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


ECE/CS 372 – introduction to computer networksLecture 16

Chapter 4, slide:

Acknowledgement: slides drawn heavily from Kurose & Ross

Our goals:

understand principles behind data link layer services:

error detection, correction

sharing a broadcast channel: multiple access

link layer addressing

example of link layer protocol


Chapter 5: Data Link Layer

Chapter 5, slide:

Some terminology:

nodes = hosts or routers

links = communication channels that connect adjacent nodes

wired links

wireless links

frame = layer-2 packet

Link Layer (also known as layer 2)

data-link layer has responsibility of

transferring datagram from one node

to adjacent node over a link

Chapter 5, slide:

links may have ≠ protocols

frames may be delivered by different link protocols over different links: e.g.,


802.11 (WiFi)

link protocols may provide ≠services

e.g., may or may not provide rdt over link

transportation analogy

Trip: Princeton to Marseille

limo: Princeton to JFK

plane: JFK to Paris

train: Paris to Marseille

tourist = frame

travel agent = routing algorithm

Doesn’t know/care of mode

transport mode = link layer protocol

≠ legs may use ≠ modes

Link layer: context

Chapter 5, slide:

Link Layer Services

  • link access and sharing:

    • Sharing and multiple access: allow medium/channel sharing

  • reliable delivery between adjacent nodes

    • transport layer-like reliability: ACK’ing

    • low bit-error link (e.g., fiber): rarely used

    • high bit-error link(e.g., wireless): often used

  • error detection:

    • errors caused by signal attenuation, noise.

    • receiver detects presence of errors

  • error correction:

    • receiver corrects errors w/o resorting to retransmission

Chapter 5, slide:

1 Error detection and correction

2 Link-layer Addressing

3 Multiple access protocols

4 Ethernet

Link Layer

Chapter 5, slide:

Error Detection

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

  • error detection not 100% reliable!: may not detect errors (rarely)

  • larger EDC field yields better detection and correction

Chapter 5, slide:

Example: Parity Checking

Two Dimensional Bit Parity:

Detect and correct single bit errors

Single Bit Parity:

Detect single bit errors

In this example:

D = data bits EDC = parity bit



Chapter 5, slide:

Checksumming: Cyclic Redundancy Check

  • Example:

  • D= 101110

  • r = 3 bits

  • G = 1001

  • Find R such that

  • G divides <D,R> (modulo 2)

  • equivalently

  • G divides <D.2r XOR R>


  • View data bits, D, as a binary number

  • Fix r CRC bits

  • Choose r+1 bit pattern (generator), G

  • Sender: choose r CRC bits, R, such that

    • G exactly divides <D,R> (modulo 2)

  • receiver knows G, divides <D,R> by G.

    • If non-zero remainder: error detected!

  • detect burst errors less than r+1 bits

Chapter 5, slide:

CRC: modulo-2 arithmetic

  • CRC calculations are done modulo-2 arithmetic

    • No carries in addition

    • No borrows in subtraction

      => Addition = subtraction = bitwise-XOR

    • XOR review:

      0 XOR 0 = 0; 0 XOR 1 = 1; 1 XOR 0 = 1; 1 XOR 1 = 0

      => a XOR 0 = a , a XOR a = 0 for a=0,1

      E.g.: 1010 XOR 0110 = 1110

    • Multiplications and divisions are same as in base-2 arithmetic, except all additions and subtractions are done without carries or borrows

      • That is: addition = subtraction = bitwise-XOR

Chapter 5, slide:



R = remainder[ ]

CRC Example (find R)

  • Want: G divides <D.2r XOR R>

  • equivalently: D.2rXOR R = nG

  • equivalently: (XOR both sides)

  • (D.2rXOR R) XOR R = nG XOR R

  • equivalently: (R XOR R = 0 & a XOR 0 = a)

    D.2r = nGXOR R

  • equivalently: (division is modulo 2 too)

  • since remainder[(nGXOR R)/G] = R

  • (note: R < G), then dividing D.2r by G (modulo 2) gives remainder = R

Chapter 5, slide:

1 Error detection and correction

2 Link-layer Addressing

3 Multiple access protocols

4 Ethernet

Link Layer

Chapter 5, slide:

MAC Addresses

  • 32-bit IP address:

    • network-layer address

    • used to get datagram to destination IP subnet

  • MAC (or LAN or physical or Ethernet) address:

    • 48 bit MAC address (for most LANs)

      • burned in NIC ROM, also sometimes software settable

    • function:get frame from one interface to another physically-connected interface (same network)

    • uses hexadecimal representation; i.e., base-16 (i.e., 4 bits)

    • it uses 16 distinct symbols: 0,1,…,9,A,B,C,D,E,F

    • 4 bits needed for each symbol:  48/4 = 12 symbols

      E.g.: 1A-2F-BB-76-09-AD

Chapter 5, slide:

MAC Addresses

Each adapter on LAN has unique MAC (LAN ) address

Broadcast address =




(wired or


= adapter




Chapter 5, slide:


  • A knows B’s MAC address

  • A wants to send a frame to B

MAC Addresses

  • A encapsulates B’MAC into the frame

  • A sends the frame into the medium

  • All nodes will hear the frame

  • Only B grabs the frame

  • All other nodes discard the frame

Node A






Node B

Chapter 5, slide:

Question: if A doesn’t know

B’s MAC address, how does it

determine this MAC address?

ARP: Address Resolution Protocol

Solution: ARP

  • Each IP node (host, router) on LAN has ARP table

  • ARP table: maps IP, MAC address for some LAN nodes

    < IP address; MAC address; TTL>

    • TTL (Time To Live): remove mapping after TTL (typically 20 min)

  • A consults its table to determine B’s MAC given it knows B’s IP

  • Q: how to construct these ARP tables?

Node A






Node B

Chapter 5, slide:

A wants to send datagram to B, and B’s MAC address not in A’s ARP table.

A broadcasts ARP packet, containing B's IP address

dest MAC address = FF-FF-FF-FF-FF-FF

all machines on LAN receive ARP query

B receives ARP packet, replies to A with its (B's) MAC address

A sends frame to B since it knows its MAC now

A caches IP-to-MAC address pair in its ARP table until information becomes old (times out)

soft state: information that times out (goes away) unless refreshed

ARP is “plug-and-play”:

nodes create their ARP tables without intervention from net administrator

ARP: Case 1—Same LAN (network)

Chapter 5, slide:








ARP: Case 2—routing to another LAN

datagram needs to go from A to B via R

assume A knows B’s IP address

  • how does ARP work now ?? Would the previous scenario work?



Chapter 5, slide:








ARP: Case 2—routing to another LAN

Here’s how it works: (A wants to send IP datagram to B)

  • A knows that B belongs to a different subnet by checking B’s IP address

  • A also knows IP address of router R (routing table at layer 3)

  • A uses ARP to get R’s MAC address for (IP address of router)

  • A creates frame with R's MAC address as dest, frame contains A-to-B IP datagram

  • A’s NIC sends frame and R’s NIC receives it

  • R removes IP datagram from Ethernet frame, sees its destined to B

  • R uses ARP to get B’s MAC address (R has B’s IP address, included in the just received frame)

  • R creates frame containing A-to-B IP datagram and sends it to B



Chapter 5, slide:

Link layer Addressing: last words

  • manufacturer buys portion of MAC address space (to assure uniqueness of MAC addresses)

  • analogy: (a) MAC address: like Social Security Number

    (b) IP address: like postal address

  • MAC flat addressing ➜ portability

    • can move LAN card from one LAN to another; not true for IP

  • Q: why can’t we just use IP addresses; i.e., no MAC addresses??

    • LANs designed for all network layer protocols, not just IP

    • IP address will have to be stored/reconfigured to the adapter every time the adapter/computer is moved

  • Q: Why can’t we process/check frames at network layer instead??

    • Overhead; each and every frame will be processed (including those destined to others)

Lecture 15, chapter 5, slide:

1 Error detection and correction

2 Link-layer Addressing

3 Multiple access protocols

4 Ethernet

Link Layer

Chapter 5, slide:

Multiple Access Links and Protocols

Two types of “links”:

  • point-to-point

    • PPP for dial-up access

    • point-to-point link between Ethernet switch and host

  • broadcast (shared wire or medium)

    • Ethernet

    • 802.11 wireless LAN

humans at a


(shared air, acoustical)

shared wire (e.g.,

cabled Ethernet)

shared RF

(e.g., 802.11 WiFi)

shared RF


Chapter 5, slide:

Multiple Access protocols

need for sharing of medium/channel

  • single channel

    needs be used by all nodes

  • interference/collision

    two or more simultaneous transmissions lead to collided signals

    multiple access protocol

  • allows multiple, concurrent access

    algorithm that nodes use to share channel, i.e., determines when a node can transmit

  • no coordination, no out-of-band channel

    agreeing about channel sharing must use channel itself!

Chapter 5, slide:

Ideal Multiple Access Protocol

Broadcast channel of rate R bps

1. when one node wants to transmit, it can send at rate R.

2. when M nodes want to transmit, each can send at average rate R/M

3. fully decentralized:

  • no special node to coordinate transmissions

  • no synchronization of clocks, slots

    4. simple

Chapter 5, slide:

MAC Protocols: a taxonomy

Three broad classes:

  • Channel Partitioning

    • divide channel into smaller “pieces” (time slots, frequency, code)

    • allocate piece to node for exclusive use

  • “Taking turns”

    • nodes take turns, but nodes with more to send can take longer turns

  • Random Access

    • channel not divided, allow collisions

    • need to know how to “recover” from collisions

Chapter 5, slide:

Channel Partitioning MAC protocols: TDMA

TDMA: time division multiple access

  • access to channel in "rounds"

  • each station gets fixed length slot (length = pkt trans time) in each round

  • unused slots go idle

  • E.g.: 6-station LAN, 1,3,4 have pkt, slots 2,5,6 idle









Chapter 5, slide:

Channel Partitioning MAC protocols: FDMA

FDMA: frequency division multiple access

  • channel spectrum divided into frequency bands

  • each station assigned fixed frequency band

  • unused transmission time in frequency bands go idle

  • E.g.: 6-station LAN, 1,3,4 have pkt, frequency bands 2,5,6 idle


frequency bands

FDM cable

Chapter 5, slide:




“Taking Turns” MAC protocols


  • master node “invites” slave nodes to transmit in turn

  • concerns:

    • polling overhead

    • latency

    • single point of failure (master)



Chapter 5, slide:

“Taking Turns” MAC protocols

  • Token passing:

  • control token passed from one node to next sequentially.

  • If token, then send message

  • concerns:

    • token overhead

    • latency

    • single point of failure (token)



to send)



Chapter 5, slide:


ECE/CS 372 – introduction to computer networksLecture 17

Chapter 4, slide:

Acknowledgement: slides drawn heavily from Kurose & Ross

Random Access Protocols

  • distributed

    • unlike TDMA or FDMA

    • no coordination among nodes

  • one node at a time

    • when a node transmits, it does so at full data rate R.

  • collisions can occur

    • two or more transmitting nodes ➜ “collision”,

  • random access MAC protocol specifies:

    • how to detect collisions

    • how to recover from collisions

  • examples of random access MAC protocols:


      (CSMA: Carrier Sense Multiple Access;

      CD: Collision Detection; CA: Collision Avoidance)

Chapter 5, slide:


all frames same size

time divided into slots

slot = time to transmit 1 frame

start transmit at beginning of slot only

nodes are synchronized

if multiple nodes transmit in slot, all can detect collision


when node gets a fresh frame, transmits in next slot

if no collision: node can send new frame in next slot

if collision: node retransmits frame in each subsequent slot with prob. p until success

Slotted ALOHA

Chapter 5, slide:


single active node can continuously transmit at full rate of channel

highly decentralized: only slots in nodes need to be in sync



collisions, wasting slots

idle slots, wasting slots

clock synchronization

Slotted ALOHA


C = collision

E = empty/idle

S = success

Chapter 5, slide:

suppose:N nodes with many frames to send, each transmits in slot with probability p

prob that a given node has success in a slot ?


prob that any node has a success ?


Efficiency = Np(1-p)N-1

Slotted Aloha efficiency

Efficiency : long-run fraction of successful slots (many nodes, all with many frames to send)

Chapter 5, slide:

Efficiency = Np(1-p)N-1

max efficiency: find p* that maximizes Np(1-p)N-1

p* = 1/N

Max Eff = (1-1/N)N-1

When N increases to ,

max eff = (1-1/N)N-1 goes to 1/e = .37

Slotted Aloha efficiency

At best: channel used for 37% useful transmission time !

Chapter 5, slide:

Pure (unslotted) ALOHA

  • unslotted Aloha: simpler, no synchronization

  • when frame first arrives

    • transmit immediately

  • collision probability increases:

    • frame sent at t0 collides with other frames sent in [t0-1,t0+1]

Chapter 5, slide:

Pure Aloha efficiency

P(success by given node) = P(node transmits) x

P(no other node transmits in [t0-1,t0] x

P(no other node transmits in [t0,t0+1]

= p . (1-p)N-1 . (1-p)N-1

= p . (1-p)2(N-1)

… choosing optimum p and then letting N -> infinity ...

= 1/(2e) = .18

(to be derived in homework problem)

even worse than slotted Aloha!

Chapter 5, slide:

CSMA (Carrier Sense Multiple Access)

CSMA: listen before transmit:

If channel sensed idle: transmit entire frame

  • If channel sensed busy, defer transmission

  • human analogy: don’t interrupt others!

Chapter 5, slide:

CSMA collisions

spatial layout of nodes

collisions can still occur:

Node B’s transmission collides with Node D’s transmission

collision is a waste!

A cannot hear B’s signal

C cannot hear D’s signal


role of distance & propagation delay in collision likelihood

  • Longer distances => weaker signals

  • => collision may be recovered

  • Longer delays => collision may be avoided

Chapter 5, slide:

CSMA/CD (Collision Detection)

CD (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

    CSMA/CD: (CSMA w/ Collision Detection)

  • collisions detectable

  • colliding transmissions aborted

  • reducing channel wastage

Chapter 5, slide:

CSMA/CD collision detection

Chapter 5, slide:

1 Error detection and correction

2 Link-layer addressing

3 Multiple access protocols

4 Ethernet

Link Layer

Chapter 5, slide:



Ethernet topology

  • bus topology popular through mid 90s

    • all nodes in same collision domain (can collide with each other)

  • today: star topology prevails

    • active switch in center

    • each “spoke” runs a (separate) Ethernet protocol (nodes do not collide with each other)

bus: coaxial cable

Chapter 5, slide:

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame


  • total 8 bytes: 7 bytes, each with pattern 10101010 followed by one byte with pattern 10101011

  • used to synchronize receiver, sender clock rates (sender’s data rate matches receiver’s data rate)

Chapter 5, slide:

Ethernet Frame Structure

  • Addresses: 6 bytes

    • if adapter receives frame with matching destination address, or with broadcast address (eg ARP packet), it passes data in frame to network layer protocol

    • otherwise, adapter discards frame

  • Type: indicates higher layer protocol (mostly IP but others possible, e.g., Novell IPX, AppleTalk)

  • CRC: checked at receiver, if error is detected, frame is dropped

Chapter 5, slide:

Ethernet: Unreliable, connectionless

  • connectionless: No handshaking between sending and receiving NICs

  • unreliable: receiving NIC doesn’t send acks or nacks to sending NIC

    • stream of datagrams passed to network layer can have gaps (missing datagrams)

    • gaps will be filled if app is using TCP

    • otherwise, app will see gaps

  • Ethernet’s MAC protocol: CSMA/CD

    (more on this next…)

Chapter 5, slide:


1. Unsychronized:

NIC (adapater) may transmit at anytime; no notion of timeslots

2. Carrier-sense:

Never transmit if others are transmitting

3. Collision detection:

stop transmitting as soon as collision is detected

4. Random backoff:

wait a random time before retransmitting (more later)

CSMA/CD vs. slotted ALOHA

Slotted ALOHA

1. Sychronized:

transmit at beginning of a timeslot only

2. No carrier-sense:

No check for whether others transmit or not

3. No collision detection:

no stop during collision

4. No random backoff

Chapter 5, slide:

Notion of bit time

Before describing CSMA/CD, let’s introduce:

bit time = time to transmit one bit on a Ethernet link

Example: consider a 10 Mbps Ethernet link

Q1: what is a “bit time”

A1: 1/(10x10^6) second = 0.1 microsecond

Q2: how much time is “96 bit time”

A2: 96 x 0.1 = 9.6 microsecond

Chapter 5, slide:

1. adapter receives datagram from network layer, creates frame

2. If adapter senses channel idle for 96 bit time, starts frame transmission

(gap to allow interface recovery)

3. If adapter senses channel busy, waits until channel idle (plus 96 bit time), then transmits

4. If adapter transmits entire frame without detecting another transmission, adapter is done with frame !

5. If adapter detects another transmission while transmitting, aborts and sends a 48-bit jam signal

(to make sure all nodes are aware of collision)

6. After aborting (after sending jam signal), adapter enters exponential backoff:

adapter chooses Kat random

(next slide is explained how)

adapter waits K·512 bit times,

returns to Step 2

Ethernet CSMA/CD algorithm

Chapter 5, slide:

Jam Signal:

make sure all other transmitters are aware of collision; 48 bits

Exponential Backoff:

Goal: adapt retrans. attempts to estimate current load

heavy load: random wait will be longer

Light load: random wait will be shorter

first collision: choose K from {0,1}…

after 2nd collision: choose K from {0,1,2,3}…

after 3rd collision: choose K from {0,1,2,3,4,5,6,7}…

after 10th collision, choose K from {0,1,2,3,4,…,1023}…

after mth collision, choose Kfrom {0,1,2,…,2m-1}

Then, delay transmission until K· 512 bit times

Ethernet’s CSMA/CD (more)

Chapter 5, slide:

A and B are connected via an Ethernet link of 10 Mbps

Propagation delay between them = 224 bit time

At time t=0, both transmit which results in collision

After collision, A chooses K=0 and B chooses K=1





  • Q1: how much is “bit time”: =1/10 = 0.1 microsecond

  • Q2: at what time does collision occur?

    • =(224/2) x 0.1 = 11.2 microsecond

  • Q3: at what time does bus become idle?

  • =224 (both A & B detect collision) + 48 (A & B finish sending jam signals) +

  • 224 (last bit of B’s jam signal arrives at A) = 496 bit time

  • =496x0.1 (bit time)= 49.6 microseccond

  • Q4: at what time does A begin retransmission?

  • [496 (bus becomes idle) + 96]x0.1 (bit time)= 59.2 microsecond

Chapter 5, slide:

A and B are connected via an Ethernet link of R bps

A and B are separated by distance d meters

Speed of propagation is s meter/second

Length of each frame is L bits


L (bits)

d (m), s (m/s)

R (bps)



  • Suppose A starts transmitting a frame, and before it finishes, B starts also

  • Q1: can A finish transmitting before it detects that B starts transmitting? Basically, is it possible of A not to detect collision?

    • Answer: yes- if frame is not long enough, A can’t detect collision

  • Q1: find relationship between L, R, s, and d, so A can detect collision?

    • Hints:

    • B can’t send if medium is busy: listen-before-talk policy

    • Think of worst case, when just before the first bit coming from A arrives to B, B starts sending

Chapter 5, slide:

  • Login