Computer networks
This presentation is the property of its rightful owner.
Sponsored Links
1 / 52

Computer Networks PowerPoint PPT Presentation


  • 75 Views
  • Uploaded on
  • Presentation posted in: General

Computer Networks. Lecture 16 Sliding Window Protocols; TCP Reliability 10/22/2013. Admin.: Assignment 4. Exam 1: Tuesday Oct. 29 in class Closed book but one piece of paper with any summary Assignment 4 to be posted tonight. proj-sol: 129 400 3045 FishThread.java

Download Presentation

Computer Networks

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Computer networks

Computer Networks

Lecture 16

Sliding Window Protocols;TCP Reliability

10/22/2013


Admin assignment 4

Admin.: Assignment 4

  • Exam 1: Tuesday Oct. 29 in class

    • Closed book but one piece of paper with any summary

  • Assignment 4 to be posted tonight

proj-sol:

129 400 3045 FishThread.java

388 1457 12873 Node.java

51 167 1145 PingRequest.java

83 250 2106 SimpleTCPSockSpace.java

181 605 5248 TCPManager.java

889 3088 26381 TCPSock.java

60 149 1316 TCPSockID.java

123 382 3866 TransferClient.java

147 500 5059 TransferServer.java

2051 6998 61039 total

proj:

129 400 3045 FishThread.java

341 1301 11313 Node.java

51 167 1145 PingRequest.java

50 128 909 TCPManager.java

132 460 3146 TCPSock.java

123 382 3866 TransferClient.java

147 500 5059 TransferServer.java

973 3338 28483 total


Recap reliable d ata t ransfer

rdt_send():called from above, (e.g., by app.)

deliver_data():called by rdt to deliver data to upper

udt_send():called by rdt,

to transfer packet over

unreliable channel to receiver

rdt_rcv():called from below; when packet arrives on rcv-side of channel

Recap: Reliable Data Transfer

send

side

receive

side


Recap potential channel errors

bit errors

loss (drop) of packets

reordering or duplication

Recap: Potential Channel Errors

Characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt).


Recap rdt3 0 bit error loss

sender

Recap: rdt3.0 (Bit Error/Loss)

receiver

data 0 (n-1)

waiting for 0(n-1)

State consistency:

When receiver’s state is waiting n, the state of the sender is either sending for n-1 or sending for n

When sender’s state is sending for n, receiver’s state is waiting for n or n + 1

ACK for 0 (n-1)

sending 0 (n-1)

data 0 (n-1)

waiting for 1

(n)

ACK for 0 (n-1)

data 1 (n)

sending 1(n)

waiting for 0(n+1)


Recap rdt3 0 s ender bit error loss

Wait for ACK0

Wait for ACK1

Wait for

call 1 from above

Wait for

call 0from above

Recap: rdt3.0 Sender (Bit Error/Loss)

rdt_send(data)

rdt_rcv(rcvpkt) &&

( corrupt(rcvpkt) ||

isACK(rcvpkt,1) )

sndpkt = make_pkt(0, data, checksum)

udt_send(sndpkt)

start_timer

L

rdt_rcv(rcvpkt)

L

timeout

udt_send(sndpkt)

start_timer

rdt_rcv(rcvpkt)

&& notcorrupt(rcvpkt)

&& isACK(rcvpkt,1)

rdt_rcv(rcvpkt)

&& notcorrupt(rcvpkt)

&& isACK(rcvpkt,0)

stop_timer

stop_timer

timeout

udt_send(sndpkt)

start_timer

rdt_rcv(rcvpkt)

L

rdt_send(data)

rdt_rcv(rcvpkt) &&

( corrupt(rcvpkt) ||

isACK(rcvpkt,0) )

sndpkt = make_pkt(1, data, checksum)

udt_send(sndpkt)

start_timer

L


Recap rdt3 0 s top and w ait o peration efficiency

Recap: rdt3.0 (Stop-and-Wait Operation) Efficiency

sender

receiver

first packet bit transmitted, t = 0

last packet bit transmitted, t = L / R

first packet bit arrives

RTT

last packet bit arrives, send ACK

ACK arrives, send next

packet, t = RTT + L / R


Computer networks

Recap: A Summary of Questions

  • How to improve the performance of rdt3.0?

  • What if there are reordering and duplication?

  • How to determine the “right” timeout value?


Computer networks

Recap: Pipelining

sender

receiver

first packet bit transmitted, t = 0

last bit transmitted, t = L / R

first packet bit arrives

RTT

last packet bit arrives, send ACK

last bit of 2nd packet arrives, send ACK

last bit of 3rd packet arrives, send ACK

ACK arrives, send next

packet, t = RTT + L / R

increase utilization

by a factor of 3!

Question: a rule-of-thumb window size?


Recap forms of pipelining protocols

Two generic forms of pipelined protocols

go-Back-N

selective repeat

Recap: Forms of Pipelining Protocols


Go back n

Sender:

k-bit seq # in pkt header

“window” of up to W, consecutive unack’ed pkts allowed

Go-Back-n

W

  • ACK(n): ACKs all pkts up to, including seq # n - “cumulative ACK”

  • timer for the packet at base

  • Go-back-n:

    • timeout(n): retransmit timeout pkt and all higher seq # pkts in window


Computer networks

Wait

GBN: Sender Extended FSM

rdt_send(data)

if (nextseqnum < base+W) {

sndpkt[nextseqnum] = make_pkt(nextseqnum,data,chksum)

udt_send(sndpkt[nextseqnum])

if (base == nextseqnum) start_timer

nextseqnum++

} else if (sender buffer has space) {

add pkt to send buffer

else

block sender

L

base=1

nextseqnum=1

timeout

start_timer

udt_send(sndpkt[base])

udt_send(sndpkt[base+1])

udt_send(sndpkt[nextseqnum-1])

rdt_rcv(rcvpkt)

&& corrupt(rcvpkt)

rdt_rcv(rcvpkt) &&

notcorrupt(rcvpkt)

if (new packets ACKed) {

advance base;

if (more packets waiting) send packets allowed by W

}

if (base == nextseqnum)

stop_timer

else

start_timer for the packet at new base


Computer networks

GBN: Receiver Extended FSM

default

udt_send(sndpkt)

rdt_rcv(rcvpkt)

&& notcurrupt(rcvpkt)

&& hasseqnum(rcvpkt,expectedseqnum)

L

Wait

extract(rcvpkt,data)

deliver_data(data)

sndpkt = make_pkt(expectedseqnum,ACK,chksum)

udt_send(sndpkt)

expectedseqnum++

expectedseqnum=1

sndpkt =

make_pkt(expectedseqnum,ACK,chksum)

ACK-only: always send ACK for correctly-received pkt with highest in-order seq #

  • need only remember expectedseqnum

  • out-of-order pkt:

    • discard (don’t buffer) -> no receiver buffering!

    • re-ACK pkt with highest in-order seq #

    • may generate duplicate ACKs


  • Gbn in action

    GBN inAction

    window

    size = 4


    Discussion efficiency of go back n

    Discussion: Efficiency of Go-Back-n

    • Assume window size W

    • Assume each packet is lost with probability p

    • Assume always busy

    • On average, how many packets do we send on average for each succ packet?


    Selective repeat

    Sender window

    Window size W: W consecutive unACKed seq #’s

    Receiver individually acknowledges correctly received pkts

    buffers pkts as needed, for eventual in-order delivery to upper layer

    ACK(n) means received packet with seq# n only

    buffer size at receiver

    window size

    Sender only resends pkts for which ACK not received

    sender timer for each unACKed pkt

    Selective Repeat


    Selective repeat sender receiver windows

    Selective Repeat: Sender, Receiver Windows

    W

    W


    Selective repeat1

    data from above :

    unACKed packets is less than window size W, send/timer; otherwise buffer/block app.

    timeout(n):

    resend pkt n, restart timer

    ACK(n) in [sendbase,sendbase+W-1]:

    mark pkt n as received

    update sendbase to the first packet unACKed

    receiver

    sender

    Selective Repeat

    pkt n in [rcvbase, rcvbase+W-1]

    • send ACK(n)

    • if (out-of-order) mark and buffer pkt nelse /*in-order*/

      deliver any in-order packets

      otherwise:

    • ignore


    Computer networks

    Selective Repeat in Action


    Computer networks

    Discussion: Efficiency of Selective Repeat

    • Assume window size W

    • Assume each packet is lost with probability p

    • On average, how many packets do we send for each data packet?


    Computer networks

    State Invariant: Window Location

    • Go-back-n (GBN)

    • Selective repeat (SR)

    sender window

    receiver window

    sender window

    receiver window


    Computer networks

    Q: what relationship between seq # size and window size?

    Window Location

    • Go-back-n (GBN)

    • Selective repeat (SR)

    sender window

    receiver window

    sender window

    receiver window


    Selective repeat seq ambiguity

    Example:

    seq #’s: 0, 1, 2, 3

    window size=3

    receiver sees no difference in two scenarios!

    Selective Repeat Seq# Ambiguity


    Computer networks

    Sliding Window Protocols:Go-back-n and Selective Repeat

    Less efficient

    More efficient

    W

    1

    M > W

    M ≥ 2W

    W

    1

    More complex

    Simpler

    p: the loss rate of a packet; M: number of seq# (e.g., 3 bit M = 8); W: window size


    Question what is initial seq

    sender

    Question: What is Initial Seq#?

    receiver

    data 0

    accept

    ACK for 0


    Question what is initial seq1

    sender

    data 0 (transfer $1000 to B)

    accept?

    Question: What is Initial Seq#?

    receiver

    data 0 (transfer $1000 to B)

    accept

    ACK for 0 (n)


    Computer networks

    Outline

    • Recap

    • Sliding window protocols

      • Go-back-n

      • Selective repeat

    • Connection management


    Connection management

    SYN(seq=0)

    yes

    Is seq=0 a new flow

    Connection Management

    • Objective: Sender confirms with receiver that it is a new flow

    Host A

    Host B

    accept?

    Q: Does this design work?


    Connection management design

    Connection Management Design

    • Network guarantee

      • a packet too old will be purged from the network: network bounds the life time of each packet

    • Sender guarantee

      • a sender will not reuse a seq# before it is sure that all packets with the seq# are purged from the network

  • Agree on initial sequence numbers

    • Sender notifies receiver the initial seq# and other initial parameters


  • Three way handshake twh tomlinson 1975

    DATA(seq=x+1)

    SYN(seq=x)

    ACK(seq=y)

    ACK(seq=x), SYN(seq=y)

    Three Way Handshake (TWH) [Tomlinson 1975]

    Host A

    Host B

    accept?

    accept data only after

    verified x is the init. seq

    SYN: indicates connection setup


    Scenarios with duplicate request

    REJECT(seq=y)

    SYN(seq=x)

    ACK(seq=x), SYN(seq=y)

    Scenarios with Duplicate Request

    Host A

    Host B

    accept?

    no suchrequest

    reject


    Three way handshake twh tomlinson 19751

    To ensure that the other side does want to send a request

    Host A

    Host B

    REJECT(seq=y)

    DATA(seq=x+1)

    SYN(seq=x)

    ACK(seq=z)

    SYN(seq=x)

    ACK(seq=y)

    accept?

    ACK(seq=x), SYN(seq=y)

    ACK(seq=x), SYN(seq=y)

    no suchrequest

    reject

    Three Way Handshake (TWH) [Tomlinson 1975]

    Host A

    Host B


    Connection close

    Objective of closure handshake:

    each side can release resource and remove state about the connection

    I am done. Are you done too?

    Connection Close

    client

    server

    init. close

    release

    resource?

    close

    release

    resource?

    I am done too. Goodbye!

    close

    release

    resource?


    General case the two army problem

    General Case: The Two-Army Problem

    The two blue armies need to agree on whether or not they will attack the white army. They achieve agreement by sending messengers to the other side. If they both agree, attack; otherwise, no. Note that a messenger can be captured!


    Four way teardown

    Four Way Teardown

    Host A

    Host B

    propose closeA->B

    close

    FIN

    A->B closed

    ACK

    propose closeB->A

    close

    A->B closed

    FIN

    ACK

    • can retransmit the ACKif its ACK is lost

    timed wait

    closed

    all states removed

    closed

    all states removed


    Computer networks

    A Summary of Questions

    • How to improve the performance of rdt3.0?

      • sliding window protocols

    • What if there are duplication and reordering?

      • network guarantee: max packet life time

      • transport guarantee: not reuse a seq# before life time

      • seq# management and connection management

    • How to determine the “right” parameters?


    Computer networks

    Outline

    • Recap

    • Reliable data transfer

    • TCP reliability


    Computer networks

    TCP: OverviewRFCs: 793, 1122, 1323, 2018, 2581

    • Point-to-point reliability: one sender, one receiver

    • Flow controlled and congestion controlled


    Tcp reliable data transfer

    Connection-oriented:

    connection management

    setup (exchange of control msgs) init’s sender, receiver state before data exchange

    close

    Full duplex data:

    bi-directional data flow in same connection

    A sliding window protocol

    a combination of go-back-n and selective repeat:

    send & receive buffers

    cumulative acks

    TCP uses a single retransmission timer

    do not retransmit all packets upon timeout

    TCP Reliable Data Transfer


    Tcp segment structure

    32 bits

    URG: urgent data

    (generally not used)

    counting

    by bytes

    of data

    (not segments!)

    source port #

    dest port #

    sequence number

    ACK: ACK #

    valid

    acknowledgement number

    head

    len

    not

    used

    rcvr window size

    U

    A

    P

    R

    S

    F

    PSH: push data now

    (generally not used)

    flow control

    checksum

    ptr urgent data

    Options (variable length)

    RST, SYN, FIN:

    connection management

    (reset, setupteardown

    commands)

    application

    data

    (variable length)

    Also in UDP

    TCP Segment Structure


    Tcp flow control

    spare room in buffer

    = RcvWindow

    flow control

    sender won’t overflow

    receiver’s buffer by

    transmitting too much,

    too fast

    TCP Flow Control

    source port #

    dest port #

    sequence number

    acknowledgement number

    head

    len

    not

    used

    rcvr window size

    U

    A

    P

    R

    S

    F

    checksum

    ptr urgent data

    Options (variable length)

    application

    data

    (variable length)


    Computer networks

    time

    TCP Seq. #’s and ACKs

    Seq. #’s:

    • byte stream “number” of first byte in segment’s data

      ACKs:

    • seq # of next byte expected from other side

    • cumulative ACK

    Host B

    Host A

    User

    types

    ‘C’

    Seq=42, ACK=79, data = ‘C’

    host ACKs

    receipt of

    ‘C’, echoes

    back ‘C’

    Seq=79, ACK=43, data = ‘C’

    host ACKs

    receipt

    of echoed

    ‘C’

    Seq=42, ACK=80

    simple telnet scenario


    Tcp fast retransmit

    Problem: Timeout period often relatively long:

    long delay before resending lost packet

    If sender receives 3 ACKs for the same data, it supposes that segment after ACKed data was lost:

    resend segment before timer expires

    TCP Fast Retransmit

    • Detect lost segments via duplicate ACKs

      • sender often sends many segments back-to-back

      • if segment is lost, there will likely be many duplicate ACKs


    Computer networks

    4

    4

    4

    Triple Duplicate Ack

    Packets

    1

    7

    2

    3

    4

    5

    6

    Acknowledgements (waiting seq#)

    2

    3

    4


    Fast retransmit

    Fast Retransmit:

    event: ACK received, with ACK field value of y

    if (y > SendBase) {

    SendBase = y

    if (there are currently not-yet-acknowledged segments)

    start timer

    }

    else {

    increment count of dup ACKs received for y

    if (count of dup ACKs received for y = 3) {

    resend segment with sequence number y

    a duplicate ACK for

    already ACKed segment

    fast retransmit


    Tcp reliable data transfer1

    • 00sendbase = initial_sequence number agreed by TWH

    • 01 nextseqnum = initial_sequence number by TWH

    • 02 loop (forever) {

    • 03 switch(event)

    • 04 event: data received from application above

    • 05 if (window allows send)

    • 06 create TCP segment with sequence number nextseqnum

    • 06 if (no timer) start timer

    • 07 pass segment to IP

    • 08 nextseqnum = nextseqnum + length(data)else put packet in buffer

    • 09 event: timer timeout for sendbase

    • 10 retransmit segment

    • 11 compute new timeout interval

    • 12 restart timer

    • 13 event: ACK received, with ACK field value of y

    • 14 if (y > sendbase) { /* cumulative ACK of all data up to y */

    • 15 cancel the timer for sendbase

    • sendbase = y

    • if (no timer and packet pending) start timer for new sendbase

    • while (there are segments and window allow)

    • sent a segment;

    • 18 }

    • 19 else { /* y==sendbase, duplicate ACK for already ACKed segment */

    • 20 increment number of duplicate ACKs received for y

    • 21 if (number of duplicate ACKS received for y == 3) {

    • 22 /* TCP fast retransmit */

    • 23 resend segment with sequence number y

    • 24 restart timer for segment y

    • 25 }

    • 26 } /* end of loop forever */

    TCP: reliable data transfer

    Simplified

    TCP

    sender


    Tcp receiver ack generation rfc 1122 rfc 2581

    TCP Receiver ACK Generation[RFC 1122, RFC 2581]

    TCP Receiver Action

    Delayed ACK. Wait up to 500ms

    for next segment. If no next segment,

    send ACK

    Immediately send single cumulative

    ACK, ACKing both in-order segments

    Immediately send duplicate ACK,

    indicating seq. # of next expected byte

    Immediate send ACK, provided that

    segment starts at lower end of gap

    Event at Receiver

    Arrival of in-order segment with

    expected seq #. All data up to

    expected seq # already ACKed

    Arrival of in-order segment with

    expected seq #. One other

    segment has ACK pending

    Arrival of out-of-order segment

    higher-than-expect seq. # .

    Gap detected

    Arrival of segment that

    partially or completely fills gap


    Computer networks

    CLOSED

    SYN SENT

    SYN

    ESTABLSIHED

    ACK

    SYN/ACK

    FIN

    ACK

    %netstat -t -a

    CLOSED

    LISTEN

    SYN RCVD

    ESTABLSIHED

    ESTABLSIHED

    ESTABLSIHED

    FINWAIT 1

    FIN

    CLOSEWAIT

    LASTACK

    FINWAIT 2

    TIMEWAIT

    ACK


    Tcp connection management

    CLOSED

    SYN SENT

    SYN

    ESTABLSIHED

    ACK

    FIN

    SYN/ACK

    ACK

    ESTABLSIHED

    ESTABLSIHED

    FINWAIT 1

    FIN

    CLOSEWAIT

    LASTACK

    FINWAIT 2

    TIMEWAIT

    ACK

    TCP Connection Management

    CLOSED

    TCP lifecycle: init SYN/FIN

    SYN RCVD

    http://dsd.lbl.gov/TCP-tuning/ip-sysctl-2.6.txt


    Tcp connection management1

    CLOSED

    SYN SENT

    SYN

    ESTABLSIHED

    ACK

    FIN

    SYN/ACK

    ACK

    ESTABLSIHED

    ESTABLSIHED

    FINWAIT 1

    FIN

    CLOSEWAIT

    LASTACK

    FINWAIT 2

    TIMEWAIT

    ACK

    TCP Connection Management

    CLOSED

    TCP lifecycle: wait for SYN/FIN

    SYN RCVD


    Computer networks

    A Summary of Questions

    • How to improve the performance of rdt3.0?

      • sliding window protocols

    • What if there are duplication and reordering?

      • network guarantee: max packet life time

      • transport guarantee: not reuse a seq# before life time

      • seq# management and connection management

    • How to determine the “right” parameters?


    Computer networks

    History

    • Key parameters for TCP in mid-1980s

      • fixed window size W

      • timeout value = 2 RTT

    • Network collapse in the mid-1980s

      • UCB  LBL throughput dropped by 1000X !


  • Login