arq (automatic repeat request)contents.kocw.net/kocw/document/2014/pusan/kimjongdeok/4.pdfstop and...

31
ARQ (Automatic Repeat reQuest)

Upload: ngodien

Post on 11-Jul-2019

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 2: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Error in Computer Network

Error in Communication: 보낸 것과 받은 것이 다른 것

2 different Binary Channel Models

Binary Channel이란 송신자 0과 1의 두 가지 Symbol만을 전송하는 채널

0

1

0

1

0

1

0

1

?𝑝

1 − 𝑝

𝑝

1 − 𝑝

𝑝

𝑝

1 − 𝑝

1 − 𝑝

Binary Symmetric Channel Binary Erasure Channel

0 1 1 0 0 1BSC

BEC

0 1 0 0 1 1

0 1 0 1

2

Page 3: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Error in Computer Network

Bit Level Error와 Packet Level Error로 일반적으로 분류

Bit Level Error – Bit 값이 0 1, 1 0

Link나 Channel 단위에서 발생

Packet Level Error – Packet이 소실 (Erased/Lost)

과도한 Bit Level Error가 발생하여 패킷을 복원하기 어려운 경우 하위 계층에서 제거

또는 네트워크 계층에서 혼잡(Congestion) 등으로 인해 스위치(라우터)가 수신한 Packet을

처리하지 못하여 Drop 시켜 발생하기도 함

2

N1 N2 N3Link

(Channel)Link

(Channel)

noise

13

Buffer(Queue) FullCongestion

3

2 1

2

11

2

3

3

Page 4: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Error Detection & Recovery

Error Detection

Bit Level Error – Error Detecting Code

• Parity Bit, CRC

Packet Level Error – Loss, Out of Order, Duplicate

• ARQ – Acknowledgement, Sequence Number

2 Approaches in Error Recovery

Retransmission

• 수신자 측에서 송신자 측으로 Feedback을 보내고

이를 기반으로 송신자가 문제가 된 데이터를 재전송

FEC (Forward Error Correction)

• 송신자가 데이터 외에 추가 정보 (Redundancy)를

보내 에러 발생 시 송신자로부터의 재전송 없이

추가 정보만으로 수신자가 자체 복구하는 방법

송신

수신

2 14 35

Q3

송신

수신

2 14 35R

3

4

Page 5: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

STOP AND WAIT PROTOCOL

Page 6: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

강의의 목표

Stop and Wait Protocol의 구성 요소와 동작 원리를 설명할 수 있다.

Network Delay를 구성하는 요소를 이해하고 설명할 수 있다.

컴퓨터 네트워크에서 Delay가 가변적인 이유와 그것이 통신 품질에

미치는 영향을 설명할 수 있다.

RTT(Round Trip Time)을 알 때 Stop and Wait Protocol의 성능을 구

할 수 있다.

교재 Chapter 7. Data Link Control Protocol

6

Page 7: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

ARQ

ARQ – Automatic Repeat reQuest

Packet Level Error Control Mechanism based on Retransmission

Error Detection

Positive Acknowledgment

Retransmission after Timeout

3 ARQ versions

1. Stop-and-Wait ARQ

2. Go-back-N ARQ ~ Sliding Window + Cumulative ACK

3. Selective Repeat ARQ ~ Sliding Window + Selective ACK

7

Page 8: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Stop and Wait

Source

Transmit Single frame and Wait for ACK

Receiving ACK, Transmits the next frame

If no ACK within Timeout, Retransmit

Receiver

If received frame damaged, discard it.

Otherwise, received a frame without damage, Transmits ACK

구성 요소

ACK, Timeout, Retransmission, SEQ Number, ACK Number

고려 사항

SEQ Number와 ACK Number는 왜 필요할까?

Timeout 값은 어떻게 설정하는 것이 좋을까?

8

Page 9: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Stop and Wait

*

Time Out

ACK

Time Out

Duplication

*

How to detect Duplication ?

Sequence Number

0 0 1

*

9

Page 10: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

0

*

0 0 0 1

*

2

Timeout

ACK

(A)

Duplication !Send ACK ?

Timeout(B)

Duplication !Send ACK ?

In case of Duplication, should we send ACK ?

Acknowledge Number

10

Page 11: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Stop and Wait – Pros and Cons

Simple

Inefficient

Ex) Frame Size = 1Kbyte, Link Bandwidth = 8Mbps, One-way Propagation

Delay = 10ms 일 때 Error가 발생하지 않을 경우 Stop and Wait의 최대 성능은 ?

(단 역방향으로는 별도의 Link를 사용하며 Propagation Delay는 동일하다)

11

Idle Period(Waste of Resource)

Page 12: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Network Delay (1)

Transmission Delay (전송 지연)

어떤 양의 신호를 보내는데 걸리는 시간

전송용량(대역폭)과 정보의 양에 의해 결정

전송지연 = 정보의 양 / 전송용량

Propagation delay (전파지연)

신호가 송신지에서 수신지까지 전파되는데 걸리는 시간

전송길이 및 빛의 속도에 의존

전파지연 = 전송길이 / 전파속도

예) 10 km 떨어진 곳에 수도관을 통해 100톤의 물을 전달하려고 한

다. 물의 유속은 시속 20 km이고, 수도관의 용량은 1분에 2톤을 처

리할 수 있다. 물 전달에 걸리는 시간을 구하라.

Processing Delay, Store and Forward Delay, Queueing Delay

12

Page 13: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Network Delay (2)

Time

Propagation Delay

Transmission Delay

13

Page 14: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Network Delay (3)

Time

Store and Forward Delay

Circuit Switching

Packet Switching

Queueing Delay

Queueing Delay

14

Page 15: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Network Delay 예제

Time

1

녹음장치

전송장치

재생장치

수신장치

전송용량 : 128Kbps

전송선 길이 = 200Km, 신호 속도: 2ⅹ 108m/sec

2

3

4

5

6

녹음 시작

Packetizaion/Frame Delay

1

2

3

4

5

6

1번 전송 시작

PropagationDelay

1

2

TransmissionDelay

1

2

1번수신 완료및 재생 시작

TotalDelay

3

4

5

3*

Delay Jitter

15

Page 16: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

SLIDING WINDOW PROTOCOL

Page 17: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

강의의 목표

Stop and Wait Protocol과 Sliding Window Protocol을 비교하여 설

명할 수 있다.

Sliding Window Protocol의 성능을 구할 수 있다.

Window 값이 미치는 영향을 이해하고 적절한 Window 값 설정을

위한 기본 개념을 이해한다.

Flow Control의 필요성을 이해하고 Sliding Window Protocol을 통

한 Flow Control의 핵심 원리를 설명할 수 있다.

17

Page 18: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Sliding Window Protocol

Window size W: Number of Frames that can be transmitted

without an ACK

Stop and Wait : W = 1

예) Stop and Wait의 예에서 에러가 전혀 발생하지 않고 모든 프레임에 대해 항

상 ACK을 보낸다고 할 때 최대 전송 속도를 얻기 위한 W의 크기는 ?

Sliding Window Protocol의 성능은?

0

W=3 2

1

1

2

0

1

1

3

2

0 1

1 0

3

0

1

2

2 1

2

3

12

18

Page 19: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Sliding Window Diagram

19

Page 20: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Example Sliding Window

20

Page 21: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Positive ACK / Negative ACK

Positive ACK

Negative ACK

0

1

21 3

32

4

*

??

0

N.3

21 3 4

*

3

3

Timeout

*

3

Timeout

5 6

*

N.3

7 0

21

Page 22: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Cumulative ACK / Selective ACK

Cumulative ACK

Selective ACK

0

1

21 3

32

4

*

5 6

4

*

4 4

Timeout

4

7

0

0

21 3

21

4

*

5 6

3

*

5 60 1

0210

321

532

4

22

Page 23: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Go Back N

Based on sliding window

Use window to control number of outstanding frames

If no error, ACK as usual with next frame expected

If error, reply with rejection

Discard that frame and all future frames until error frame received

Transmitter must go back and retransmit that frame and all subsequent

frames

Combination of Cumulative ACK and Negative ACK

23

Page 24: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Selective Repeat

Also called selective retransmission

Only lost frames are retransmitted

Subsequent frames are accepted by the receiver and buffered

Minimizes retransmission

Receiver must maintain large enough buffer

More complex login in transmitter

24

Page 25: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Flow & Congestion Control

Flow Control

keep sender from overrunning receiver

Congestion control

keep sender from overrunning network

Sender가 전송 속도를 조절하는 것.

(좁은 의미의) Flow Control과 Congestion Control을 구분하지 않고

이 둘을 결합하여 (넓은 의미의) Flow Control 이라고도 함

TCP는 Flow/Congestion Control 기능이 있지만 UDP는 없음

25

NetS RSender전송 속도 조절

Page 26: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

How to control the transmitting speed?

Rate Based Approach

(X)bps의 속도로 전송하라; X를 조절;

구현을 위해 Timer 등이 필요.

Window Based Approach

추가로 (X)bytes 까지 전송할 수 있다; X를 조절;

Counter 등으로 간단하게 실현 가능

TCP를 포함하여 많은 실용 프로토콜에서 쓰임.

Sliding Window Protocol

Error Control + Flow Control

Sliding Window Protocol의 Throughput과 Window 크기 W의 관계는?

Window의 크기 W를 조정하면 전송 속도를 조정할 수 있다.

• 예) 수신자의 버퍼 크기가 부족하면 W를 줄이고 충분하면 W를 늘이고

• 예) 네트워크가 혼잡하면 W를 줄이고 여유가 있으면 W를 늘이고

26

Page 27: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Error and Flow Control in TCP

전송 계층인 TCP에서도 Error 및 Flow Control 필요

그 방식은 본 장에서 소개한 기술들을 기반으로 함

Sliding Window ARQ / Similar to Go back N

Flow Control – Advertised Window0 4 10 16 31

Urgent Pointer

Source Port Destination Port

Sequence Number

Acknowledgement Number

DataOffset Reserved

URG

ACK

PSH

RST

SYN

FIN

Window

Checksum

Options(If any) + Padding

Data

20 bytes

27

Page 28: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Flow Control in TCP

TCP에서 수신자는 송신자가 보낸 패킷을 수신하면 ACK Flag을 Setting한

패킷을 송신자에게 보내 Error Control 이 가능하게 한다.

이 ACK 패킷에는 해당 시점에서 수신자가 추가로 수신 가능한 데이터 양

(여유 버퍼 공간)을 (Advertised) Window에 설정하여 송신자에게 알린다.

TCP 송신자는 이 Window 이상의 정보를 보내지 않도록 자신의 Window 크

기를 조절한다.

28

송신자 수신자

TCP (1)

ACK

(1)번 패킷까지 잘 받았어. 그리고 현재

버퍼에 추가로 5개까지 더 받을 수 있어

Page 29: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Flow Control in TCP (참고)

Send buffer size: MaxSendBuffer

Receive buffer size: MaxRcvBuffer

Receiving side

LastByteRcvd - LastByteRead < = MaxRcvBuffer

AdvertisedWindow = MaxRcvBuffer - (NextByteExpected - NextByteRead)

Sending side

LastByteSent - LastByteAcked < = AdvertisedWindow

EffectiveWindow = AdvertisedWindow - (LastByteSent - LastByteAcked)

LastByteWritten - LastByteAcked < = MaxSendBuffer

block sender if (LastByteWritten - LastByteAcked) + y > MaxSenderBuffer

Always send ACK in response to arriving data segment

Persist when AdvertisedWindow = 0

29

Page 30: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

Sliding Window Mechanism of TCP (참고)

Sending side

LastByteAcked ≤ LastByteSent

LastByteSent ≤ LastByteWritten

buffer bytes between LastByteAcked

and LastByteWritten

Receiving side

LastByteRead < NextByteExpected

NextByteExpected ≤ LastByteRcvd +1

buffer bytes between NextByteRead

and LastByteRcvd

30

Sending App. Receiving App.

LastByteAcked LastByteSent

LastByteRead

NextByteExpected LastByteRcvd

TCP

(Advertised) Window Field of TCP Header

LastByteWritten

?

Page 31: ARQ (Automatic Repeat reQuest)contents.kocw.net/KOCW/document/2014/Pusan/kimjongdeok/4.pdfStop and Wait Source Transmit Single frame and Wait for ACK Receiving ACK, Transmits the next

31

Sending App. Receiving App.

2000

MaxRcvBuffer = 5000MaxSendBuffer = 3000

① App writes data of 2000 bytes1) LastByteWritten=2000

② TCP sends a segment of 1000 bytes1) LastByteSent = 1000

③ TCP receives ACK with AW = 40001) LastByteAcked = 1000

④ TCP sends a segment of 500 bytes (A); But lost during Tx.1) LastByteSent = 1500

⑤ TCP sends a segment of 500 bytes (B)1) LastByteSent = 2000

① TCP receives a segment of 1000 bytes1) NextByteRead = 12) LastByteRcvd = 10003) NextByteExpected=1001

② TCPSend ACK with AW=5000- (N.B.E – N.B.R)③ App reads data of 800 bytes

1) NextByteRead = 801

④ TCP receives a segment of 500 bytes of (B)1) LastByteRcvd = 20002) NextByteExpected = 1001

⑤ Send ACK with AW=5000 – (N.B.E – N.B.R)

Let Initial Effective Window=1000

BA B