Download presentation
Presentation is loading. Please wait.
1
EEC-484/584 Computer Networks Lecture 9 Wenbing Zhao wenbing@ieee.org (Part of the slides are based on materials supplied by Dr. Louise Moser at UCSB and Prentice-Hall)
2
2 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Outline Elementary Data Link Protocols Channel Allocation Problem Multiple Access Protocols
3
3 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex Stop and Wait Protocol Add flow control: receiver provide feedback Sender pseudo code LOOP forever FromHost (Sframe.info) /* get message from host */ Sframe.kind = data /* set up data frame with message */ SendFrame (Sframe) /* and transmit frame */ WaitEvent (event) /* STOP and WAIT for ack frame */ GetFrame (Rframe) /* get it and discard it */ ENDLOOP Only possible event is FrameArrival and type of frame received is ack.
4
4 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex Stop and Wait Protocol Receiver pseudo code LOOP forever WaitEvent (event) /* wait for FrameArrival */ GetFrame (Rframe) /* get the frame from receiver */ ToHost (Rframe.info) /* pass message to host */ Sframe.kind = ack /* build ack frame */ SendFrame (sframe) /* and transmit frame */ ENDLOOP Only possible event is FrameArrival and type of frame received is data.
5
5 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex Stop and Wait Protocol Effect of a damaged frame: passes a corrupt message to the host Effect of a lost message or ack: causes lockup - A waiting for ack from B and B waiting for data from A
6
6 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol for a Noisy Channel Dealing with lost of data frame with retransmission –Receiver: check event, if it is not FrameArrival ignore it –Sender: send data frame and if an ack is not received within a certain time retransmit it Need two new functions –StartTimer: starts an internal timer –StopTimer: stops the timer If the timer 'times out’ WaitEvent returns an event value of TimeOut
7
7 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol for a Noisy Channel Sender pseudo code LOOP forever FromHost (Sframe.info) /* get message from host */ Sframe.kind = data /* set up data frame with message */ REPEAT /* until ack arrives */ SendFrame (Sframe) /* and transmit frame */ StartTimer /* start the timre */ WaitEvent (event) /* stop and wait for ack frame */ UNTIL event = FrameArrival /* ack frame arrived ? */ StopTimer /* stop the timer */ GetFrame (Rframe) /* get ack frame and discard it */ ENDLOOP In this case event may be FrameArrival or TimeOut
8
8 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol for a Noisy Channel Receiver pseudo code LOOP forever REPEAT /* until frame OK */ WaitEvent(event) /* wait for FrameArrival */ GetFrame(Rframe) /* get the frame from receiver */ UNTIL event = FrameArrival /* data frame arrived ? */ ToHost(Rframe.info) /* pass message to host */ Sframe.kind = ack /* build ack frame */ SendFrame(Sframe) /* and transmit frame */ ENDLOOP In this case event maybe FrameArrival or ChSumErr
9
9 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol for a Noisy Channel Problem: duplicate delivery
10
10 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol for a Noisy Channel Problem: duplicate delivery
11
11 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol for a Noisy Channel Problem: duplicate delivery
12
12 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel Each frame must carry a sequence number Sender: sets up the seq number in the data frame and keeps transmitting it until it gets an ack Receiver: when it gets a data frame with a particular sequence number: –sends an acknowledgement frame –checks that the sequence number of the frame is the expected sequence number: if so it is passed to the host and the expected sequence number incremented else the frame is discarded
13
13 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel Sender psuedo code SeqSend = 0 LOOP forever FromHost(Sframe.info) Sframe.kind = data Sframe.seq = SeqSend REPEAT SendFrame (Sframe) StartTimer WaitEvent(event) UNTIL event FrameArrival SeqSend = SeqSend + 1 StopTimer GetFrame(Rframe) ENDLOOP /* initial sequence number */ /* get message from host */ /*set up data frame with message */ /* set up sequence number */ /* until ack arrives */ /* transmit frame */ /* start the timer */ /* STOP and WAIT for ack frame */ /* ack frame arrived? */ /* set up next sequence number */ /* stop the timer */ /* get it and discard it */ In this case event may be FrameArrival or TimeOut
14
14 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel Receiver pseudo code SeqExpected = 0 LOOP forever REPEAT WaitEvent (event) GetFrame (Rframe) UNTIL event = FrameArrival if (SeqExpected = Rframe.seq) { ToHost (Rframe. info) SeqExpected = SeqExpected + 1 } Sframe.kind = ack SendFrame (Sframe) ENDLOOP /* initial sequence number */ /* until frame OK */ /* wait for Frame Arrival */ /* get the frame from receiver */ /* frame OK? */ /* yes, frame expected? */ /* yes, pass message to host */ /* next sequence number */ /* build ack frame */ /* and transmit frame */ In this case event may be FrameArrival or ChSumErr
15
15 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel The sequence numbers for this protocol can be held in a single bit with a sequence of frames having the numbers 0 1 0 1 0 1 0 1 etc.
16
16 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel
17
17 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel
18
18 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel
19
19 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel This protocol still has a problem –Identify the problem –How to fix it?
20
20 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Medium Access Control Sublayer Broadcast channels often used on DLL –multiaccess or random access The channel allocation problem: Who gets to use the channel? –Static Channel Allocation –Dynamic Channel Allocation
21
21 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Static Channel Allocation FDM – Frequency Division Multiplexing –Frequency spectrum divided into logical channel –Each user has exclusive use of own frequency band TDM – Time Division Multiplexing –Time divided into slots each user has time slot –Users take turns in round robin fashion Problem: wasted bandwidth if user does not use his/her frequency band or timeslot
22
22 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Frequency Division Multiplexing
23
23 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Time Division Multiplexing T1 Carrier (1.544 Mbps)
24
24 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Model for Dynamic Channel Allocation N independent stations (also called terminals) Probability of a frame being generated in an interval t is t (arrival rate constant) Once a frame has been generated, the station is blocked until the frame is transmitted successfully
25
25 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Model for Dynamic Channel Allocation Single Channel shared by all stations Collision – event when two frames transmitted simultaneously and the resulting signal is garbled –All stations can detect collisions
26
26 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Model for Dynamic Channel Allocation Frame transmission time –Continuous Time – can begin at any instant –Slotted Time – always begin at the start of a slot Carrier sense or not –Carrier sense – stations can tell if the channel is busy. Do not send if channel is busy –No carrier sense – just go ahead and send
27
27 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Multiple Access Protocols ALOHA Carrier Sense Multiple Access Protocols Collision-Free Protocols Wireless LAN Protocols
28
28 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Pure ALOHA Let users transmit whenever they have data to send If frame destroyed (due to collision), sender waits random amount of time, sends again User does not listen before transmitting
29
29 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Pure ALOHA: Vulnerable Period Vulnerable period for a frame: A collision will happen if another frame is sent during this period 2 frame time
30
30 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Pure ALOHA Throughput for ALOHA systems
31
31 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Slotted ALOHA Idea: divide time into intervals, each interval corresponds to one frame –Station is permitted to send only at the beginning of next slot Vulnerable period is halved (1 frame time) –Probability of no collision in time slot = e -G –Throughput S = G e -G –Max occurs when G = 1, S = 2*0.184
32
32 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Carrier Sense Multiple Access When station has data to send, listens to channel to see if anyone else is transmitting If channel is idle, station transmits a frame Else station waits for it to become idle If collisions occurs, station waits random amount of time, tries again Also called 1-persistent CSMA –With probability 1 station will transmit if channel is idle
33
33 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao After a station starts sending, it takes a while before 2nd station receives 1st station ’ s signal –2nd station might start sending before it knows that another station has already been transmitting If two stations become ready while third station transmitting –Both wait until transmission ends and start transmitting, collision results Carrier Sense Multiple Access: Collision Still Possible
34
34 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao p-persistent CSMA: Reduce the Probability of Collision Sense continuously, but does not always send when channel is idle –Applicable for slotted channels When ready to send, station senses the channel –If channel idle, station transmits with probability p, defers to next slot with probability q = 1-p –Else (if channel is busy) station waits until next slot tries again –If next slot idle, station transmits with probability p, defers with probability q = 1-p –…–…
35
35 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Non-Persistent CSMA Does not sense continuously, send if it senses the channel is idle Before sending, station senses the channel –If channel is idle, station begins sending –Else station does not continuously sense, waits random amount of time, tries again
36
36 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Persistent and Nonpersistent CSMA Improves over ALOHA because they ensure no station to transmit when it senses channel is busy
37
37 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao CSMA with Collision Detection If two stations start transmitting simultaneously, both detect collision and stop transmitting Minimum time to detect collision = time for signal to propagate
38
38 Spring Semester 2007EEC-484/584: Computer NetworksWenbing Zhao Contention Period: Minimum Time to Detect Collision Let the time for a signal to propagate between the two farthest stations be For station to be sure it has channel and other stations will not interfere, it must wait 2 without hearing a collision (not as you might expect) –At t 0, station A begins transmitting –At t 0 + - , B begins transmitting, just before A ’ s signal arrives –B detects collision and stops –At t 0 + - + (t 0 +2 - ), A detects collision A B
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.