TCP - Department of Computer Engineering

Download Report

Transcript TCP - Department of Computer Engineering

Transport Layer Protocols –
UDP and TCP
Asst. Prof. Chaiporn Jaikaeo, Ph.D.
[email protected]
http://www.cpe.ku.ac.th/~cpj
Computer Engineering Department
Kasetsart University, Bangkok, Thailand
Adapted from the notes by Lami Kaya and lecture slides from Anan Phonphoem
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
© The McGraw-Hill Companies, Inc.
Outline



Transport Layer
User Datagram Protocol (UDP)
Transmission Control Protocol (TCP)
2
TCP/IP protocol Suite
Application
Application
Transport
Transport
Network
Network
Network
Data Link
Data
Data
Data Link
Physical
Phy
Phy
Physical
3
Issues in Network Layer


No/Little error detection
No attempt to correct





Retransmission
Point-to-point (connectionless)
No handshaking
No verification
No flow control
4
Transport Protocol

Set of rules



for exchange control message / data
End-to-End
Application may by-pass Transport Layer



build functions on top of IP
reduce overhead
application run on switch/router that has no
Transport Layer
5
Transport Protocols




User Datagram Protocol (UDP)
Transmission Control Protocol (TCP)
Stream Control Transmission Protocol (SCTP)
Real-Time Transport Protocol (RTP)
6
Ports and Addresses

IP address is the end point of identifier


On same machine (same IP)



source / destination
needs identifier for each application
multiple applications (e.g. 3 ftp sessions)
“Port”

16-bit number (65,356 ports) for each IP
7
Ports and Addresses


Unique connection identifier
[source IP] + [source port]
+ [dest. IP] + [dest. port]
Web #1 [Src 3.5.10.7:3213, Dst 158.108.1.2:80]
Web #2 [Src 57.2.1.9:4121, Dst 158.108.1.2:80]
Ftp [Src 1.2.1.1:9785, Dst 158.108.1.2:21]
IP address: 158.108.1.2
8
Ports and Addresses


Known destination IP
Concern Issues



destination port ?
listen port ?
IANA* divides ports into three ranges



well-known ports
registered ports
dynamic / private ports
*IANA – The Internet Assigned Numbers Authority
9
Well-known ports



0 – 1023
Used by server applications
Use with restricted privileges (root)
10
Registered Ports



1024 – 49,151
Assigned by IANA
Used for server applications


Allow client to make contact
Can be used by ordinary users
11
Dynamic / Private ports


49,152 – 65,535
Ephemeral (temporary) ports




as-needed basis
freed up when done
Assigned by local machines
Cannot be registered with IANA
12
Connection-Oriented Transport

Advantages





Disadvantages




easy to communicate (if receiver is there!)
verify the real receiver
establish connection
agree on some protocols
transfer data
error correction
tear down connection
heavier-weight protocol
sophisticated implementation (keep state)
consume high bandwidth for management
TCP – Transmission Control Protocol
13
Connectionless Transport


Datagram approach
Advantages




rapid data transfer
no connection setup
no need for connection maintenances
Disadvantages




transfer data
not reliable (losses are expected)
out of order packets
application more complex (takes precautions)
UDP – User Datagram Protocol
14
Outline



Transport Layer
User Datagram Protocol (UDP)
Transmission Control Protocol (TCP)
15
User Datagram Protocol (UDP)

Characteristics





No error detection/recovery
No flow control
No checking for existing of destination
Simple services
Very useful protocol
16
UDP Basic Functions

Provides basic functions above raw IP


Port addressing – to specific application
Data integrity verification – checksum
17
UDP Message Format
Total length = UDP header+ Payload ≤ 216 bytes
18
UDP Message Fragmentation
UDP Header
DataData
Transport Layer
IP Layer
IP Header
Payload
IP Header
Data
19
Protocols that use UDP



TFTP (trivial FTP)
BOOTP (for diskless station)
Network Time Protocol (NTP)


Network File System (NFS)


need basic delivery and checksum
need low overhead
Many multimedia applications


need low latency
losses are acceptable
20
Outline



Transport Layer
User Datagram Protocol (UDP)
Transmission Control Protocol (TCP)
21
Transmission Control Protocol (TCP)



Most popular/important in Internet
Reliable transport protocol
Connection-oriented



need connection establishment
[IP+source port]  [IP+destination port]
guarantee error-free / in-order delivery
22
TCP Messages (Segment)
23
Making connection

Application on server



Client
Server
passive receive mode
listening by issue Listen request to socket
locally
Application on Client

request to socket API locally with



destination IP
destination port
(source port: if not specify, TCP assigns private
port)
24
TCP Connection Establishment
Internet
Server
Application
Client
TCP stack
TCP stack
Passive Open
Application
Active Open
Open Req
Open Ready
Open Ready
3-way Handshake
25
TCP Segments

Segment size



at source node = MTU local link
fit in IP packet
may be fragmented along the way
TCP Header
Data
Transport Layer
IP Layer
IP Header
Payload
IP Header
Data
26
Data Transmission (I)
Internet
Server
Application
TCP stack
Client
TCP stack
Application
Send Req.
1500 bytes
Seq. 1 ; length 1000
Ack 1001
Seq. 1001 ; length 500 Push
Ack 1501
Rec. 1000 bytes
Rec. 500 bytes
27
Flow Control

A process of managing rate of data
transmission between two devices

Make sure fast sender does not overwhelm slow
receiver
Take this
Take this
Take this
:

I'm running
out of buffer!
TCP uses Windowing Flow Control
28
TCP Window Control
Send Buffer
Recv. Buffer
Win
Win
Win
Win
29
Closing Connection (By either end)
Internet
Server
Application
TCP stack
Data
Last Data Segment
Client
TCP stack
Ack
1 byte
Close req (Empty Data) Fin Flag; Seq.= n + 1
Close
Application
Data
Close
Fin Flag; Ack = n+2; Seq.= m + 1
Ack = m + 2
Close Resp
3-way Handshake
30
Protocols that use TCP





File Transfer Protocol (FTP)
Hypertext Transfer Protocol (HTTP)
Simple Mail Transfer Protocol (SMTP)
Post Office Protocol (POP3)
Telnet
31
Choosing between TCP and UDP

TCP


reliable transport services
UDP


non-reliable transport services
only delivery data to specific port
32
Summary

Transport Layer


User Datagram Protocol (UDP)



port & IP address
packet format (8-byte header)
functions
Transmission Control Protocol (TCP)



packet format ( 20-byte header)
connection establishment / tear down
window control
33