0% found this document useful (0 votes)
59 views

Computer Networks 3

The document discusses error detection and correction techniques at the data link layer. It describes how frames are transmitted at the data link layer and how errors can occur during transmission. It then summarizes different error detection techniques like parity bits, checksums, and cyclic redundancy checks (CRCs). CRCs are powerful error detection codes that use polynomial arithmetic. The document discusses how CRCs work and provides background on polynomial arithmetic operations. It also compares error correction via forward error correction versus retransmission approaches.

Uploaded by

norac92034
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Computer Networks 3

The document discusses error detection and correction techniques at the data link layer. It describes how frames are transmitted at the data link layer and how errors can occur during transmission. It then summarizes different error detection techniques like parity bits, checksums, and cyclic redundancy checks (CRCs). CRCs are powerful error detection codes that use polynomial arithmetic. The document discusses how CRCs work and provides background on polynomial arithmetic operations. It also compares error correction via forward error correction versus retransmission approaches.

Uploaded by

norac92034
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 115

Computer Networks

CS F303

DATA LINLK LAYER

Ashutosh Bhatia
Department of Computer Science and Information Systems
BITS Pilani Birla Institute of Technology and Science
Pilani|Dubai|Goa|Hyderabad Pilani Campus, Pilani
Data-Link Layer
• Frame-by-Frame next-hop delivery
– Frame: Block of data exchanged at link layer
• Uses services of PHY layer (which delivers bits) to
deliver frames

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Link Layer Protocols
• Link could be point-to-point or broadcast
– Broadcast: Many nodes connected to same communication
channel (e.g. wireless)
• Protocol:
– Define format of frames to be exchanged over the link
– In response to frames, action to be taken by nodes
– Examples: Ethernet, Token-Ring, WiFi, PPP etc

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Services
• Logical Link Control (LLC): Interface between Network layer and
MAC sub-layer
– Multiplexing
– Error Detection
– Error Recovery (optional)
– Flow Control (optional)
• Media Access Control (MAC): Controls access to physical media
(Broadcast Channels)
• Switching (Interconnecting LANs)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Data Link Layer
Error Control
Error Detection
• What cause errors?
– Distortion of signals due to frequency dependant
attenuation, noise (PHY layer)
– Random single-bit vs Bursty errors
• Why detect errors?
– Data fidelity, prevent wastage of resources

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


What next?
• After Detection:
– Drop Frame
• Higher layers (e.g TCP) will recover or few losses dont hurt
applications (e.g. audio)
– Recover Frame
• Error Correction: Frame carries enough information to correct
errors
• Retransmission: Receiver signals sender on error, sender
retransmits the frame

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Error correction vs Retransmission

• Error correction requires more redundant bits per frame


than error detection
– Redundancy bits are sent all the time (every frame)
• Retransmission requires another copy to be transmitted
– Copy sent only on error

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Usage
• Error correction useful when
– Error rate if high (e.g. wireless)
– Cost (e.g. latency) of retransmission is too high (e.g. satellite
link)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Framework
• Add redundant information to a frame to detect or correct errors
• At Sender: Add k bits of redundant data to a m bit message
– k derived from original message through some algorithm
• At Receiver: Reapply same algorithm as sender to detect errors;
take corrective action if necessary
• Examples:
– Detection: k << m; k = 32; m ~12,000 for Ethernet
– Correction: Code Rate: m/(m+k)
• WiFi code rates range from 1/2 to 5/6

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Hamming Distance
• Code word: n=m+k bits
• Hamming distance between two codewords:
• Number of bits they differ in
– XOR the two codewords
• Example:
– Codewords: 01110110, 00011101
– Distance is 5

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Hamming Distance of a Code
• Number of possible code words is 2n
• Legal code words = 2m (determined by the algorithm)
• Among the list of legal code words, find the smallest
hamming distance between two code words
– This is the hamming distance of a code (=d)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Rules
• The error detection/correction capabilities are a
function of the code’s hamming distance
• Error Detection: Can detect up to d-1 errors
– To change one codeword to another require atleast d bit
changes
• Error Correction: Can correct up to (d-1)/2 errors
– The received codeword (in error) is still closer to the original
codeword than any other codeword

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Example

• Repetition code
– 0 -> 000; 1 -> 111
– m=1, k=2; n=3
– Hamming distance is 3, code rate is 1/3
• Can detect up to 2 errors and correct up to 1 error

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Design Considerations of a Code

• Reduce k to achieve high code rate


• For given values of n and k, maximize d
• Easy encoding and decoding
–Minimal memory and processing time

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Focus

• Error Detection
• Reliable Transfer (retransmissions)
• Error Correction
–E.g. Reed-Solomon codes, Convolution codes,
–Turbo codes

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Summary
• Important to detect errors in frames
• Error Recovery: FEC or Retransmission
– Inherent tradeoffs
• Framework (Overview)
– Hamming distance and error detection/correction
capabilities
– Design considerations
• Going forward: Error detection (in detail)
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
General Approach

• Add redundant information to a frame


• At Sender:
– Add k bits of redundant data to a m bit message
– k << m; k = 32; m = 12,000 for Ethernet
– k derived from original message through some algorithm
• At Receiver:
– Reapply same algorithm as sender to detect errors; take corrective action
if necessary

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Parity Bit

• Even Parity: 1100, send 11000


• Detects odd number of errors

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Two Dimensional Parity
• Used by BISYNC protocol for
ASCII characters

• “N + 8” bits of redundancy for


“N” ASCII characters (character
is 7 bits)

• Catches all 1, 2, 3 bit errors and


most 4 bit errors

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Internet Checksum

• Used at the network layer (IP header)


• Algorithm:
– View data to be transmitted as a sequence of 16-bit integers.
– Add the integers using 16 bit one's complement arithmetic.
– Take the one's complement of the result – this result is the
checksum
– Receiver performs same calculation on received data and
compares result with received checksum
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
• Sender: IPV4 header in hexadecimal
– 4500 0073 0000 4000 4011 c0a8 0001 c0a8 00c7 (16-bit words)
– Sum up the words (can use 32 bits): 0002 479c
– Add carry to the 16-bit sum: 479e
– Take the complement: b861 checksum
• Receiver:
– Sum up the words including checksum (use 32 bits): 2fffd
– Add carry to the 16 bit sum: ffff (= 0 in 1’s complement) no error
was detected
example values from wikipedia
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Internet Checksum

• Not very strong in detecting errors


– Pair of single-bit errors, one which increments a word, other
decrements a word by same amount
• Why is it used still?
– Very easy to implement in software
– Majority of errors picked by CRC at link-level (implemented
in hardware)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Cyclic Redundancy Check (CRC)

• Used by many link-level protocols: HDLC, DDCMP,


Ethernet, Token-Ring
• Uses powerful math based on finite fields
• Background: Polynomial Arithmetic

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Polynomial Arithmetic

• Represent a m bit message with a polynomial of


degree “m-1”
–11000101 = x7 + x6 +x2 + 1
• Arithmetic over the field of integers modulo 2
(coefficients are 1 or 0)
• Addition or subtraction are identical: XOR

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Polynomial Arithmetic

• Polynomial division (very similar to integer


division)
–X/Y is X = q*Y + r
–For integers: 0<=r<Y
–For polynomials: degree of r (remainder polynomial)
is less than divisor polynomial

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Cyclic Redundancy Check (CRC)
• Message polynomial M(x): m bit message represented with a
polynomial of degree “m-1”;
– 11000101 = x7 + x6 +x2 + 1
• Sender and receiver agree on a divisor polynomial C(x) of degree k
– k: Number of redundancy bit
– E.g. C(x) = x3+x2+1 (degree k = 3)
– Choice of C(x) significantly effects error detection and is derived carefully
based on observed error patterns
– Ethernet uses CRC of 32 bits, HDLC, DDCMP use 16 bits
– Ethernet: x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Idea
• Sender sends m+k bits => Transmitted message P(x)
• Contrive to make P(x) exactly divisibly by C(x)
• Received message R(x)
– No errors: R(x) = P(x), exactly divisible by C(x)
– Errors: R(x) ~= P(x); likely not divisible by C(x)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Generate P(x)

• You have M(x) and C(x). Generate P(x)


• Multiply M(x) by xk to get T(x)
– Add k zeros at the end of the message
– Divide T(x) by C(x) to get remainder R(x)
• Subtract remainder R(x) from T(x) to get P(x)
• P(x) is now exactly divisible by C(x)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Details

• T(x) = x^k M(x) = Q(x) C(x) + R(x)


• P(x) = x^k M(x) –R(x) = x^kM(x) +R(x) =Q(x)C(x)
– Coefficients of R(x) are the redundant bits
– Transmitted Bits: Messaged (n) bits, followed by redundant
bits (k)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Example

• Message (M): 11001011

• Divisor (C): 1101

• T: 11001011000

• Remainder (R): 101

• Transmitted Bits (P): 11001011101

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Error Detection

• Received polynomial = P(x) + E(x)


• E(x) captures bit map of the positions of errors
• Cannot detect errors if E(x) is also divisible by C(x)
• Goal: Design C(x) such that for anticipated error
patterns, E(x) is not divisible by C(x)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Example
• Detect all instances of odd number of bit errors
• E(x) contains odd number of terms with coefficient of ‘1’
– Implies E(1) = 1

• If C(x) were a factor of E(x), then C(1) would also have to be 1


• If C(1) = 0, we can conclude C(x) does not divide E(x)
• If C(x) has some factor of the form x^i+1, then C(1)=0

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Capabilities
• All single-bit errors, if xk and x0 have non-zero coefficients
• All double-bit errors, if C(x) has at least three terms
• All odd bit errors, if C(x) contains the factor (x + 1)
• Any bursts of length <= k, if C(x) includes a constant term (x0
term)
• CRC is easily implementable on shift registers

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Data Link Layer :
Media Access Control
(MAC)
Problem
• Status: Can transfer data reliably between two point-to-point
nodes
• Next: How to make a few tens of nodes talk?

?
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Outline
• How to interconnect nodes? Network Topology
• How to mediate access among the nodes? Media Access
Control (MAC)
– Categorize and discuss some popular MAC protocols
• Overview, merits and demerits

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Network Topologies

Note: Shared Wire or Medium is broadcast


BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Types of Transmission
• Unicast:
– Packet is intended for one node only
• Broadcast
– Packet intended for everyone
• Multicast
– Packet intended for a subset.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Media Access Control (MAC)

• Two or more simultaneous transmissions by nodes 


interference (collision)
• MAC: Protocol that determines how nodes share
channel
– Determine when a node can transmit
– Communication about channel sharing must use channel
itself!

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Ideal MAC
• Broadcast channel of rate R bps
– When one node wants to transmit, it can send at rate R.
– When M nodes want to transmit, each can send at average
rate R/M
– Simple and easy to implement
– Fault tolerant

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Human Analogy

• Speed Dating Party: Couples want to talk with each


other
– Assumption: Everyone talks loudly, so everyone can hear
everyone else in the room  If two speaker talk at same
time, none can understand what was talked
• How would you facilitate meaningful conversations (no
interference)?

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Channel Partitioning Protocols

Divide resource into smaller “pieces”.


Allocate piece to node for exclusive use.
Time Division Multiplexing
• Allocate couples different time slots  Time Division
Multiplexing (TDM)
• Time divided into time frames. Time frames divided into N
time slots. Each sender allocated one time slot.
• Disadvantage: Sender limited to R/N even when other senders
are idle, channel access delay

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Frequency Division Multiplexing
• Move couples to different rooms Frequency Division
Multiplexing (FDM)
• Spectrum divided into frequency bands
– Sender/Receivers tune in to assigned frequency band
– If there are N senders, each sender gets R/N bandwidth
• Disadvantages:
– A sender limited to R/N even when other senders are idle
– Sender-Receiver channel coordination

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Frequency Division Multiplexing

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Human Analogy

• Speed Dating Party: Couples need to talk with each


other
– Assumption: Everyone talks loudly, so everyone can hear
everyone else in the room
• How would you facilitate meaningful conversations (no
interference)?

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Random Access Protocols

• Polite Speaker: Listen. If its quiet, start talking. If this


clashes with others, backoff and try again.
• No a priori coordination among nodes
• Sender transmits at full rate. If two or more transmit at
same time  Collision

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Random Access Protocols

• Specify:
– How to detect collisions?
– How to recover from collisions?
• Disadvantages:
– High load leads to too many collisions and wastage of
resources

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Taking Turns Protocols
• Quickly poll to see who wants to talk, give time slots to only
speakers
• Channel partitioning MAC protocols: efficient and fair at high
load, inefficient at low load
• Random access MAC protocols: efficient at low load, inefficient
at high load
• Taking Turns protocols: Make the best of both worlds!

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Polling (Centralized)
• A central coordinator polls nodes in a round robin fashion
• Disadvantages:
– Polling overhead (single user will get rate < R)
– Single point of failure (coordinator)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Token Passing (Decentralized)
• Control token passed from one node to next in certain order
• Concerns
– Token overhead
– Single point of failure (token)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Summary
• Many nodes sharing a link  Need Media Access Control
• Three broad classes of Protocols:
– Channel Partitioning: Divide resource into smaller “pieces” (time
slots, frequency, code); Allocate piece to node for exclusive use
– Random Access: Allow full access to resource but provide means to
recover from collisions
– Taking turns: Take turns using the resource, but nodes with more
need get longer turns
• Next: Explore some popular technologies along with their
corresponding MAC

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Aloha
Background
• 1970’s : Wireless computer network developed at University of
Hawaii to interconnect Hawaiian islands
– First operational packet radio network
• Inspiration to many standards: Ethernet, WiFi, Cellular (random
access channels)
• Simple and relatively easy to analyze

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Pure Aloha
• Senders transmit whenever they have a packet to send
• Sender can determine status of packet (intact or collision) at
end of transmission
• If collision, sender waits a random amount of time and tries
again

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Efficiency
• What is the efficiency of ALOHA?
– What is the probability that a transmitted frame does not suffer
collision?

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Assumptions
• Frames are of equal length
• Probability of k transmission attempts per frame time (old
retransmissions and new) is Poisson with mean G per frame
time.
– Pr[k] = Gk e-G / k!

(Infinite user population generating new frames with a poisson


distribution with mean rate less than 1 per frame)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Throughput

• Throughput S = G * Ps
– Ps: probability that a frame is successful i.e. did not suffer
collision
• Determine Ps
– Under what conditions will a frame not suffer collision?

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Vulnerable Period

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Analysis
• Consider the sequence of successive transmission attempts on
the channel.
• For some given i, let Ti be the time interval between the ith and
the i+1th transmission attempt
• ith attempt will be successful if both Ti and Ti-1 exceed frame
time
– Intervals are independent

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Analysis

• From Poisson distribution, the inter arrival time


between attempts is exponential
– Pr (T > frame time) = e-G
– Prob of success = Ps = e-G * e-G = e-2G
– S = GPs = G e-2G
• Maximum Throughput: G = 0.5, S = 0.184 (18%)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Slotted Aloha

• Time divided into discrete intervals (slots)


– Slot interval corresponds to frame time
• Nodes can transmit frames only at beginning of slots
– Nodes are time synchronized
• Vulnerable period reduced by half

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Vulnerable Period (Slotted Aloha)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Analysis
• S = G e-G
• Maximum Throughput: G=1, S = 1/e = 0.368 (36.8%)
• At G=1, empty slots is 37%, successes is 37% and collisions is
26%
• Higher values of G decrease empty slots, but increase collisions
exponentially

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Another Method
• N nodes with many frames to send
• A node transmits with probability p in a slot
• Prob that a given node succeeds = p (1-p)N-1
• Prob that a slot is a success = E(N,p) = prob any node succeeds =
Np(1-p)N-1
• For maximum efficiency, find p such that maximizes Np(1-p)N-1
• p* turns out to be 1/N
• Efficiency = 1/e, In the limit N -> infinity

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Theory vs Practice
• Assumptions very important
• Reality can be very different from theory
• Example:
– Poisson arrivals not true
– Fixed packet size not true
– Infinite population not true
– Other parameters, buffering, slotting

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Summary
• Looked at two simple random access protocols – Pure Aloha
and Slotted Aloha
• Looked at how such protocols can be theoretically evaluated
• Maximum efficiency of both is rather poor
• Another class of random access protocols: CSMA (Carrier Sense
Multiple Access)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Outline
• CSMA class of protocols
– Persistent and Non-persistent
• Ethernet MAC : CSMA/CD
– Applicable for Bus or Star topology in shared mode

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Problems with Aloha

• What causes collisions?


–Pure Aloha: Transmissions without care or concern for
channel state
–Slotted Aloha: Multiple arrivals in previous slot ->
collision in current slot (greedy to access channel)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


CSMA
• ‘Listen before Talk’ – Carrier Sense
• If a node has a frame to send, listen to channel first
– If busy, don’t send frame --- don’t disrupt ongoing transmission
– If idle, send frame
• Two categories: persistent and non-persistent

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


1-Persistent CSMA
• Employed by Ethernet
• If a node has a frame to send:
– If channel busy, wait till it becomes idle, then transmit
– If channel idle, transmit
– If collision, wait a random amount of time and start over
• Better than Pure Aloha, but is it better than Slotted Aloha?

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Non Persistent CSMA
• Used in 802.15.4 (Zigbee/Sensor technology)
• If a node has a frame to send:
– If channel busy, do not sense anymore. Wait a random amount of
time and try again
– If channel idle, transmit
– If collision, wait a random amount of time and start over
• Better channel utilization than 1-persistent but longer delays

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


P-persistent
• Employed by 802.11 (WiFi)
• Assumes a slotted system
• If a sender has a frame to send:
– If channel idle, transmit with probability p (defer to next slot with
probability q=1-p). Repeat till frame sent or channel busy due to
another transmission
– If channel busy, wait till idle. Repeat above.
– If collision, wait a random time and try again
• Good Tradeoff between non-persistent and 1-persistent

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


QUIZ
• In which of the following protocols can a channel be idle at the end of a transmission even when there are
nodes with traffic to send?
– Slotted aloha
– 1-persistent
– Non-persistent
– P-persisitent

• Which of the following protocols does better in terms of channel utilization at high loads?
– Slotted aloha
– 1 persistent
– Non persistent
– 0.5 persistent

• Which among the following is a slotted system?


– Pure aloha
– 1 persistent CSMA
– Non persistent CSMA
– P persistent CSMA

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Ethernet MAC
• CSMA/CD: Carrier Sense Multiple Access (1-persistent) with
Collision Detection
– ‘Listen before talk’
– Simultaneous talking, stop talking reduces wastage of resource
• Following explanation applicable to 10Mbps Ethernet

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Collision Detection

• Cases under which collision occurs?


– Two stations waiting for channel to become idle
– Two stations attempting transmission at same time on an idle
channel
– Two stations attempting transmission at slightly different times on an
idle channel
• Effect of propagation delay

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Collision Detection

• Collision detection done by hardware


• Propagation delay affects efficiency
– Longer the propagation delay, higher chances of collision
• Worst case delay of detecting collision?
– One RTT

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Collision Detection

• On detecting collision send a jamming signal of 32 bits


• Why jamming signal?
– Ethernet Frame is 96 bits (64 bits preamble + 32 jamming)
– Jamming extends the frame to allow collision detection

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Frame Size
• Minimum frame size is 64 bytes (512 bits)
– 46 bytes of payload (18 byte header)
• Why this restriction?
– A host must transmit for one RTT to detect all collisions
– This RTT for 2500m long cable with 4 repeaters is about 51.2us
(10Mbps -> 512 bits)
• Maximum number of hosts: 1024 in a collision domain

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


CSMA/CD

• Adaptor has a frame to send:


– If channel idle (for 96 bit time), start transmission. If busy,
wait until channel idle (+96 bits time) and then transmit.
– If no collision detected, done
– If collision detected, stop transmission, send jamming signal.
Enter exponential backoff
• (For 10Mbps, bit time is 0.1us)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Exponential Backoff

• When transmitting a frame after mth collision


– Wait for K*512 bit times and return to step 1
– K chosen at random from {0,1,2 ….. 2m-1} m = min (n,10)
– 1st collision: choose K from {0,1}
– 2nd collision: choose K from {0,1,2,3}
– After 10th collisions, choose K from {0,1,2,3,4,…,1023}
– Maximum number of transmissions of a frame: 16 (15
retransmissions)
– Size of k grows exponentially after each collision

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Exponential Backoff

• Why exponential backoff?


– Adapts to current load
– Not very fair (Capture effect)
• Why 512 bit time?
– Ensures that if a node chose a lower value of K than any
other node, it can transmit without collision

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Efficiency
• Long run fraction of ‘useful’ time on the channel
– Large number of nodes with large number of frames to transmit
– Efficiency = 1 / [1+5(Tprop/Ttx)]

• Tprop = max prop time between 2 nodes in LAN


• Ttx = time to transmit a frame
• As Tprop approaches 0 or Ttx becomes large, efficiency
approaches 1

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Exercise
• Suppose you want to employ CSMA/CD (not the Ethernet
standard as such) on a bus topology of length 2km and rate
10Mbps. What minimum size frame in bytes would you use?
Format X. Assume speed of light is 2* 10^8m/s

Ans. 25
• The propogation delay is 2 * 10^3/2*10^8 = 10us. RTT = 20us.
Bits that can be sent during 20us = 200 bits = 25 bytes.
Hence we need a frame size of at least 25 bytes.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Ethernet Capture Effect
• Two stations A, B employing Ethernet standard are competing for access. Suppose,
both stations have many frames to send (labelled A1, A2, ... for A and B1, B2, .... for
B). Suppose A and B simultaneously transmit their respective first frames and
collide. After their first collision, A chooses k=0, while B chooses k=1. This ensures
that transmission of A1 is successful while B1 is yet to meet with success. At the end
of A1's transmission, A attempts to send A2 and B attempts to send B1. What is the
probability that A2's transmission succeeds over B1's?

Ans. 0.625.
A is choosing between k = {0,1}, while B is choosing between k = {0,1,2,3}. The number
of possible combinations is 2 * 4 = 8. Out of these, if A chose k=0, it will win if B chose
{1,2,3} = 3 choices But if A chose k=1, it will win if B chose {2,3} = 2 choice. Hence A2
will succeed = 5/8.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Exercise
• Suppose two nodes A and B both transmit packets at the same time and
collide. As soon as they collide, they send the jamming signal and enter
exponential backoff. Assume the time at which both A and B finish
transmitting the last bit of the jamming signal is set to 0, and the one way
propagation delay between the nodes is 250 bit times. Also suppose that A
chose a value of k=0 and B chose a value of k=1 (waits 512 bit times).
1. When does node A begin transmission? Express the answer in terms of
bit times.
2. When does node A's first bit reaches B relative to time 0? Express answer
in bit times.
3. When does node B attempt to transmit its first bit?

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Computer Networks
CS F303

Obtaining IP Addresses
Ashutosh Bhatia
Department of Computer Science and Information Systems
BITS Pilani Birla Institute of Technology and Science
Pilani|Dubai|Goa|Hyderabad Pilani Campus, Pilani
Problem Statement

• IP layer forwarding is based on IP addresses

• Next-hop delivery based on Link addresses (MAC)

• Need to perform IP to MAC address translation

• Answer: Address Resolution Protocol (ARP)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Address Resolution Protocol (ARP)
• Operates at Link layer (Frame type = 0x0806)

• Based on broadcast: What is the MAC address corresponding


to given IP address?
– Host with matching IP address replies

• Each host maintains a cache with IP to MAC translations


– Entries in cache timed out periodically (15 min)
– arp –a shows all the ARP cache entries

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Address Resolution Protocol (ARP)

• Originator: Add entry to cache corresponding to target

• Target: Add entry to cache corresponding to the originator


(sender)

• Intermediate hosts: Refresh existing entries


• When forwarding a datagram, check cache, if no mapping,
invoke ARP

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


ARP Packet Format

Numbers in brackets capture mapping IP


addresses to Ethernet addresses

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Proxy ARP
• Router answers ARP requests for a host on of the network on another
interface
• The sender of the ARP request thinks that the router is the destination host
• The router acts as proxy agent for the destination host, and relays its packets
• Motivation
– Can hide a number of machines
– All packets for these machines have to pass through the router running
Proxy ARP, where the packets can be examined
– The sender does not know that its packets are passing through a machine
and are being checked

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


How Does Proxy ARP Work?
• The Host A (172.16.10.100) on Subnet A needs to send
packets to Host D (172.16.20.200) on Subnet B.

• As Host A has a /16 subnet mask, it believes that it is


directly connected to Host D, so it sends an ARP request
to Host D. But does not reach Host D.

• The router sends Proxy ARP reply to Host A telling its


own MAC address as the host D MAC address .

• Upon receipt of this ARP reply, Host A updates its ARP


table

• Later whenever router receives a packet for host D at


interface e0 from anybody in subnet A, it relays the
packet to interface e1
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Gratuitous ARP
• Wireshark/Tcpdump Output
– arp who-has IP_x tell IP_y
– Source protocol address: IP_y
– Target protocol address: IP_x

• Sometimes, one sees IP_x= IP_y


– The sender knows its address; yet it issues a request asking to resolve its address
– Hence “gratuitous”
– Does not expect a reply

• But if a reply arrives: misconfigured system!

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Gratuitous ARP

• A feature of ARP
– Host H has an entry in its ARP cache for IP address X
– It receives an ARP request from IP address X for some
address Y
– Even though H does not reply to the ARP request, it updates
its ARP cache with X’s hardware address (contained in the
ARP Req)
– “Latest” hardware address is maintained

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Uses of Gratuitous ARPs
• Backup server taking over from a failed server

• After detecting that the primary server has failed, the backup
server

– Issues a gratuitous ARP request, with the primary server’s IP address and
its own hardware address

– Causes all machines to update their ARP cache entries, so that the
backup’s hardware address is noted

– Henceforth, all traffic is directed to the backup server

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956

You might also like