Download presentation
Presentation is loading. Please wait.
Published byGavin O’Connor’ Modified over 9 years ago
1
© Janice Regan, CMPT 128, 2007-2012 0 CMPT 371 Data Communications and Networking LANs 2: MAC protocols
2
Janice Regan © 2005-2012 1 Point to point link Direct connection between two hosts, medium connecting hosts is 100% available to the two endpoint hosts
3
Janice Regan © 2005-2012 2 Broadcast link The medium connecting the hosts is shared between many hosts. Each time a frame is sent (broadcast or unicast) every other host attached to the medium receives a copy A multiple access protocol is used to define how that sharing is accomplished
4
Janice Regan © 2005-2012 3 Medium Access Control LAN is a single shared broadcast channel Transmission of a frame may be initiated at any time, or only at the beginning of defined ‘slots’ Two or more simultaneous transmissions by nodes on the LAN will collide and cause interference only one node can successfully send at any given time communication about channel sharing must use channel itself stations may or may not be able to ‘sense’ a transmission from another station on the network Need a distributed set of procedures that determines how to share the channel. Such procedures are defined in a Medium Access Control Protocol (MAC Protocol)
5
Janice Regan © 2005-2012 4 MAC Protocols Static Channel Allocation or Channel Partitioning divide channel into time slots, frequency bands, code channels, may use a round robin technique allocate one to each node for exclusive use Contention or Random Access Allow and recover from collisions for bursty traffic Straightforward to implement adequate for light to moderate loads Taking turns protocols tightly coordinate shared access to avoid collisions Reservation methods poll stations each cycle, but reserve transmission slots of for stations with data to transmit. (slightly more overhead than round robin, but improved efficiency due to avoiding empty slots)
6
Janice Regan © 2005-2012 5 Channel Partitioning MAC: TDMA TDMA: time division multiple access (used for some cellular telephones ) access to channel in “cycles" each station gets fixed length slot (length = pkt trans time) in each cycle unused slots go idle, channel utilization may be low example: 6-station LAN Frame 1: 1,2,4,5 have pkt, slots 2 and 6 idle Frame 2: 2,5,6 have pkt, slots 1,3,4 idle DDDDDDD 1 frame (6 slots)
7
Janice Regan © 2005-2012 6 Channel Partitioning MAC: FDMA FDMA: frequency division multiple access (used for some cellular telephones ) Spectrum divided into frequency bands Each station assigned a fixed frequency band unused transmission time in frequency bands go idle example: 6-station LAN Frame 1: 1,2,4,5 have pkt, slots 2 and 6 idle Frame 2: 2,5,6 have pkt, slots 1,3,4 idle Spectrum of frame 1 (6 bands)
8
Janice Regan © 2005-2012 7 Channel Partitioning (CDMA) CDMA (Code Division Multiple Access) Used mostly in wireless broadcast channels such as cellular phones All users share same frequency band. Information from each user is spread throughout that frequency band Each user has their own orthogonal Walsh code ‘chipping’ sequence to encode data. encoded signal = (original data) X (Walsh code) Encoded signals from each channel are added, the summed signal is transmitted The orthogonal property of Walsh codes guarantees that (ignoring transmission errors) multiplying the received signal by a Walsh code will extract the data for the channel encoded using that Walsh code from the received (summed) signal. Decoded signal = (received summed signal X Walsh code)
9
Janice Regan © 2005-2012 8 Random Access Protocols When node has packet to send it transmits that packet at full channel data rate R. When two or more nodes transmit at the same time a collision occurs A Random Access MAC protocol specifies how to detect and recover from collisions Examples of Random Access MAC Protocols: ALOHA, Slotted ALOHA CSMA, CSMA/CD
10
Janice Regan © 2005-2012 9 Pure (unslotted) ALOHA No synchronization, simplest possible approach When frame arrives at a station transmit immediately Listen for an ACK for twice the maximum propagation time between stations in the network plus a small additional time Retransmit if no ACK is received A frame of duration (transmission time) 1 sent by station i at time t 0. It will collide with frames sent by other stations in the time interval [t 0 -1,t 0 +1 ] t0t0 t 0 -1t 0 +1 Packet from station i Packet from other station Packet from other station Any packet starting between t 0 and t 0 +1 collides Any packet starting between t 0 and t 0 -1 colides
11
Janice Regan © 2005-2012 10 Pure Aloha efficiency Frames are generated at a rate of N per frame transmission time. If N>1 frames are being generated at a rate faster than they can possibly be transmitted (even in ideal conditions) Frames may also be retransmitted. The average number of frames (original and retransmitted) transmitted in one frame transmission time is G. Let P 0 be the probability that the frame does not suffer a collision is P 0 =e -2G (for a Poisson distribution) The throughput, S, (or efficiency) is the product of P 0 and the load presented G S=Ge -2G At G = 0.5 the maximum value of S (S=0.18) is attained THE BEST WE CAN HOPE FOR IS 18%
12
Janice Regan © 2005-2012 11 Slotted ALOHA All nodes are synchronized so time can be divided into fixed length slots, with the first slot beginning at a reference time Duration of a slot is transmission time of 1 frame When 2 or more nodes transmit in the same slot, all nodes detect the resulting collision A frame begins transmission at the beginning of a slot, After a collision the node retransmits frame. The probability that the frame will be retransmitted in each subsequent slot will be P (until retransmission occurs)
13
Janice Regan © 2005-2012 12 Slotted ALOHA single node can continuously transmit at full rate of channel Slots in nodes need to be in sync between nodes Frames that overlap do so completely, reducing contentions Collisions cause frequent retransmission, idle slots Nodes may be able to detect collision in less than time to transmit packet so extra time is spent transmitted packets known to be corrupted Node 1 Node 4 Node 1 Node 4 Node 3 Node 2 Node 4 Node 2 Node 3 Node 1 collision Retransmit success Retransmit success Retransmit success Retransmit success
14
Janice Regan © 2005-2012 13 Slotted Aloha efficiency Utilization is the number of successful transmissions as a fraction of slots available Let P 0 be the probability that the frame does not suffer a collision is P 0 =e -2G (for a Poisson distribution) The probability of transmission on the k th try is P k = P( k-1 collisions) * P( successful transmission) = ( 1-e -2G ) k-1 e -2G The expected number of transmissions for each packet is The maximum throughput is then the presented load time the expected number of retransmissions S=Ge -G is a minimum, that is G=1 The channel used for successful transmissions no more than 37% of time
15
Janice Regan © 2005-2012 14 Carrier Sense Multiple Access CSMA: listen (sense channel) before transmit: If channel sensed idle: Transmit entire frame immediately If channel sensed busy: 1-persistant CSMA: Listen until the channel is available then the station transmits as soon as the medium is available (immediately with probability 1) Non-persistant CSMA: station waits a random time period and the checks the medium again, transmitting immediately if the channel is now free (better U but longer delays) P-persistant CSMA: Listen until the channel is available, then transmit with probability p. (Probability q=1-p that the station will wait one time period, usually the maximum propagation delay, to transmit) Channel is not sensed during transmission, whole packet is sent even if a collision occurs
16
Janice Regan © 2005-2012 15 CSMA collisions collisions can still occur: propagation delay means two nodes may not hear each other’s transmissions Consider node A starts transmitting packet 1 at time t 0. Node C starts transmitting packet 2 at time t 1. The propagation time from A to C is 2t 1 A B A C Time t 3 =2.5*t 1 A C Time t 2 =1.5*t 1 Collision detected at station B starting at time 2t 1 Collision has occurred but has not been detected C B B Collision may never detected at station A or station C Time t 3 =2*t 1
17
Janice Regan © 2005-2012 16 CSMA/CD (Collision Detection) A station has a packet to transmit, packets are long enough that transmission time is longer than the end to end propagation time in the network (otherwise becomes no more efficient the plain CSMA) If the medium is idle, transmit immediately If the medium is busy listen until the medium is available If a collision is detected, transmit a short jamming signal to inform all stations there has been a collision Then wait a random length of time (referred to as the backoff) and retransmit
18
Janice Regan © 2005-2012 17 Binary Exponential Backoff When a collision is detected, transmit a short jamming signal to inform all stations there has been a collision Then wait a length of time, L, chosen from a random distribution with mean, M. L is referred to as the backoff. After time L retransmit Each time a collision is detected for a retransmitted frame the mean of the random distribution is doubled. An L is chosen from the new distribution and the frame is retransmitted after time L. The doubling of the mean of the distribution continues for the first 10 retransmissions. For retransmission attempts 11 to 16 the random distribution remains the same. After 16 retransmissions the station gives up and reports an error
19
Janice Regan © 2005-2012 18 Collision Detection Collisions detected within short time ‘Short time’ For the detecting station is the propagation time from the sending station to the detecting station The sending station learns of the collision when the jamming signal reaches it, after a time equal to twice the propagation time. Easier in wired LANs: measure signal strengths, compare transmitted, received signals. Possible difficulties with attenuation along very long propagations paths, when transmitted signal powers may fall below detection levels. More difficult in wireless LANs: receiver shut off while transmitting Reduces channel wastage by reducing amount of time transmitting during contention conditions.
20
Janice Regan © 2005-2012 19 CSMA collisions and CSMA/CD Consider node A starts transmitting packet 1 at time t 0. Node C starts transmitting packet 2 at time t 1. The propagation time from A to C is 2t 1 A B A C t 3 =2*t 1 A C t 2 =1.5*t 1 Collision detected by A and C. station A and C send jamming signal Collision detected at stations B C B B t 3 =3*t 1 Collision has occurred but has not been detected D A D
21
Janice Regan © 2005-2012 20 CSMA collisions and CSMA/CD Consider node A starts transmitting packet 1 at time t 0. Node C starts transmitting packet 2 at time t 1. The propagation time from A to C is 2t 1 C A Collision detected by A and C. station A and C send jamming signal B t 3 =3*t 1 A and C. receive jamming signal B t 3 =5*t 1 D A C A jamming signal received by B and D B t 3 =4*t 1 D
22
Janice Regan © 2005-2012 21 MAC protocols Network Layer 802.2 Logical Link Control (LLC) 802.3 Ethernet Physical Layer 802.4 Token Ring 802.5 Token Bus 802.11 Wireless Data Link Layer
23
Janice Regan © 2005-2012 22 IEEE 802 Protocol Layers Stallings 2003: fig 15.5
24
Janice Regan © 2005-2012 23 MAC Frame Preamble: 7 octets of alternating 1’s and 0’s used to establish sychronization Start Frame Delimiter (SFD): The sequence 10101011 used to indicate the start of the frame. Destination address (DA): address of the station for which the frame is intended (MAC address of interface) Source address (SA): The address of the station that sent the frame Length/Type: Length of the LLC data field (<1500 octets), or the type of protocol (if not 802.3) Pad: added to make sure the transmission time of the packet is at least as long as the propagation time through the network (required for efficient use of CSMA/CD) FCS: 32 bit CRC
25
Janice Regan © 2005-2012 24 IEEE 802.3 (Ethernet MAC Frame) Stallings 2000: fig 14.2, 17.8 IEEE 802.11 (Wireless MAC Frame)
26
Janice Regan © 2005-2012 25 Taking turns MAC protocols channel partitioning MAC protocols: share channel efficiently and fairly at high load inefficient at low load due to ‘idle’ slots Random access MAC protocols efficient at low load: single node can fully utilize channel collision overhead increases with load Taking turns protocols look for best of both Poll, transmit only when polled or only when told by central station Use token passing (e.g. a token ring network)
27
Janice Regan © 2005-2012 26 Polling Eliminate collisions and empty frames Controlled by a central station which Sends a Poll message to start selected station transmitting Watches for the end of the data transmitted by the station (no signal on the link for some limiting time > round trip travel time between the central station and the polled station = delay time) Repeats the previous 2 steps until all hosts on the broadcast link have been polled Repeats the polling of the whole set of stations Addition overhead of delay time for each host, even if host has no data to transmit If master node fails, whole link fails
28
Janice Regan © 2005-2012 27 Example of Token Passing Token Ring: Governed by standard 802.5 Based on the use of a small frame called a token A station may only transmit when it has possession of a token Transmission is a three step process A station grabs the token as it passes (flipping token bit) The station transmits its frame The station reemits the token when both Transmission is complete The leading edge of the packet has returned to the transmitting station
29
Janice Regan © 2005-2012 28 IEEE 802.5 Frame Format Stallings 2000: fig 14.6
30
Janice Regan © 2005-2012 29 Token Ring Operation Transmission steps are as follows A station wishing to transmit waits until the token passes and flips the token bit in the access control field The station appends the rest of its packet after the ACR field The station continues to transmit until it has transmitted all its packets or the token holding timer expires. When the ACR field of the last transmitted frame returns the token bit is turned back on and the end data delimiter is appended A frame returning to the originating station uses the frame status field to differentiate between Destination station not active or does not exist (A=0,C=0) Destination station exists but frame not copied (A=1,C=0) Frame received (A=1,C=1)
31
Janice Regan © 2005-2012 30 Token Ring Operation Stallings 2000: fig 14.5
32
Janice Regan © 2005-2012 31 Token Ring Operation Stallings 2000: fig 14.5
33
Janice Regan © 2005-2012 32 Token Ring Operation Stallings 2000: fig 14.5
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.