csce 515 : computer network programming

24
CSCE 515: Computer Network Programming Chin-Tser Huang [email protected] University of South Carolina

Upload: blythe-mckay

Post on 14-Mar-2016

44 views

Category:

Documents


0 download

DESCRIPTION

CSCE 515 : Computer Network Programming. Chin-Tser Huang [email protected] University of South Carolina. Midterm Exam Grade. Before adjustment Graduate: Avg 10, Highest 12.5 Undergrad: Avg 12.4, Highest 18 After adjustment Graduate: +5 to everyone Undergrad: +2 to everyone. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CSCE  515 : Computer Network  Programming

CSCE 515:Computer Network

Programming

Chin-Tser [email protected]

University of South Carolina

Page 2: CSCE  515 : Computer Network  Programming

3/17/2005 2

Midterm Exam Grade Before adjustment

Graduate: Avg 10, Highest 12.5 Undergrad: Avg 12.4, Highest 18

After adjustment Graduate: +5 to everyone Undergrad: +2 to everyone

Page 3: CSCE  515 : Computer Network  Programming

3/17/2005 3

Final Exam Guide Problems similar to those in midterm

exam Will have one more programming

problem that asks you to debug a piece of code

In each section, the one who makes most progress in final exam compared to midterm exam grade will get 2 bonus points!

Page 4: CSCE  515 : Computer Network  Programming

3/17/2005 4

Bulk Data Flow With bulk of data to send, it is desired

that sender is allowed to transmit multiple packets before it stops and waits for acknowledgment

However, cannot keep sending without pause, otherwise receiver may run out of buffer

Use sliding window protocol to control data flow

Page 5: CSCE  515 : Computer Network  Programming

3/17/2005 5

Sliding Window Protocol Receiver advertises a window to notify

sender how much data it can send Window closes as left edge moves to right

When data is sent and acknowledged Window opens as right edge moves to right

When receiving process reads acknowledged data and freeing up space in TCP receive buffer

Window shrinks as right edge moves to left (discouraged)

Page 6: CSCE  515 : Computer Network  Programming

3/17/2005 6

Sliding Window

1 2 3 4 5 6 7 8 9 10

11

offered window(advertised by

receiver)usable window

sent, not ACKedacknowledged

sent andcan send ASAP

can’t send untilwindow moves

Page 7: CSCE  515 : Computer Network  Programming

3/17/2005 7

TCP Options A variable-length list of optional

information for TCP segments Some options defined in TCP include

End of option list No operation Maximum segment size Window scale factor Timestamp Selective acknowledgment

Page 8: CSCE  515 : Computer Network  Programming

3/17/2005 8

TCP SACK Permitted and SACK Option When establishing a connection, either

end can use SACK permitted option to let the other end know that it can accept SACK option

When some segment is lost, can use SACK option to acknowledge received bytes to avoid redundant retransmission

Page 9: CSCE  515 : Computer Network  Programming

3/17/2005 9

TCP SACK Option Examples Assume left window edge is 5000 and

sender sends a burst of 8 segments, each containing 500 data bytes

Case 1: first 4 segments are received but the last 4 are dropped receiver will return a normal TCP ACK

segment acknowledging sequence number 7000, with no SACK option

Page 10: CSCE  515 : Computer Network  Programming

3/17/2005 10

TCP SACK Option Examples Case 2: first segment is dropped but the remaining

7 are received Upon receiving each of the last seven packets, receiver

will return a TCP ACK segment that acknowledges sequence number 5000 and contains a SACK option specifying one block of queued dataTriggering Segment ACK Left Edge Right Edge5000 (lost)5500 5000 5500 60006000 5000 5500 65006500 5000 5500 70007000 5000 5500 75007500 5000 5500 80008000 5000 5500 85008500 5000 5500 9000

Page 11: CSCE  515 : Computer Network  Programming

3/17/2005 11

TCP SACK Option Examples Case 3: 2nd, 4th, 6th, and 8th (last) segments

are dropped receiver ACKs the first packet normally, and the 3rd,

5th, and 7th packets trigger SACK optionsTriggering Segment ACK 1st Block 2nd Block 3rd BlockLeft Right Left Right Left Right5000 55005500 (lost)6000 5500 6000 65006500 (lost)

7000 5500 7000 7500 6000 6500 7500 (lost) 8000 5500 8000 8500 7000 7500 6000 6500

8500 (lost)

Page 12: CSCE  515 : Computer Network  Programming

3/17/2005 12

TCP PUSH Flag Sender uses PUSH flag to notify receiver

to pass all data it has to the receiving process

Some cases where PUSH is set Send buffer is emptied by sending this

segment This segment is final data segment

Page 13: CSCE  515 : Computer Network  Programming

3/17/2005 13

Urgent Mode One end notifies the other end that

some “urgent data” is in data stream What action to take is up to receiver Two fields in TCP header needs to be set

URG flag set to 1 Urgent pointer set to a positive offset that is

added to ISN to get seq# of last byte of urgent data

Page 14: CSCE  515 : Computer Network  Programming

3/17/2005 14

TCP Timeout and Retransmission TCP handles lost data segments and

acknowledgments by setting a timeout when it sends data

If data isn’t acknowledged when timeout expires, TCP retransmits data

Two implementation issues to consider How to determine timeout interval How frequently to retransmit data

Page 15: CSCE  515 : Computer Network  Programming

3/17/2005 15

Round-Trip Time Measurement RTT changes over time due to

route changes and network traffic changes

TCP should track RTT changes and modify its timeout accordingly

R R+(1-)M, where =0.9RTO = R, where =2

Page 16: CSCE  515 : Computer Network  Programming

3/17/2005 16

Improved RTT Measurement Previous approach can’t keep up

with wide fluctuations in RTT and may cause unnecessary retransmissions

Err = M-AA A+gErr, where g=0.125D D+h(|Err|-D), where h=0.25RTO = A+4D

Page 17: CSCE  515 : Computer Network  Programming

3/17/2005 17

Karn’s Algorithm When receiving an ACK after

retransmission, TCP can’t tell this ACK is for original transmission or for retransmission

Hence can’t update RTT estimators using received ACK when a timeout and retransmission occur

Page 18: CSCE  515 : Computer Network  Programming

3/17/2005 18

TCP Congestion Control Assume packet loss is largely due to

congestion Two indications of packet loss: timeout and

receipt of duplicate ACKs When congestion occurs, slow down

transmission rate, and gradually come back if congestion is relieved

Use two algorithms Slow start Congestion avoidance

Page 19: CSCE  515 : Computer Network  Programming

3/17/2005 19

Slow Start The rate at which new packets should be injected

into network is the rate at which acknowledgments are returned

Use a congestion window (cwnd) in sender’s TCP Initialized to one segment when new connection is

established Increased by one segment each time an ACK is received

until packet loss occurs: exponential increase Congestion window is flow control by sender while

advertised window is flow control by receiver

Page 20: CSCE  515 : Computer Network  Programming

3/17/2005 20

Congestion Avoidance Use a slow start threshold (ssthresh) When receiving 3 dup ACKs, cwnd is cut in

half, and window grows linearly 3 dup ACKs indicates network capable of

delivering some segments When timeout occurs, cwnd instead set to

1 MSS, and window first grows exponentially until reach ssthresh, then grows linearly Timeout before 3 dup ACKs implies severe

congestion

Page 21: CSCE  515 : Computer Network  Programming

3/17/2005 21

Congestion Control Algorithm When cwnd is below ssthresh, sender in

slow-start phase, window grows exponentially

When cwnd is above ssthresh, sender is in congestion-avoidance phase, window grows linearly

When a triple duplicate ACK occurs, ssthresh set to cwnd/2 and cwnd set to ssthresh

When timeout occurs, ssthresh set to cwnd/2 and cwnd is set to 1 MSS

Page 22: CSCE  515 : Computer Network  Programming

3/17/2005 22

Fast Retransmit and Fast Recovery Used when receiving 3 dup ACKs

Receiving 3 dup ACKs means data can still flow, so no need to reduce rate abruptly

Fast retransmit: when receiving 3 dup ACKs, retransmit without waiting for retransmission timeout

Fast recovery: perform congestion avoidance, not slow start

Page 23: CSCE  515 : Computer Network  Programming

3/17/2005 23

Repacketization When TCP times out and retransmits,

it does not have to retransmit the identical segment again

Instead, TCP is allowed to send a bigger segment (not exceeding MSS) to increase performance Because TCP identifies data by byte

number, not segment number

Page 24: CSCE  515 : Computer Network  Programming

3/17/2005 24

Next Class TCP persist and keepalive timers Other TCP options Read TI Ch. 22, 23, 24