Unit2-Medium Access Control
Unit2-Medium Access Control
Transport
Network
Link
Physical
MAC is here!
Computer Networks
– Single Channel Assumption: There's only one channel; all stations are equivalent and can send and receive on that channel.
– Collision Assumption: If two frames overlap in any way time-wise, then that's a collision. Any collision is an error, and both frames must be retransmitted. Collisions are the only possible error.
– Continuous/ Slotted Time: Time is not in discrete chunks. Frame transmission can begin at any instant. Alternatively, in slotted, frame transmissions always begin at the start of a time slot. Any station can transmit in any slot (with a possible collision.)
– Carrier/No-Carrier Sense: Stations can tell a channel is busy before they try it. NOTE - this doesn't stop collisions.
Multiple Access Protocols: ALOHA
ALOHA
– Developed in Hawaii in the 1970s.
PURE ALOHA:
– Every station transmits whenever it wants to.
– Colliding frames are destroyed. The sender knows if its frame got destroyed using feedback property, and if so waits a random time and then retransmits.
– ANY overlap is a collision.
– Best efficiency if frames are same size.
– A contention system: Multiple users share a common channel that can lead to conflict.
Pure Aloha(2)
Multiple Access Protocols: ALOHA
ALOHA : Performance
– collision probability increases:
– pkt sent at t0 collide with other pkts sent in [t0-1, t0+1]
Random Waiting
times
Wasted time
Non-Persistent
CSMA
• Advantages of non-persistent CSMA:
• Less greedy than 1-persistent.
• It reduces the chances of collision because the stations wait a
random amount of time before transmitting.
• Token pass.
• There is only one token in the network.
• The token is passed through every node in the network.
• Only the node that has the token can transfer data.
Binary Countdown
1 2
3 4 5 6
A B C* D E* F* G H*
Slot 0: C*, E*, F*, H* (all nodes under node 0 can try), conflict
slot 1: C* (all nodes under node 1 can try), C sends
slot 2: E*, F*, H*(all nodes under node 2 can try), conflict
slot 3: E*, F* (all nodes under node 5 can try), conflict
slot 4: E* (all nodes under E can try), E sends
slot 5: F* (all nodes under F can try), F sends
slot 6: H* (all nodes under node 6 can try), H sends.
Motivation for Wireless MAC
• Can we apply media access methods from fixed networks?
• Example CSMA/CD
– Carrier Sense Multiple Access with Collision Detection
– send as soon as the medium is free, listen into the medium if a collision
occurs (original method in IEEE 802.3)
• Problems in wireless networks
– Signal strength decreases proportional to the square of the distance
– Sender would apply CS and CD, but the collisions happen at the
receiver (Hidden terminals)
– it might be the case that a sender cannot “hear” the collision, i.e., CD
does not work
Hidden and Exposed Terminals
• A wants to
transmit to B.
• C senses channel
– no idea A is
transmitting.
A B • C initiates
F transmission to F.
C
• Collision at B. – C
D and A are hidden
from each other.
• Exposed terminals A B C
– B sends to A, C wants to send to another terminal (not A/B)
– C has to wait, CS signals a medium in use
– but A is outside the radio range of C, therefore waiting is not necessary
– C is “exposed” to B
MACA - collision avoidance
• No carrier sense (CS)
• MACA (Multiple Access with Collision Avoidance) uses short signaling packets for collision avoidance
– RTS (request to send): a sender request the right to send from a receiver with a short RTS packet before it sends a data packet
– CTS (clear to send): the receiver grants the right to send as soon as it is ready to receive
• Signaling packets contain
– sender address
– receiver address
– packet size
• Variants of this method can be found in IEEE 802.11.
MACA examples
• MACA avoids the problem of hidden terminals
– A and C want to
send to B
– A sends RTS first
– C waits after receiving
CTS from B
RTS
CTS CTS
A B C
RTS RTS
CTS
A B C
Alternative Approach: MACAW
• No carrier sense, no collision detection
• Collision avoidance:
– Sender sends RTS
– Receiver sends CTS
– Sender sends DATA
– Receiver sends ACK
• Backoff mechanism:
– Exponential backoff with significant changes for improving fairness
and throughput
•
•
A sends out RTS and set a timer and waits for CTS
If A receives CTS before timer go to zero, OK! sends data packet
MACA
• Otherwise, A assumes there is a collision at B
• Double the backoff counter interval
• Randomly pick up a timer from [1,backoff counter]
• Send next RTS after timer go to zero
• B sends out CTS, then set a timer and waits for data packet
• If data packet arrives before timer go to zero, OK!
• Otherwise, B can do other things
• C overhears A’s RTS, set a timer which is long enough to allow A to receive CTS. After the timer goes to zero, C can do other things
• D overhears B’s CTS, set a timer which is long enough to allow B to receive data packet.
• E overhears A’s RTS and B’s CTS, set a timer which is long enough to allow B to receive data packet.
• RTS and CTS can also contain info to allow sender A to adjust power to reduce interference
Interconnecting LANs
Q: Why not just one big LAN?
• Limited amount of supportable traffic: on single LAN, all stations must share bandwidth
• limited length: 802.3 (Ethernet) specifies maximum cable length
• large “collision domain” (can collide with many stations).
Repeater Ethernet
Bridge
Router
Token- X.25
ring Network
Gateway
Hubs/Repeaters
• Physical Layer devices: essentially repeaters operating at
bit levels: repeat received bits on one interface to all other
interfaces
• Hubs can be arranged in a hierarchy (or multi-tier design),
with backbone hub at its top
Collison Domain
Hubs (more)
• Each connected LAN referred to as LAN segment
• Hubs do not isolate collision domains: node may collide
with any node residing at any segment in LAN
• Hub Advantages:
– simple, inexpensive device
– portions of the Multi-tier Hub LAN continue to operate if one hub
malfunctions
– extends maximum distance between node pairs (100m per Hub)
• Hub Limitations:
•single collision domain results in no increase in max throughput
multi-tier throughput same as single segment throughput
•cannot connect different Ethernet types (e.g., 10BaseT and
100baseT)
Bridges
• Link Layer devices: operate on Ethernet frames, examining frame header and selectively forwarding frame based on its destination.
• Bridge isolates collision domains since it buffers frames.
• When frame is to be forwarded on segment, bridge uses CSMA/CD to access segment and transmit.
• Bridge advantages:
– Isolates collision domains resulting in higher total max throughput, and does not limit the number of nodes nor geographical coverage.
– Can connect different type Ethernet since it is a store and forward device
Collison
Domain-2
Collison Domain-1 Collison Domain-3
Interconnection Without Backbone
Switch
Hub
Switch ports
Twisted pair
Bridge Learning: example
Suppose C sends frame to D and D replies back with
frame to C
C 1
C sends frame to bridge
bridge notes that C is on port 1 in the filtering table
bridge has no info about D, so floods to all the LANs
Nodes will compare the destination address of the
frame
frame received by D
Bridge Learning: example
C 1
D 2
D generates reply to C, sends
bridge sees frame from D
bridge notes that D is on interface 2
bridge knows C on interface 1, so selectively
forwards frame out via interface 1
Bridge Operation
bridge procedure(in_MAC, in_port,out_MAC)
Set filtering table (in_MAC) to in_port /*learning*/
lookup in filtering table (out_MAC) receive out_port
if (out_port not valid) /* no entry found for destination */
then flood; /* forward on all but the interface on
which the frame arrived*/
1 S4
S1 3 S4
1 1 S3
A 4 S2 2 Addres Port
F s
1 D I
B C C 1
E G H
I 3
S3
Q: show switch tables and packet forwarding in Addres Port
s
S1, S2, S3, S4 C 1
S2 I 2
Addres Port
s
C 1
The Danger of Loops
CC DD
a) <Src=AA, Dest=DD>
b) This continues to infinity
– How do we stop this?
c) Remove loops from the Hub
topology
Port 2 Port 2
– Without physically unplugging cables
AA 12 AA 12
d) 802.1 uses an algorithm to Port 1 Port 1
build and maintain a
spanning tree for routing Hub
AA BB
Loops and Routing
N S6
P
S5 O
K
L M S1
S2 S4
A S3
F I
B C D
E G H
There should be only one path exist from the Source to Destination to avoid the
loops at the data link layer.
Spanning Tree Definition
1 2 3 4 6 2
5 3
4 1
6 7 7
5
7
• Bridges exchange Configuration Bridge Protocol Data Units (BPDUs) to build the tree
– Used to elect the root bridge
– Calculate shortest paths
– Locate the next hop closest to the root, and its port
– Select ports to be included in the spanning trees
5
8
Definitions
• Bridge ID (BID) = <Random Number>
• Root ID: bridge with the lowest BID in the tree.
• Path Cost: cost (in hops) from a transmitting bridge to the root
• Each port on a bridge has a unique Port ID.
• Root Port: port that forwards to the root on each bridge
• Designated Bridge: the bridge on a LAN that provides the minimal cost path to the root
– The designated bridge on each LAN is unique
5
9
Comparing BPDUs
BPDU1 BPDU2
B1:R1/Cost1 B2:R2/Cost2
0: 0/0 12:
12:12/0
0/1 3: 0/2
3/0
27: 27/0
27: 0/1 41: 41/0
41: 3/1
0/2
9: 3/2
0/3
9/0 68: 3/2
9/1
68: 68/0
0/3