Lecture 11 Process-to-process Delivery UDP and TCP
Textbook: Ch. 23, 24
SEHH2238 Computer Networking
SEHH2238 Lecture 11 1
Copyright By PowCoder代写 加微信 powcoder
SEHH2238 Computer Networking
Transport Layer
Transport Layer Protocol
TCP (24.3)
Transport-Layer Services
Port Number and Socket Address
Transport Layer in TCP/IP (24.1) UDP (24.2)
User Datagram Format
UDP Applications and Examples
Main Topics
TCP Connection Establishment
TCP Data Transfer
Sequence Number and Acknowledgement
Retransmission and Timeout
SEHH2238 Lecture 11 2
SEHH2238 Computer Networking
A. Transport Layer
The transport layer is located between the application layer and the network layer.
It provides a process-to-process communication between two application layers, one at the local host and the other at the remote host.
Communication is provided using a logical connection.
SEHH2238 Lecture 11
SEHH2238 Computer Networking
Idea behind this logical connection.
Figure 23.1: Logical connection at the transport layer
SEHH2238 Computer Networking
Transport-Layer Services
The transport layer
is responsible for providing services to the
application layer; and
receives services from the network layer.
Process-to-process Communication Process Process Process Process
SEHH2238 Lecture 11 5
SEHH2238 Computer Networking
Addressing : Port Numbers
A computer can run several server programs and/or several client programs at the same time.
To identify a process, a port number is used. E.g. A service called “Daytime” uses 13 as the port
Figure 23.3: Port numbers
SEHH2238 Lecture 11 6
SEHH2238 Computer Networking
Registered ports: 1024 to 49151. IANA maintains the official list.
Port Number
In TCP/IP protocol suite, the port numbers are integers between 0 and 65,535 (16 bits).
Well-knownports:0to1023.
E.g. 23: Telnet remote login, 80: HTTP
Dynamic or private ports: 49152 to 65535. One common use is for temporary ports.
TheFulllistcanbefoundinServiceNameandTransport Protocol Port Number Registry
http://www.iana.org/assignments/service-names-port- numbers/service-names-port-numbers.xhtml
SEHH2238 Computer Networking
Socket Address
The combination of an IP address and a port number is called a socket address.
Figure 23.6: Socket address
SEHH2238 Lecture 11 8
SEHH2238 Computer Networking
B. Transport Layer in TCP/IP
TCP/IP is a set of protocols, or protocol suite, that defines how all transmissions are exchanged across the Internet
TCP/IP is a five-layer protocol: physical, data link, network, transport and application
Transport layer: (2 protocols/services) Transmission Control Protocol (TCP) – data unit is
called TCP segment
User Datagram Protocol (UDP) Network layer: Internet Protocol (IP)
SEHH2238 Lecture 11 9
SEHH2238 Computer Networking
Transport-layer protocols in the TCP/IP protocol suite
Figure 24.1: Position of transport-layer protocols in the TCP/IP protocol suite
SEHH2238 Lecture 11
SEHH2238 Computer Networking
Some well-known UDP and TCP Protocols
Table 24.1: Some well-known ports used with UDP and TCP 11
SEHH2238 Computer Networking
C. User Datagram Protocol (UDP) The User Datagram Protocol (UDP) is a
connectionless, unreliable transport protocol.
UDP packets, called user datagrams, have a fixed-size header of 8 bytes made of four fields, each of 2 bytes (16 bits).
If UDP is so powerless, why would a process want to use it?
UDPisaverysimpleprotocolusingaminimumof overhead.
SEHH2238 Lecture 11 12
SEHH2238 Computer Networking
UDP Format
Thefirsttwofieldsdefinethesourceanddestination port numbers.
Thethirdfielddefinesthetotallengthoftheuser datagram, header plus data.
The 16 bits can define a total length of 0 to 65,535 bytes.
However, the total length needs to be less because a UDP user datagram is stored in an IP datagram with the total length of 65,535 bytes.
Figure 24.2: User datagram packet format
SEHH2238 Lecture 11 13
SEHH2238 Computer Networking
Example 24.1
The following is the contents of a UDP header in hexadecimal format.
a. What is the source port number?
b. What is the destination port number?
c. What is the total length of the user datagram?
d. What is the length of the data?
e. Is the packet directed from a client to a server or vice
f. What is the client process?
SEHH2238 Lecture 11
SEHH2238 Computer Networking
Example 24.1
a. The source port number is the first four hexadecimal
digits (CB84)16 or 52100
b. The destination port number is the second four
hexadecimal digits (000D)16 or 13.
c. The third four hexadecimal digits (001C)16 define the
length of the whole UDP packet as 28 bytes.
d. The length of the data is the length of the whole packet
minus the length of the header, or 28 − 8 = 20 bytes.
e. Since the destination port number is 13 (well-known
port), the packet is from the client to the server. f. The client process is the Daytime (see Table 3.1).
SEHH2238 Lecture 11
SEHH2238 Computer Networking
SEHH2238 Lecture 11
Example 24. 3 – DNS
Domain Name Service (DNS) A client-server application
uses the services of UDP
Because a client needs to send a short request to a server and to receive a quick response from it.
The request and response can each fit in one user datagram.
Quick reference for DNS:
http://www.youtube.com/watch?v=ZBi8GCxk7NQ
http://www.youtube.com/watch?v=2ZUxoi7YNgs
SEHH2238 Computer Networking
SEHH2238 Lecture 11
Real-time interactive application
Audio and video are divided into frames and sent one after another (Such as Skype).
If the transport layer is supposed to resend a corrupted or lost frame,
The synchronizing of the whole transmission may be lost. The viewer suddenly sees a blank screen and needs to wait until the
second transmission arrives. This is not tolerable.
Each small part of the screen is sent using one single user datagram
The receiving UDP can easily ignore the corrupted or lost packet and deliver the rest to the application program.
That part of the screen is blank for a very short period of time,
which most viewers do not even notice.
SEHH2238 Computer Networking
How about downloading a very large text file from the Internet?
Very large text file?
We definitely need to use a transport layer that provides reliable service.
We don’t want part of the file to be missing or corrupted.
Thedelaycreatedbetweenthedeliveriesofthepartsis not an overriding concern for us; we wait until the whole file is composed before looking at it.
In this case, UDP is not a suitable transport layer. Then, use TCP service.
SEHH2238 Lecture 11
SEHH2238 Computer Networking
D. Transmission Control Protocol (TCP)
Transmission Control Protocol (TCP) is a connection-oriented, reliable protocol.
TCP explicitly defines connection establishment, data transfer, and connection teardown phases to provide a connection-oriented service.
TCP uses a combination of Go-back N (GBN) and Selective Repeat (SR) protocols to provide reliability.
SEHH2238 Lecture 11 19
SEHH2238 Computer Networking
TCP Services
TCP provides process-to-process communication using port numbers.
It is a stream-oriented protocol.
TCP creates an environment in which the two processes
seem to be connected by an “imaginary tube” that carries their bytes across the network.
Sending process
Receiving process
Stream of bytes
SEHH2238 Lecture 11
SEHH2238 Computer Networking
Figure 24.7: TCP segment format
TCP Segment
SEHH2238 Lecture 11 21
SEHH2238 Computer Networking
Header Length and Control Field
Header Length (HLEN)
Indicates the number of 4-byte words in the TCP header. Header length is between 20 to 60 bytes.
So, the field is 5 (5×4=20) to 15.
Control Field (6 bits)
ACK – indicate that the value carried in the acknowledgement field
RST, SYN, FIN – for connection setup and teardown (skip details)
PSH – indicate that the receiver should pass the data to the upper layer immediately
URG – indicate that this segment contains urgent data; the location of the last byte is indicated by the urgent data pointer field
SEHH2238 Lecture 11 22
SEHH2238 Computer Networking
TCP is connection-oriented.
TCP Connection
Allofthesegmentsbelongingtoamessagearethensent over this logical path.
Using a single logical pathway for the entire message facilitates the acknowledgment process as well as retransmission of damaged or lost frames.
How TCP, which uses the services of IP, a connectionless protocol, can be connection-oriented?
The point is that a TCP connection is logical, not physical.
TCP operates at a higher level. TCP uses the services of IP to deliver individual segments to the receiver, but it controls the connection itself.
SEHH2238 Lecture 11
SEHH2238 Computer Networking
Connection establishment using three-way handshaking
Figure 24.10: Connection establishment using three-way handshaking
SEHH2238 Computer Networking
Connection Establishment
The server program tells its TCP that it is ready to accept a connection. The request is called a passive open.
When a client wants to connect with the server, it issues a request for active open, and TCP will start a Three- Way Handshaking:
Step One: Client sends a SYN segment (with Clients’ sequence number).
Step Two: Server sends a SYN + ACK segment (with servers’ sequence number).
Step Three: Client sends an ACK segment.
SEHH2238 Lecture 11 25
SEHH2238 Computer Networking
Data Transfer
In the example:
After a connection is established, the client sends 2,000
bytes of data in two segments.
The server then sends 2,000 bytes in one segment. The client sends one more segment.
The first three segments carry both data and acknowledgment, but the last segment carries only an acknowledgment because there is no more data to be sent.
PSH (push) flag set so that the server TCP knows to deliver data to the server process as soon as they are received.
SEHH2238 Lecture 11 26
SEHH2238 Computer Networking
TCP Data transfer
Figure 24.11: Data transfer
SEHH2238 Lecture 11
SEHH2238 Computer Networking
TCP seq. #’s and ACKs
byte stream “number” of
first byte in segment’s User
ACKs: (TCP is full-duplex)
seq#ofnextbyte expected from other side
receipt of ‘C’, responses
cumulative ACK
host ACKs receipt
SEHH2238 Lecture 11
simple telnet scenario
SEHH2238 Computer Networking
TCP Round Trip Time and Timeout
Q: how to set TCP timeout value?
Q: how to estimate RTT?
longerthanRTT but RTT varies
SampleRTT: measured time from segment transmission until ACK receipt
tooshort:premature timeout
ignore retransmissions SampleRTT will vary, want
unnecessary retransmissions
estimated RTT “smoother”
too long: slow reaction to segment loss
average several recent measurements, not just current SampleRTT
SEHH2238 Lecture 11 29
SEHH2238 Computer Networking
TCP Round Trip Time and Timeout
EstimatedRTT =
(1- α)*EstimatedRTT + α*SampleRTT
Exponential weighted moving average influence of past sample decreases
exponentially fast
typical value: α = 0.125
SEHH2238 Lecture 11 30
SEHH2238 Computer Networking
Example of Estimating RTT( E_RTT)
T02:00senddata 2:15 ACK back SampleRTT=15
Assume α=0.1and
initial E_RTT0 = 10 minutes
T12:15senddata 2:28 ACK back SampleRTT=13
E_RTT1= 0.9×10 + 0.1 x 15 = 10.5
T22:30senddata 2:46 ACK back SampleRTT=16
E_RTT2= 0.9×10.5 + 0.1 x 13 = 10.75
T32:50senddata 3:00 ACK back SampleRTT=10
E_RTT3= 0.9×10.75 + 0.1 x 16 = 11.275
T43:00senddata
E_RTT4= 0.9×11.275 + 0.1 x10= 11.1475 SEHH2238 Lecture 11 31
EstimatedRTT =(1- α)*EstimatedRTT + α*SampleRTT
RTT (milliseconds)
SEHH2238 Computer Networking
Example RTT estimation:
RTT: gaia.cs.umass.edu to fantasia.eurecom.fr
1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106
time (seconnds)
SampleRTT Estimated RTT
SEHH2238 Computer Networking
TCP Round Trip Time and Timeout
Setting the timeout
EstimtedRTT plus “safety margin” large variation in EstimatedRTT
-> larger safety margin
first estimate of how much SampleRTT deviates
from EstimatedRTT:
DevRTT = (1-β)*DevRTT + β*|SampleRTT-EstimatedRTT|
(typically, β = 0.25) Then set timeout interval:
TimeoutInterval = EstimatedRTT + 4*DevRTT
SEHH2238 Lecture 11 33
SEHH2238 Computer Networking
Example of Setting Timeout(TO)
T0 2:00 send data 2:15 ACK back SampleRTT=15
Assume β = 0.2 and
initial D_RTT0 = 1 minutes
T1 2:15 send data 2:28 ACK back SampleRTT=13
DevRTT = (1-β)*DevRTT + β*|SampleRTT-EstimatedRTT|
T2 2:30 send data 2:46 ACK back SampleRTT=16
TO1= 10.5 + 4×1.8 = 17.7
T3 2:50 send data 3:00 ACK back SampleRTT=10
D_RTT3=0.8×1.94 +0.2x|16-10.75|=2.60 TO3= 11.275 + 4×2.6 = 21.675
T4 3:00 send data
TO4= 11.1475 + 4×2.335 = 20.4875
TimeoutInterval = EstimatedRTT+4*DevRTT D_RTT1= 0.8×1 + 0.2 x |15-10| = 1.8
D_RTT2= 0.8×1.8 +0.2 x|13-10.5|= 1.94 TO2= 10.75 + 4×1.94 = 18.51
D_RTT4= 0.8×2.60+0.2 x|10-11.275|= 2.335
SEHH2238 Lecture 11 34
SEHH2238 Computer Networking
TCP reliable data transfer
TCP creates reliable data transfer service on top of IP’s unreliable service
Retransmissions are triggered by:
Pipelined segments
Cumulative acks and
Timeout events
Selective Repeat.
Duplicate acks
Initially consider simplified
TCP uses single
retransmission timer (to
reduce overhead) ignore flow control,
TCP sender:
ignore duplicate acks
congestion control
SEHH2238 Lecture 11 35
SEHH2238 Computer Networking
Transport Layer provides process-to-process logical connection
Socket address = IP address + port number
The User Datagram Protocol (UDP) is a
connectionless, unreliable but simple.
TCP creates reliable data transfer service
TCP Round Trip Time and Timeout
SEHH2238 Lecture 11 36
SEHH2238 Computer Networking
References
Video on Comparing UDP and TCP
http://www.youtube.com/watch?v=Vdc8TCESIg8
Revision Quiz
http://highered.mheducation.com/sites/0073376221/stud
ent_view0/chapter23/quizzes.html
http://highered.mheducation.com/sites/0073376221/stud ent_view0/chapter24/quizzes.html
SEHH2238 Lecture 11 37
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com