Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron...

67
Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University [email protected]
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    218
  • download

    3

Transcript of Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron...

Page 1: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Data Communication and Networks

Lecture 9/10

Internet ProtocolsNovember 6, 2003

Joseph Conron

Computer Science Department

New York University

[email protected]

Page 2: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

What’s the Internet: Components view

millions of connected computing devices: hosts, end-systems pc’s workstations, servers PDA’s phones, toastersrunning network apps

communication links fiber, copper, radio, satellite

routers: forward packets (chunks) of data thru network

Page 3: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

What’s the Internet: Components view

protocols: control sending, receiving of msgs e.g., TCP, IP, HTTP, FTP, PPP

Internet: “network of networks” loosely hierarchical public Internet versus private intranet

Internet standards RFC: Request for comments IETF: Internet Engineering Task Force

Page 4: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

What’s the Internet: a service view

communication infrastructure enables distributed applications: WWW, email, games, e-commerce,

database., voting, more?

communication services provided: connectionless connection-oriented

Page 5: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Internet structure: network of networks

roughly hierarchical national/international

backbone providers (NBPs) e.g. BBN/GTE, Sprint,

AT&T, IBM, UUNet interconnect (peer) with

each other privately, or at public Network Access Point (NAPs)

regional ISPs connect into NBPs

local ISP, company connect into regional ISPs

NBP A

NBP B

NAP NAP

regional ISP

regional ISP

localISP

localISP

Page 6: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Connectionless Operation

Corresponds to datagram mechanism in packet switched network

Each NPDU treated separately Network layer protocol common to all DTEs and

routers Known generically as the internet protocol

Internet Protocol One such internet protocol developed for ARPANET RFC 791 (Get it and study it)

Lower layer protocol needed to access particular network

Page 7: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Connectionless Internetworking

Advantages Flexibility Robust No unnecessary overhead

Unreliable Not guaranteed delivery Not guaranteed order of delivery

Packets can take different routes

Reliability is responsibility of next layer up (e.g. TCP)

Page 8: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Internet protocol stack

application: supporting network applications ftp, smtp, http

transport: host-host data transfer tcp, udp

network: routing of datagrams from source to destination ip, routing protocols

link: data transfer between neighboring network elements ppp, ethernet

physical: bits “on the wire”

application

transport

network

link

physical

Page 9: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Protocol layering and data

Each layer takes data from above adds header information to create new data unit passes new data unit to layer below

applicationtransportnetwork

linkphysical

applicationtransportnetwork

linkphysical

source destination

M

M

M

M

Ht

HtHn

HtHnHl

M

M

M

M

Ht

HtHn

HtHnHl

message

segment

datagram

frame

Page 10: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Internet Protocol (IP)

Only protocol at Layer 3 Defines

Internet addressing Internet packet format Internet routing

RFC 791 (1981)

Page 11: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

IP Address Details

32 Bits - divided into two parts Prefix identifies network Suffix identifies host

Global authority assigns unique prefix to network (IANA)

Local administrator assigns unique suffix to host

Page 12: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

IP Addresses

0network host

10 network host

110 network host

1110 multicast address

A

B

C

D

class1.0.0.0 to127.255.255.255

128.0.0.0 to191.255.255.255

192.0.0.0 to223.255.255.255

224.0.0.0 to239.255.255.255

32 bits

given notion of “network”, let’s examine IP addresses:

“class-full” addressing:

Page 13: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Classes and Network Sizes

Maximum network size determined by class of address

Class A large Class B medium Class C small

Page 14: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

IP Addressing Example

Page 15: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Subnets and Subnet Masks Allow arbitrary complexity of internetworked

LANs within organization Insulate overall internet from growth of network

numbers and routing complexity Site looks to rest of internet like single network Each LAN assigned subnet number Host portion of address partitioned into subnet

number and host number Local routers route within subnetted network Subnet mask indicates which bits are subnet

number and which are host number

Page 16: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Routing Using Subnets

Page 17: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

IP addressing: CIDR classful addressing:

inefficient use of address space, address space exhaustion e.g., class B net allocated enough addresses for 65K hosts,

even if only 2K hosts in that network

CIDR: Classless InterDomain Routing network portion of address of arbitrary length address format: a.b.c.d/x, where x is # bits in network portion

of address

11001000 00010111 00010000 00000000

networkpart

hostpart

200.23.16.0/23

Page 18: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Internet Packets

Contains sender and destination addresses Size depends on data being carried Called IP datagram Two Parts Of An IP Datagram

Header Contains source and destination address Fixed-size fields

Data Area (Payload) Variable size up to 64K No minimum size

Page 19: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

IP datagram format

ver length

32 bits

data (variable length,typically a TCP

or UDP segment)

16-bit identifier

Internet checksum

time tolive

32 bit source IP address

IP protocol versionnumber

header length (bytes)

max numberremaining hops

(decremented at each router)

forfragmentation/reassembly

total datagramlength (bytes)

upper layer protocolto deliver payload to

head.len

type ofservice

“type” of data flgsfragment

offsetupper layer

32 bit destination IP address

Options (if any) E.g. timestamp,record routetaken, specifylist of routers to visit.

Page 20: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

IP Fragmentation & Reassembly

network links have MTU (max.transfer size) - largest possible link-level frame. different link types,

different MTUs large IP datagram divided

(“fragmented”) within net one datagram becomes

several datagrams “reassembled” only at

final destination IP header bits used to

identify, order related fragments

fragmentation: in: one large datagramout: 3 smaller datagrams

reassembly

Page 21: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

IP Fragmentation and Reassembly

ID=x

offset=0

fragflag=0

length=4000

ID=x

offset=0

fragflag=1

length=1500

ID=x

offset=1480

fragflag=1

length=1500

ID=x

offset=2960

fragflag=0

length=1040

One large datagram becomesseveral smaller datagrams

Page 22: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

IP Semantics

IP is connectionless Datagram contains identity of destination Each datagram sent/ handled independently

Routes can change at any time

Page 23: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

IP Semantics (continued)

IP allows datagrams to be Delayed Duplicated Delivered out-of-order Lost

Called best effort deliveryMotivation: accommodate all possible

networks

Page 24: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Datagram LifetimeDatagrams could loop indefinitely

Consumes resources Transport protocol may need upper bound on

datagram lifeDatagram marked with lifetime

Time To Live field in IP Once lifetime expires, datagram discarded (not

forwarded) Hop count

Decrement time to live on passing through a each router

Time countNeed to know how long since last router

Page 25: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

ICMPInternet Control Message ProtocolRFC 792Transfer of (control) messages from

routers and hosts to hostsFeedback about problems

e.g. time to live expired

Encapsulated in IP datagram Not reliable

Page 26: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

ICMP Error MessagesWhen an ICMP error message is sent, the

message always contains the IP header and the first 8 bytes of the IP datagram that caused the problem

ICMP has rules regarding error message generation to prevent broadcast storms

Page 27: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

ICMP Echo CommandUsed by “ping” and “tracert”When a destination IP host receives an

ICMP echo command, it returns and ICMP “echo reply”

Ping uses this to determine if a path to a destination (and its return path) are “up”

Tracert uses echo in a clever way to determine the identities of the routers along the path (by “scoping” TTL).

Page 28: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Address Resolution ProblemSuppose we know the IP Address of a local

system (one to which we are connected)We would like to send an IP packet to that

system.The link layer (ethernet, for instance) only

knows about MAC addresses!How do we determine the MAC address

associated with the IP address?

Page 29: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

ARPAddress resolution provides a mapping

between two different forms of addresses 32-bit IP addresses and whatever the data link

uses

ARP (address resolution protocol) is a protocol used to do address resolution in the TCP/IP protocol suite (RFC826)

ARP provides a dynamic mapping from an IP address to the corresponding hardware address

Page 30: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

ARP Protocol A knows B's IP address, wants to learn physical

address of B A broadcasts ARP query pkt, containing B's IP

address all machines on LAN receive ARP query

B receives ARP packet, replies to A with its (B's) physical layer address

A caches (saves) IP-to-physical address pairs until information becomes old (times out) soft state: information that times out (goes away) unless

refreshed

Page 31: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

ARP Cache

The cache maintains the recent IP to physical address mappings

Each entry is aged (usually the lifetime is 20 minutes) forcing periodic updates of the cache

ARP replies are often broadcast so that all hosts can update their caches

Page 32: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

ARP Packet Format

168

Sender’s Protocol Address

Destination IP Address

31

Hardware Type

Hardware Size Protocol Size Operation

Protocol Type

Sender’s Hardware Address (for Ethernet 6 bytes)

(for IP 4 bytes) Target Hardware Address

Target Protocol Address

Page 33: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Internet Transport Protocols

Two Transport Protocols Available

Transmission Control Protocol (TCP) connection oriented most applications use TCP

RFC 793

User Datagram Protocol (UDP) Connectionless

RFC 768

Page 34: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Transport layer addressing

Communications endpoint addressed by:

IP address (32 bit) in IP Header Port number (16 bit) in TP Header1

Transport protocol (TCP or UDP) in IP Header

1 TP => Transport Protocol (UDP or TCP)

Page 35: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Standard services and port numbers

service tcp udpecho 7 7daytime 13 13netstat 15ftp-data 20ftp 21telnet 23smtp 25time 37 37domain 53 53finger 79http 80pop-2 109pop 110sunrpc 111 111uucp-path 117nntp 119talk 517

Page 36: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581

full duplex data: bi-directional data flow

in same connection MSS: maximum

segment size

connection-oriented: handshaking (exchange

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

flow controlled: sender will not

overwhelm receiver

point-to-point: one sender, one

receiver

reliable, in-order byte steam: no “message

boundaries”

pipelined: TCP congestion and flow

control set window size

send & receive bufferssocketdoor

T C Psend buffer

T C Preceive buffer

socketdoor

segm ent

applicationwrites data

applicationreads data

Page 37: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP Header

Page 38: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP segment structure

source port # dest port #

32 bits

applicationdata

(variable length)

sequence number

acknowledgement numberrcvr window size

ptr urgent datachecksum

FSRPAUheadlen

notused

Options (variable length)

URG: urgent data (generally not used)

ACK: ACK #valid

PSH: push data now(generally not used)

RST, SYN, FIN:connection estab(setup, teardown

commands)

# bytes rcvr willingto accept

countingby bytes of data(not segments!)

Internetchecksum

(as in UDP)

Page 39: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Reliability in an Unreliable World

IP offers best-effort (unreliable) delivery TCP uses IP TCP provides completely reliable transfer How is this possible? How can TCP realize:

Reliable connection startup? Reliable data transmission? Graceful connection shutdown?

Page 40: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Reliable Data Transmission

Positive acknowledgment Receiver returns short message when data arrives Called acknowledgment

Retransmission Sender starts timer whenever message is transmitted If timer expires before acknowledgment arrives, sender

retransmits message THIS IS NOT A TRIVIAL PROBLEM! – more on this later.

Page 41: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP Flow Control

Receiver Advertises available buffer space Called window This is a known as a CREDIT policy

Sender Can send up to entire window before ACK arrives

Each acknowledgment carries new window information Called window advertisement Can be zero (called closed window)

Interpretation: I have received up through X, and can take Y more octets

Page 42: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Credit SchemeDecouples flow control from ACK

May ACK without granting credit and vice versa

Each octet has sequence numberEach transport segment has seq number,

ack number and window size in header

Page 43: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Use of Header FieldsWhen sending, seq number is that of first

octet in segmentACK includes AN=i, W=jAll octets through SN=i-1 acknowledged

Next expected octet is i

Permission to send additional window of W=j octets i.e. octets through i+j-1

Page 44: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Credit Allocation

Page 45: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP Flow Controlreceiver: explicitly

informs sender of (dynamically changing) amount of free buffer space RcvWindow field

in TCP segmentsender: keeps the

amount of transmitted, unACKed data less than most recently received RcvWindow

sender won’t overrun

receiver’s buffers bytransmitting too

much, too fast

flow control

receiver buffering

RcvBuffer = size of TCP Receive Buffer

RcvWindow = amount of spare room in Buffer

Page 46: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP seq. #’s and ACKsSeq. #’s:

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

ACKs: seq # of next byte

expected from other side

cumulative ACKQ: how receiver handles

out-of-order segments A: TCP spec

doesn’t say, - up to implementor

Host A Host B

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

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

Seq=43, ACK=80

Usertypes

‘C’

host ACKsreceipt

of echoed‘C’

host ACKsreceipt of

‘C’, echoesback ‘C’

timesimple telnet scenario

Page 47: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP ACK generation [RFC 1122, RFC 2581]

Event

in-order segment arrival, no gaps,everything else already ACKed

in-order segment arrival, no gaps,one delayed ACK pending

out-of-order segment arrivalhigher-than-expect seq. #gap detected

arrival of segment that partially or completely fills gap

TCP Receiver action

delayed ACK. Wait up to 500msfor next segment. If no next segment,send ACK

immediately send singlecumulative ACK

send duplicate ACK, indicating seq. #of next expected byte

immediate ACK if segment startsat lower end of gap

Page 48: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP: retransmission scenarios

Host A

Seq=92, 8 bytes data

ACK=100

loss

tim

eout

time lost ACK scenario

Host B

X

Seq=92, 8 bytes data

ACK=100

Host A

Seq=100, 20 bytes data

ACK=100

Seq=

92

tim

eout

time premature timeout,cumulative ACKs

Host B

Seq=92, 8 bytes data

ACK=120

Seq=92, 8 bytes data

Seq=

10

0 t

imeou

t

ACK=120

Page 49: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Why Startup/ Shutdown Difficult?

Segments can be Lost Duplicated Delayed Delivered out of order Either side can crash Either side can reboot

Need to avoid duplicate ‘‘shutdown’’ message from affecting later connection

Page 50: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP Connection Management

Recall: TCP sender, receiver establish “connection” before exchanging data segments

initialize TCP variables: seq. #s buffers, flow control info

(e.g. RcvWindow) client: connection initiator Socket clientSocket = new

Socket("hostname","port

number"); server: contacted by client Socket connectionSocket =

welcomeSocket.accept();

Three way handshake:

Step 1: client end system sends TCP SYN control segment to server specifies initial seq #

Step 2: server end system receives SYN, replies with SYNACK control segment

ACKs received SYN allocates buffers specifies server->

receiver initial seq. #

Page 51: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP Connection Management (OPEN)

client

SYN

server

SYNACK

ACK

opening

opening

closed

established

Page 52: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP Connection Management (cont.)

Closing a connection:

client closes socket: clientSocket.close();

Step 1: client end system sends TCP FIN control segment to server

Step 2: server receives FIN, replies with ACK. Closes connection, sends FIN.

client

FIN

server

ACK

ACK

FIN

close

close

closed

tim

ed w

ait

Page 53: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP Connection Management (cont.)

Step 3: client receives FIN, replies with ACK.

Enters “timed wait” - will respond with ACK to received FINs

Step 4: server, receives ACK. Connection closed.

Note: with small modification, can handle simultaneous FINs.

client

FIN

server

ACK

ACK

FIN

closing

closing

closed

tim

ed w

ait

closed

Page 54: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP Connection Management (cont)

TCP clientlifecycle

TCP serverlifecycle

Page 55: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Timing Problem!

The delay required for data to reach a destination and anacknowledgment to return depends on traffic in the internet aswell as the distance to the destination. Because it allowsmultiple application programs to communicate with multipledestinations concurrently, TCP must handle a variety of delaysthat can change rapidly.

How does TCP handle this .....

Page 56: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Solving Timing Problem Keep estimate of round trip time on each

connection Use current estimate to set retransmission timer Known as adaptive retransmission Key to TCP’s success

Page 57: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP Round Trip Time and TimeoutQ: how to set TCP

timeout value? longer than RTT

note: RTT will vary too short: premature

timeout unnecessary

retransmissions too long: slow

reaction to segment loss

Q: how to estimate RTT? SampleRTT: measured time

from segment transmission until ACK receipt ignore retransmissions,

cumulatively ACKed segments

SampleRTT will vary, want estimated RTT “smoother” use several recent

measurements, not just current SampleRTT

Page 58: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

TCP Round Trip Time and Timeout

EstimatedRTT = (1-x)*EstimatedRTT + x*SampleRTT

Exponential weighted moving average influence of given sample decreases exponentially fast typical value of x: 0.1

Setting the timeout EstimtedRTT plus “safety margin” large variation in EstimatedRTT -> larger safety margin

Timeout = EstimatedRTT + 4*Deviation

Deviation = (1-x)*Deviation + x*|SampleRTT-EstimatedRTT|

Page 59: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Implementation Policy OptionsSendDeliverAcceptRetransmitAcknowledge

Page 60: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

SendIf no push or close TCP entity transmits at

its own convenience (IFF send window allows!)

Data buffered at transmit bufferMay construct segment per data batchMay wait for certain amount of data

Page 61: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

Deliver (to application)In absence of push, deliver data at own

convenienceMay deliver as each in-order segment

receivedMay buffer data from more than one

segment

Page 62: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

AcceptSegments may arrive out of orderIn order

Only accept segments in order Discard out of order segments

In windows Accept all segments within receive window

Page 63: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

RetransmitTCP maintains queue of segments

transmitted but not acknowledgedTCP will retransmit if not ACKed in given

time First only Batch Individual

Page 64: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

AcknowledgementImmediate

as soon as segment arrives. will introduce extra network traffic Keeps sender’s pipe open

Cumulative Wait a bit before sending ACK (called “delayed

ACK”) Must use timer to insure ACK is sent Less network traffic May let sender’s pipe fill if not timely!

Page 65: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

UDP: User Datagram Protocol [RFC 768]

“no frills,” “bare bones” Internet transport protocol

“best effort” service, UDP segments may be: lost delivered out of order

to app connectionless:

no handshaking between UDP sender, receiver

each UDP segment handled independently of others

Why is there a UDP? no connection

establishment (which can add delay)

simple: no connection state at sender, receiver

small segment header no congestion control:

UDP can blast away as fast as desired

Page 66: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

UDP: more often used for streaming

multimedia apps loss tolerant rate sensitive

other UDP uses DNS SNMP

reliable transfer over UDP: add reliability at application layer application-specific

error recover!

source port # dest port #

32 bits

Applicationdata

(message)

UDP segment format

length checksumLength, in

bytes of UDPsegment,including

header

Page 67: Data Communication and Networks Lecture 9/10 Internet Protocols November 6, 2003 Joseph Conron Computer Science Department New York University jconron@cs.nyu.edu.

UDP UsesInward data collectionOutward data disseminationRequest-ResponseReal time application