IT305
Week 13_Lec 2
Computer Networks
CSMA and ARP
CSMA (carrier sense multiple access)
simple CSMA: listen before transmit:
• if channel sensed idle: transmit entire frame
• if channel sensed busy: defer transmission
CSMA/CD: CSMA with collision detection
• collisions detected within short time
• colliding transmissions aborted, reducing channel
wastage
• collision detection easy in wired, difficult with
wireless
Link Layer 2
CSMA: collisions spatial layout of nodes
▪collisions can still occur
with carrier sensing:
• propagation delay means two
nodes may not hear each
other’s just-started
transmission
▪collision: entire packet
transmission time wasted
• distance & propagation delay
play role in in determining
collision probability
Link Layer 3
CSMA/CD: spatial layout of nodes
▪CSMA/CD reduces the
amount of time wasted in
collisions
• transmission aborted on
collision detection
Link Layer 4
Ethernet CSMA/CD algorithm
1.Ethernet receives datagram from network layer, creates
frame
2.If Ethernet senses channel:
if idle: start frame transmission.
if busy: wait until channel idle, then transmit
3.If entire frame transmitted without collision - done!
4.If another transmission detected while sending: abort, send
jam signal
5.After aborting, enter binary (exponential) backoff:
• after mth collision, chooses K at random from {0,1,2, …,
2m-1}. Ethernet waits K·51.2 micro secs, returns to Step 2
• more collisions: longer backoff interval
• K = 0, immediate transmission
• k=1, wait 512 bit times
• 2nd collision, K={0, 1, 2,3}, This corresponds to a wait selected from {0,
51.2, 102.4, 153.6} micro seconds.
ARP: address resolution protocol
Question: how to determine interface’s MAC address, knowing its IP
address?
ARP table: each IP node (host,
ARP
router) on LAN has table
137.196.7.78
ARP
1A-2F-BB-76-09-AD • IP/MAC address mappings for
ARP some LAN nodes:
LAN < IP address; MAC address; TTL>
71-65-F7-2B-08-53
137.196.7.23
58-23-D7-FA-20-B0
137.196.7.14 • TTL (Time To Live): time after
ARP 0C-C4-11-6F-E3-98 which address mapping will be
137.196.7.88
forgotten (typically 20 min)
Link Layer: 6-8
ARP protocol in action
example: A wants to send datagram to B
• B’s MAC address not in A’s ARP table, so A uses ARP to find B’s MAC address
A broadcasts ARP query, containing B's IP addr
Ethernet frame (sent to FF-FF-FF-FF-FF-FF)
1 • destination MAC address = FF-FF-FF-FF-FF-FF
• all nodes on LAN receive ARP query C Source MAC: 71-65-F7-2B-08-53
Source IP: 137.196.7.23
ARP table in A Target IP address: 137.196.7.14
…
IP addr MAC addr TTL
TTL
A B
1
71-65-F7-2B-08-53 58-23-D7-FA-20-B0
137.196.7.23 137.196.7.14
D
Link Layer: 6-9
ARP protocol in action
example: A wants to send datagram to B
• B’s MAC address not in A’s ARP table, so A uses ARP to find B’s MAC address
ARP message into Ethernet frame
(sent to 71-65-F7-2B-08-53)
C Target IP address: 137.196.7.14
Target MAC address:
ARP table in A 58-23-D7-FA-20-B0
…
IP addr MAC addr TTL
TTL
A B
2
71-65-F7-2B-08-53 58-23-D7-FA-20-B0
137.196.7.23 137.196.7.14
2 B replies to A with ARP response,
giving its MAC address
D
Link Layer: 6-10
ARP protocol in action
example: A wants to send datagram to B
• B’s MAC address not in A’s ARP table, so A uses ARP to find B’s MAC address
C
ARP table in A
IP addr MAC addr TTL
TTL
137.196. 58-23-D7-FA-20-B0 500
A B
7.14
71-65-F7-2B-08-53 58-23-D7-FA-20-B0
137.196.7.23 137.196.7.14
3 A receives B’s reply, adds B entry
into its local ARP table
D
Link Layer: 6-11
Routing to another subnet: addressing
walkthrough: sending a datagram from A to B via R
focus on addressing – at IP (datagram) and MAC layer (frame) levels
assume that:
• A knows B’s IP address
• A knows IP address of first hop router, R (how?)
• A knows R’s MAC address (how?)
A B
R
111.111.111.111
74-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
111.111.111.112 111.111.111.110
CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 222.222.222.221
88-B2-2F-54-1A-0F
Link Layer: 6-12
Routing to another subnet: addressing
A creates IP datagram with IP source A, destination B
A creates link-layer frame containing A-to-B IP datagram
• R's MAC address is frame’s destination
MAC src: 74-29-9C-E8-FF-55
MAC dest: E6-E9-00-17-BB-4B
IP src: 111.111.111.111
IP dest: 222.222.222.222
IP
Eth
Phy
A B
R
111.111.111.111
74-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
111.111.111.112 111.111.111.110
CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 222.222.222.221
88-B2-2F-54-1A-0F
Link Layer: 6-13
Routing to another subnet: addressing
frame sent from A to R
frame received at R, datagram removed, passed up to IP
MAC src: 74-29-9C-E8-FF-55
IP src: 111.111.111.111
MAC dest: E6-E9-00-17-BB-4B
IP dest: 222.222.222.222
IP src: 111.111.111.111
IP dest: 222.222.222.222
IP IP
Eth Eth
Phy Phy
A B
R
111.111.111.111
74-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
111.111.111.112 111.111.111.110
CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 222.222.222.221
88-B2-2F-54-1A-0F
Link Layer: 6-14
Routing to another subnet: addressing
R determines outgoing interface, passes datagram with IP source A, destination B
to link layer
R creates link-layer frame containing A-to-B IP datagram. Frame destination address:
B's MAC address
MAC src: 1A-23-F9-CD-06-9B
MAC dest: 49-BD-D2-C7-56-2A
IP src: 111.111.111.111
IP dest: 222.222.222.222
IP
Eth
Phy
A B
R
111.111.111.111
74-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
111.111.111.112 111.111.111.110
CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 222.222.222.221
88-B2-2F-54-1A-0F
Link Layer: 6-15
Routing to another subnet: addressing
R determines outgoing interface, passes datagram with IP source A, destination B
to link layer
R creates link-layer frame containing A-to-B IP datagram. Frame destination address:
B's MAC address
MAC src: 1A-23-F9-CD-06-9B
transmits link-layer frame MAC dest: 49-BD-D2-C7-56-2A
IP src: 111.111.111.111
IP dest: 222.222.222.222
IP
IP Eth
Eth Phy
Phy
A B
R
111.111.111.111
74-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
111.111.111.112 111.111.111.110
CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 222.222.222.221
88-B2-2F-54-1A-0F
Link Layer: 6-16
Routing to another subnet: addressing
B receives frame, extracts IP datagram destination B
B passes datagram up protocol stack to IP
IP src: 111.111.111.111
IP dest: 222.222.222.222
IP
IP Eth
Eth Phy
Phy
A B
R
111.111.111.111
74-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
111.111.111.112 111.111.111.110
CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 222.222.222.221
88-B2-2F-54-1A-0F
Link Layer: 6-17