2.5 reliable transmission

60
1 2.5 Reliable Transmission Acknowledgements & Timeouts Stop-and-Wait Sliding Window

Upload: carson

Post on 24-Feb-2016

55 views

Category:

Documents


0 download

DESCRIPTION

2.5 Reliable Transmission. Acknowledgements & Timeouts Stop-and-Wait Sliding Window. A link level protocol that wants to deliver frames reliably must somehow recover from those discarded (lost) frames This is usually accomplished using a combination of two mechanisms - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 2.5 Reliable Transmission

1

2.5 Reliable Transmission Acknowledgements & Timeouts Stop-and-Wait Sliding Window

Page 2: 2.5 Reliable Transmission

2

A link level protocol that wants to deliver frames reliably must somehow recover from those discarded (lost) frames

This is usually accomplished using a combination of two mechanisms Acknowledgment (ACK)

an acknowledgment (ACK) is a small control frame that a protocol sends back to the sender to indicate the original frame was successfully delivered

Retransmit if the sender does not receive an acknowledgment after a

reasonable amount of time, then it retransmits the original frame

Page 3: 2.5 Reliable Transmission

3

Timeout this action of waiting a reasonable amount of time is

called a timeout Automatic repeat request (ARQ)

the general strategy of using acknowledgments and timeouts to implement reliable delivery is sometimes called automatic repeat request (ARQ)

Page 4: 2.5 Reliable Transmission

4

Acknowledgements & Timeouts The simplest ARQ scheme is the stop-and-wait

algorithm Stop-and-wait algorithm

after transmitting one frame, the sender waits for an acknowledgement (ACK) before transmitting the next frame

if the ACK does not arrive after a certain period of time, the sender times out and retransmits the original frame

Page 5: 2.5 Reliable Transmission

5

Timeline showing four different scenarios for the stop-and-wait algorithm the sending side is represented on the left the receiving side is depicted on the right time flows from top to bottom figure (a) to (d)

(a) shows the ACK is received before the timer expires

(b) and (c) show the original frame and the ACK, respectively, are lost

(d) shows the timeout fires too soon

Page 6: 2.5 Reliable Transmission

6

The “lost” means that the frame was corrupted while in transit, that this corruption was detected by an error code on the receiver, and that the frame was subsequently discarded

Page 7: 2.5 Reliable Transmission

7

Page 8: 2.5 Reliable Transmission

8

Suppose the sender sends a frame and the receiver acknowledges it, but the acknowledgment is either lost or delayed in arriving in both cases, the, sender times out and retransmits the original

frame, but the receiver will think that it is the next frame, since it correctly received and acknowledged the first frame

this has the potential to cause duplicate of a frame to be delivered to address this prob1em, the header for a stop-and-wait protocol

usually includes a 1-bit sequence number – i.e., the sequence number can take on the values 0 and 1 - and the sequence numbers used for each frame alternate

Page 9: 2.5 Reliable Transmission

9

Stop-and-wait algorithm with 1-bit sequence number the header for a stop-and-wait protocol includes a 1-bit

sequence number (0 or 1) when the sender retransmits frame 0, the receiver can

determine that it is seeing a second copy of frame 0 rather than the first copy of frame 1 and therefore can ignore it

Page 10: 2.5 Reliable Transmission

10

shortcoming it allows the sender to have only one outstanding

(un-ACKed) frame on the link at a time, and this may far below the link’s capacity

example a 1.5Mbps link with a 45-ms round-trip time delay × bandwidth product

45ms (RTT) × 1.5Mbps (link) = 67.5Kb (8KB)

Page 11: 2.5 Reliable Transmission

11

since the sender can send only one frame per RTT, and assuming a frame size of 1 KB, this implies a maximum sending rate bits per frame ÷ time per frame = (1024 × 8) ÷ 0.045 = 182 Kbps or about 1/8th (= (182 ÷ 1024) ÷ 1.5) link’s

capacity

Page 12: 2.5 Reliable Transmission

12

Sender Receiver

Frame 0

Frame 1

Frame 0

ACK 0

ACK 1

ACK 0

Timeline for stop-and-wait with 1-bit sequence number

Page 13: 2.5 Reliable Transmission

13

Keeping the pipe full to use the link fully, we’d like the sender to be able to

transmit up to eight frames before having to wait for an acknowledgment (consider the 1/8th link’s utilization in the example)

the significance of the bandwidth × delay product is that it represents the amount of data that could be in transit

we would like to be able to send this much data without waiting for the first acknowledgment (ie., keeping the pipe full)

Page 14: 2.5 Reliable Transmission

14

Sliding Window Allow multiple outstanding (un-ACKed) frames Upper bound on un-ACKed frames, called window

Page 15: 2.5 Reliable Transmission

15

SW: Sender Assign a sequence number (SeqNum) to each frame Maintain three state variables

send window size (SWS) the upper bound on the number of outstanding

(unacknowledged) frames that the sender can transmit

last acknowledgment received (LAR) the sequence number of the last acknowledgment

received last frame sent (LFS)

the sequence number of the last frame sent

Page 16: 2.5 Reliable Transmission

16

Maintain invariant: LFS - LAR≦SWS

When an ACK arrives, the sender moves LAR to the right, thereby allowing the sender to transmit another frame

The sender associates a timer with each frame it transmits, and it retransmits the frame should the timer expire before an ACK is received

The sender has to be willing to buffer up to SWS frames since it must be prepared to retransmit them until they are acknowledged

< SWS

LAR LFS

■ ■ ■ ■ ■ ■ ─

Page 17: 2.5 Reliable Transmission

17

SW: Receiver Maintain three state variables

receive window size (RWS) the upper bound on the number of out-of-order

frames that the receiver is willing to accept largest frame acceptable (LAF)

the sequence number of the largest-acceptable frame last frame received (LFR)

the sequence number of the last frame received

Page 18: 2.5 Reliable Transmission

18

Maintain invariant: LAF - LFR ≦ RWS

Frame SeqNum arrives if LFR < SeqNum ≦ LAF then accept (within the

receiver’s window) if SeqNum ≦ LFR or SeqNum > LAF then

discarded (outside the receiver’s window)

RWS

LFR LAF

■ ■ ■ ■ ■ ■

< ─

Page 19: 2.5 Reliable Transmission

19

Let SeqNumToAck denote the largest sequence number not yet acknowledged, such that all frames with sequence numbers less than or equal to SeqNumToAck have been received the receiver acknowledges the receipt of

SeqNumToAck, even if higher-numbered packets have been received

this acknowledgement is said to be cumulative(漸增 ) sets LFR = SeqNumToAck & adjusts LAF = LFR +

RWS

Page 20: 2.5 Reliable Transmission

20

Example suppose LFR = 5 (i.e., the last ACK the receiver sent

was for sequence number 5), and RWS = 4 this implies that LAF = 9 should frames 7 and 8 arrive, they will be buffered

because they are within the receiver’s window no ACK needs to be sent since frame 6 is yet to arrive frames7 and 8 are said to have arrived out of order

Page 21: 2.5 Reliable Transmission

21

should frame 6 then arrive perhaps it was lost and had to be retransmitted, or perhaps it

was simply delayed - the receiver acknowledges frame 8, bumps LFR to 8, and sets LAF to 12

if frame 6 was in fact lost then a timeout will have occurred at the sender, causing it to

retransmit frame 6

Page 22: 2.5 Reliable Transmission

22

When a timeout occurs, the amount of data in transit decreases since the sender is unable to advance its window until frame 6 is acknowledged this means that when packet losses occur, this scheme is

no longer keeping the pipe full Early detection of packet losses

giving more information to the sender makes it potentially easier for the sender to keep the pipe full, but adds complexity to the implementation

Page 23: 2.5 Reliable Transmission

23

sol-1 the receiver could send a negative acknowledgment (NAK) for

frame 6 as soon as frame 7 arrived (adds additional complexity to the receiver)

sol-2 send additional acknowledgments of frame 5 when frames 7

and 8 arrived, e.g., a sender can use duplicate ACKs as a clue that a frame was lost

sol-3 selective acknowledgment: the receiver acknowledges

exactly those frames it has received, rather than just the highest-numbered frame received in order, e.g., the receiver could acknowledge the receipt of frames 7 and 8

Page 24: 2.5 Reliable Transmission

24

Send window size selected according to how many frames we want to have

outstanding on the link at a given time SWS is easy to compute for a given delay × bandwidth

product

Page 25: 2.5 Reliable Transmission

25

Receive window size the receiver can set RWS to whatever it wants RWS = 1

the receiver will not buffer any frames that arrive out of order

RWS = SWS the receiver can buffer any of the frames the sender

transmits RWS > SWS

makes no sense, it’s impossible for more than SWS frames to arrive out of order

Page 26: 2.5 Reliable Transmission

26

Sequence Number Space SeqNum field is finite; sequence numbers wrap

around (折回 ) Sequence number space must be larger then number

of outstanding frames, e.g. stop-and-wait (1-bit): allows 1 outstanding frame

at a time and has two distinct sequence numbers (0 &1)

a 3-bit field: allows 7 outstanding frame at a time and has 8 distinct sequence numbers (0..7)

Page 27: 2.5 Reliable Transmission

27

Is SWS ≦ MaxSeqNum-1 (MaxSeqNum is the number of available sequence numbers) correct? if RWS = 1, then MaxSeqNum SWS+1≧ is correct

[the receiver will not buffer any frames that arrive out of order] if RWS=SWS, then MaxSeqNum SWS+1≧ is incorrect

example (MaxSeqNum=8 & SWS=7) assumption

3-bit SeqNum field (sequence numbers 0..7) SWS=RWS=7

Scenario (we want to avoid this) the sender transmits frames 0..6, successfully arrive, but ACK

lost the receiver is now expecting frames 7, 0..5 (sequence

numbers wrap around) the sender times out and sends 0..6

Page 28: 2.5 Reliable Transmission

28

The sending window size can be no more than half as big as the number of available sequence numbers when RWS=SWS SWS <(MaxSeqNum+1)/2

General rule for arbitrary values of RWS and SWS MaxSeqNum SWS+RWS≧

Implementation of Sliding Window (pp. 109-114)

Page 29: 2.5 Reliable Transmission

29

Frame Order and Flow Control Sliding window protocol can be used to serve three

different roles reliably deliver frames across an unreliable link (the

core function of the algorithm) preserve the order in which frames are transmitted

this is easy to do at the receiver - since each frame has a sequence number, the receiver just makes sure that it does not pass a frame up to the next-higher-level protocol until it has already passed up all frames with a smaller sequence number

i.e., the receiver buffers out-of-order frames

Page 30: 2.5 Reliable Transmission

30

support flow control a feedback mechanism by which the receiver is able to

throttle the sender keep the sender from overrunning the receiver, that is, from

transmitting more data than the receiver is able to process this is usually accomplished by augmenting the sliding

window protocol so that the receiver not only acknowledges frames it has received, but also informs the sender of how many frames it has room (free buffer space) to receive

Page 31: 2.5 Reliable Transmission

31

Concurrent Logical Channels

Concurrent logical channels multiplex several logical channels onto a single point-to-

point link and to run the stop-and-wait algorithm on each of these logical channels

maintain 3 bits of state for each channel channel busy (yes/no) current sequence number out next sequence number in

example: ARPANET

Page 32: 2.5 Reliable Transmission

32

2.6 Ethernet (802.3) History

developed by Xerox Palo Alto Research Center (PARC) in mid-1970s

roots in Aloha packet-radio network 10 Mbps Ethernet is standardized by Xerox, DEC,

and Intel in 1978 Ethernet is standardized as IEEE 802.3

Page 33: 2.5 Reliable Transmission

33

Ethernet a family of frame-based computer networking

technologies for local area networks (LANs) originally used a shared coaxial cable winding

around a building or campus to every attached machine

a working example of the carrier sense, multiple access with collision detection (CSMA/CD) governed the way the computers shared the channel

Page 34: 2.5 Reliable Transmission

34

carrier sense means that all the nodes can distinguish

between an idle and a busy link collision detect

means that a node listens as it transmits and can therefore detect when a frame it is transmitting has interfered (collide) with a frame transmitted by another node

Page 35: 2.5 Reliable Transmission

35

a multiple-access network meaning that a set of nodes send and receive frames over a shared link

Ethernet can be thought of as being like a bus that has multiple stations plugged into it

data rates Ethernet: 10 Mbps Fast Ethernet: 100 Mbps Gigabit Ethernet: 1,000 Mbps

Page 36: 2.5 Reliable Transmission

36

Physical Properties Ethernet segment

implemented on a coaxial cable of up to 500m (impedance of 50-ohm)

this cable is similar to the type used for cable TV, except cable TV’s 75 ohms

Host connects to the Ethernet segment by tapping into it;

taps must be 2.5m apart

Page 37: 2.5 Reliable Transmission

37

Transceiver a small device directly attached to the tap detects when the line is idle and drives the signal

when the host is transmitting receives incoming signals connects to an Ethernet adaptor, which is plugged

into the host Adaptor

all the logic that makes up the Ethernet protocol is implemented in the adaptor

Page 38: 2.5 Reliable Transmission

Ethernet transceiver and adaptor

Page 39: 2.5 Reliable Transmission

39

Repeater multiple Ethernet segments can be joined together

by repeaters a device that forwards digital signals, much like an

amplifier forwards analog signals no more than four repeaters may be positioned

between any pair of hosts an Ethernet has a total reach of only 2,500m an Ethernet is limited to supporting a maximum of

1,024 hosts

Page 40: 2.5 Reliable Transmission

Ethernet repeater

Page 41: 2.5 Reliable Transmission

41

Example of Ethernet repeater use just two repeaters between any pair of hosts a segment running down the spine of a building

with a segment on each floor

Page 42: 2.5 Reliable Transmission

42

Any signal placed on the Ethernet is broadcast over the entire network signal

propagated in both directions repeater

forward the signal on all ongoing segments

Page 43: 2.5 Reliable Transmission

43

terminator attached to the end of each segment absorb the

signal and keep it from bouncing back and interfering with trailing signals

Encoding Ethernet uses the Manchester encoding

scheme

Page 44: 2.5 Reliable Transmission

44

Coax cable evolution 50-ohm coax cable thick-net 10Base5

10 means 10Mbps Base means baseband system 5 means that a given segment can be no longer

than 500m

Page 45: 2.5 Reliable Transmission

45

thin-net 10Base2 10Mbps 2 means that a given segment can be no longer

than 200m 10BaseT

10Mbps T means twisted pair (Category 5 twisted pair) limited to under 100m in length

Page 46: 2.5 Reliable Transmission

46

100BaseT 100Mbps Category 5 twisted pair limited to under 100m in length

1000BaseT 1000Mbps Category 5 twisted pair limited to under 100m in length

Page 47: 2.5 Reliable Transmission

47

Access Protocol Media access control (MAC)

control access to the shared Ethernet link implemented in hardware on the network adaptor

Ethernet is a bit oriented framing protocol Frame format

Preamble (64 bits) allows the receiver to synchronize with the

signal a sequence of alternating 0s and 1s

Destaddr

64 48 32CRCPreamble Src

addr Type Body1648

Page 48: 2.5 Reliable Transmission

48

Dest addr & Src addr (48 + 48 bits) both the source and destination hosts are

identified with a 48-b address Type (16 bits)

demultiplexing key it identifies to which of possibly many higher-

level protocols this frame should be delivered Body

46 (used to detect a collision) to 1,500 bytes of data

Destaddr

64 48 32CRCPreamble Src

addr Type Body1648

Page 49: 2.5 Reliable Transmission

49

CRC (32 bits) each frame includes a 32-bit CRC

from the host perspective, an Ethernet frame a 14-byte header two 6-byte addresses a 2-byte type field

the sending adaptor attaches the preamble, CRC, and postamble before transmitting, and the receiving adaptor removes them

Destaddr

64 48 32CRCPreamble Src

addr Type Body1648

Page 50: 2.5 Reliable Transmission

50

Ethernet a bit-oriented framing protocol

Destaddr

64 48 32CRCPreamble Src

addr Type Body1648

Ethernet frame format

Page 51: 2.5 Reliable Transmission

51

Addresses The address belongs to the adaptor, not the host, it is

actually burned into ROM Addresses

a sequence of six numbers (48 bits, hexadecimal digits) separated by colons, example: 8:0:2b:e4:b1:2 00001000 00000000 00101011 11100100 10110001 00000010

unique: 48-bit unicast address assigned to each adapter broadcast: all 1s multicast: first bit is 1

Page 52: 2.5 Reliable Transmission

52

Each frame transmitted on an Ethernet is received by every adaptor connected to that Ethernet each adaptor recognizes those frames addressed to its

address and passes only those frames on to the host an adaptor can also be programmed to run in

promiscuous mode, in which case it delivers all received frames to the host, but this is not the normal mode

Page 53: 2.5 Reliable Transmission

53

Summary an Ethernet adaptor receives all frames and accepts

frames addressed to its own address frames addressed to the broadcast address frames addressed to a multicast address, if it has

been instructed to listen to that address all frames, if it has been placed in promiscuous

mode an Ethernet adaptor passes to the host only the frames

that it accepts

Page 54: 2.5 Reliable Transmission

54

Transmit Algorithm

When the adaptor has a frame to send if line is idle

send immediately (no negotiation with the other adaptors)

upper bound message size of 1500 bytes (means that the adaptor can occupy the line for only a fixed length of time)

must wait 9.6μs after the end of one frame before beginning to transmit the next frame

if line is busy wait until idle and transmit immediately

Page 55: 2.5 Reliable Transmission

55

Ethernet is said to be a 1-persistent protocol because an adaptor with a frame to send transmits with probability 1 whenever a busy line goes idle

In general, a p-persistent algorithm transmits with probability 0 ≦ p ≦1 after a line becomes idle, and defers with probability q = 1- p (there might be multiple adaptors waiting for the busy line to become idle, and we don’t want all of them to begin transmitting at the same time)

Page 56: 2.5 Reliable Transmission

56

Because there is no centralized control it is possible for two (or more) adaptors to begin transmitting at the same time, either because both found the line to be idle or because both had been waiting for a busy line to become idle. When this happens, the two (or more) frames are said to collide on the network

Page 57: 2.5 Reliable Transmission

57

If an adaptor detects that its frame is colliding with another transmits a 32-bit jamming sequence and then stop

transmitting frame a transmitter will minimally send “64-bit preamble plus

32-bit jamming sequence = 96 bits (runt frame)” in the case of collision

The worst case scenario (the two hosts are at opposite ends of the Ethernet) transmitter needs to send 512 bits to make sure that the

frame it just sent did not collide with another frame 512 bits is the minimum frame size: 64 bytes (14

bytes header + 46 bytes of data + 4 bytes of CRC)

Page 58: 2.5 Reliable Transmission

58

scenario(a) A sends a frame at time t(b) the first bit of A’s frame arrives at B at time t+d (d is link

latency)(c) suppose an instant before host A’s frame arrives, B still

sees an idle line and begins transmitting at time t+d and collides with A’s frame (this collision is detected by host B)

(d) B’s runt (32-bit jamming sequence) frame arrives at A at time t+2d

A will not know that the collision occurred until B’s runt reaches it

A must transmit for 2×d to be sure that it detects all possible collisions

(a)

(b)

(c)

A B

A B

A B

A B

(d)

Page 59: 2.5 Reliable Transmission

59

(a)

(b)

(c)

A B

A B

A B

A B

(d)

Worst-case scenario: (a) A sends a frame at time t; (b) A’s frame arrives at B at time t + d; (c) B begins transmitting at time t + d and collides with A’s frame; (d) B’s runt (32-bit) frame arrives at A at time t + 2d

Page 60: 2.5 Reliable Transmission

60

round-trip delay and try again each time it tries to transmit but fails, the adaptor

doubles the amount of time it waits before trying again (exponential backoff) 1st collision delay : 0 or 51.2μs (round-trip delay,

which on a 10-Mbps Ethernet corresponds to 512 bits), selected at random

2nd collision delay: 0, 51.2, 102.4, or 153.6μs, selected at random

nth collision delay: k x 51.2μs, for randomly selected k=0..2n – 1 (min {n, 10})

adaptor typically retry up to 16 times