Transport Protocols and
Distributed Applications
EP1100
Data Communications
and Computer Networks
Illustrations in this material are collected from
Behrouz A Forouzan, Data Communications
EP1100 Datakommunikation och datornät 3
Today’s Lecture
•
Transport Protocols
End-to-end packet transmission
TCP—connection-oriented transmission
UDP—datagram transmission
•
Distributed Applications
the Client-Server communication model
DNS, Mail, FTP, WWW, SNMP
DHCP
EP1100 Datakommunikation och datornät
Transport services and protocols
• Providelogical
communicationbetween app processes running on different hosts
• Transport protocols run in
end systems
send side: breaks app
messages into
segments, passes to network layer
receive side:
reassembles segments into messages, passes to app layer
• More than one transport
protocol available to apps
Internet: TCP and UDP
application transport network data link physical application transport network data link physical logica l en d-e nd tran sport
EP1100 Datakommunikation och datornät 5
Internet transport-layer protocols
• Reliable, in-order delivery
(TCP) congestion control error control flow control connection setup • Unreliable, unordered delivery: UDP no-frills extension of “best-effort” IP
• Services not available:
delay guarantees bit-rate guarantees application transport network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical application transport network data link physical logica l en d-e nd tran sport
Multiplexing/demultiplexing
application transport network link physical P1 application transport network link physical application transport network link physical P2 P3 P1 P4host 1 host 2 host 3
= process = socket
delivering received segments to correct socket
Demultiplexing at rcv host:
gathering data from multiple sockets, enveloping data with header (later used for demultiplexing)
EP1100 Datakommunikation och datornät 7
How demultiplexing works
• Host receives IP datagrams
each datagram has
source IP address, destination IP address
each datagram carries
one transport-layer segment
each segment has
source, destination port number
• Host uses IP addresses & port numbers to direct segment to appropriate socket
source port # dest port #
32 bits
application data (message) other header fields
TCP/UDP segment format
EP1100 Datakommunikation och datornät
Application Addressing
TCP UDP ICMP OSPF
SNMP BGP SMTP FTP HTTP DNS
IP
IEEE 802.3 IEEE 802.11 SONET/SDH PPP IP Protocol
EP1100 Datakommunikation och datornät 9
Client-Server Model
• Server uses a ”well known port number” ICANN/IANA
o Internet Corporation for Assigned Names and Numbers
o Internet Assigned Numbers Authority
• Client port numbers are assigned dynamically ”Ephemeral” ports
Some Well Known Port Numbers
Description Protocol
Name Port
Post Office Protocol ver 3 UDP/TCP
pop3 110
Post Office Protocol ver 2 UDP/TCP
pop2 109
USENET News Transfer Protocol TCP
nntp 119
Network Time Protocol UDP/TCP
ntp 123
World Wide Web HTTP UDP/TCP
www 80
Trivial File Transfer Protocol UDP tftp 69 Bootstrap client UDP/TCP bootpc 68 Bootstrap server UDP/TCP bootps 67
Domain name server UDP/TCP dns 53 Mail transfer TCP smtp 25 Terminal TCP telnet 23
File Transfer Protocol (control channel) TCP
ftp 21
File Transfer Protocol (data channel) TCP
ftp-data 20
EP1100 Datakommunikation och datornät 11
User Datagram Protocol (UDP)
• Connectionless datagram service
• Checksum computed over pseudoheader of IP header fields
Source and destination IP addresses Protocol type
Extra field of UDP total length
EP1100 Datakommunikation och datornät
Why Datagrams?
•
Application doesn’t need a reliable service
Periodic updates, statistics, etc
•
Connection-oriented service too costly
Overhead with connection management
•
Application does flow and error control itself
•
Retransmissions are useless
It would arrive too late if retransmitted
•
Multicast
TCP does not support multicast
EP1100 Datakommunikation och datornät 13
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 buffers
socket door TCP send buffer TCP receive buffer socket door segment application writes data application reads data
TCP segment structure
source port # dest port #
32 bits application data (variable length) sequence number acknowledgment number Receive window Urg data pnter checksum F S R P A U head
len usednot
Options (variable length)
ACK: ACK # valid RST, SYN, FIN: connection estab (setup, teardown commands) # bytes rcvr willing to accept counting by bytes of data (not segments!) Internet checksum (as in UDP)
EP1100 Datakommunikation och datornät 15
TCP reliable data transfer
•
TCP creates reliable and orderly service
on top of IP’s unreliable service
•
Pipelined segments
•
Cumulative ACKs
No NACKs
Hybrid between Go-back-N and Selective
Repeat
•
Retransmissions are triggered by
timeout events
duplicate acks
EP1100 Datakommunikation och datornät
TCP Round Trip Time and Timeout
How to set TCP
timeout value?
• Longer than RTT
but RTT varies
• Too short: premature
timeout
unnecessary
retransmissions
• Too long: slow
reaction to segment loss
lowers throughput
How to estimate RTT?
• SampleRTT:measured time from segment transmission until ACK receipt
ignore retransmissions • SampleRTTwill vary, want
estimated RTT “smoother” average over several recent
measurements
How to set timeout?
• Use estimated RTT
• Add four times estimated
EP1100 Datakommunikation och datornät 17
Example RTT estimation
RTT: gaia.cs.umass.edu to fantasia.eurecom.fr 100 150 200 250 300 350 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106 time (seconnds) RT T ( m illi secon ds) SampleRTT Estimated RTTTCP Flow Control
•
Receiver side of TCP
connection has a
receive buffer:
•
Receiver includes
value of receive
window in ACKs
•
Sender limits
unACKed data
guarantees receive buffer doesn’t overflow•
Speed-matching
service
matching the send
rate to the receiving applications drain rate
•
Application process
may be slow at
reading from buffer
EP1100 Datakommunikation och datornät 19
TCP Connection Management
Three way handshake:
Step 1: client host sends TCP SYN segment to server
specifies initial seq #
no data
Step 2: server host receives SYN, replies with SYNACK segment
server allocates buffers
specifies server initial seq. #
Step 3:client receives SYNACK, replies with ACK segment, which may contain data
EP1100 Datakommunikation och datornät
TCP Congestion Control
How does sender perceive congestion?
•
loss event = timeout or 3 duplicate acks
•
TCP sender reduces rate after loss event
Mechanism
•
Sliding window
Window size must be variable
o To allow full utilization over paths of different length o To control the sending rate to avoid persistent congestion
•
Modes of varying the window size
Slow start
EP1100 Datakommunikation och datornät 21
TCP Slow Start
• When connection begins, window = 1
max segment
Example: MSS = 500 bytes & RTT = 200 ms
initial rate = 20 kb/s
• Increase rate fast until threshold
double window every RTT
done by incrementing the window for every ACK received
Slow-start threshold (ssthresh)
o Switch to congestion avoidance mode o set to 65 kB in many implementations o modified in congestion avoidance
• Initial rate is slow but ramps up
exponentially fast Host A one segment RTT Host B time two segments four segments
TCP congestion avoidance
•
Increase transmission rate (window size)
probing for available capacity, until loss occurs
•
Operation
Additive increase:increase window by 1 MSS every RTT until loss detected
Multiplicative decrease:cut window in half after loss
o Slow-start threshold is set to this value
Time out reduces window to minimum
EP1100 Datakommunikation och datornät 23
Flow and congestion control combined
•
Receiver window—advertised by
receiver
•
Congestion window—TCP congestion
control
Sliding window, moved forward by ACKs
(self-clocking)
Window size increased for every ACK
Window size reduced at time out and loss
Window
size Packet loss Max size
Tid
sender window = min(receiver window, congestion window)
EP1100 Datakommunikation och datornät
Fairness
Fairness and UDP
• Multimedia apps often do
not use TCP
do not want rate throttled by congestion control
• Instead use UDP
pump audio/video at constant rate, tolerate packet loss
May starve TCP
connections that react to loss
Fairness and parallel TCP connections
• Nothing prevents app from
opening parallel connections between 2 hosts.
Web browsers do this
• Example: link of rate R
supporting 9 connections; new app asks for 1 TCP, gets
rate R/10
new app asks for 11 TCPs, gets more than R/2!
EP1100 Datakommunikation och datornät 25
Summary
•
Principles behind transport layer services:
multiplexing, demultiplexing
reliable data transfer
flow control
congestion control
•
Instantiation and implementation in the
Internet
UDP
TCP
Technology Trends
• Transport protocols define services over Internet
TCP: reliable delivery without rate and delay guarantee UDP: best effort as given by the network
• New protocols
trade-off between reliability, delay and rate (soft QoS) support multimedia streaming services
o rate based congestion control
support for multicast (multiple receivers)
o problem with feedback must be solved
• Overlays (peer-to-peer)
sessions pair-wise between peers
a path might include multiple transport protocol sessions end-to-end semantic of TCP is lost
EP1100 Datakommunikation och datornät 27
Technology Trends
•
TCP trends
improve performance over wireless links
with or without link level retransmissions
o high bit error rates
o paths with high delay variations
improve throughput over high-capacity
paths
o eg, multi-Gb/s links between computer centers
resource sharing with non-TCP traffic
o policy for the sharing (definition of fairness)
— TCP friendly congestion control
EP1100 Datakommunikation och datornät
Applications
• Domain Name System (DNS)
to allow symbolic names instead of numeric IP addresses
• Simple Message Transfer Protocol (SMTP)
the basic protocol of e-mail communication
• File Transfer Protocol (FTP)
• Hypertext Transfer Protocol (HTTP): for Web browsing • Simple Network Management Protocol (SNMP)
To manage network devices
• Dynamic Host Configuration Protocol (DHCP)
Autoconfiguration
Domain Name System (DNS)
DNS
•
Translate host name to IP address
www.ee.kth.se
Î
130.237.43.45
•
3 generations of translations
HOSTS.TXT
DNS
EP1100 Datakommunikation och datornät 31
Hierarchical Name Space
• www.ee.kth.se, ftp.internic.net, google.com, ...
• Internet Corporation for Assigned Names and Numbers
(ICANN)
distribution of IP addresses and domain names
o ensures that a domain name maps to correct IP address
autonomous system ("AS") numbers protocol ports and parameter numbers.
EP1100 Datakommunikation och datornät
Hierarchy of Name Servers
• Root servers
List of all top level domains http://data.iana.org/TLD/tlds-alpha-by-domain.txt
• Country Code Top Level Domains, cc-TLD
.uk, .de, .jp, .us, .se, et c.
• Generic Top Level Domains, gTLD
.aero, .asia, .biz, .cat, .com, .coop, .edu, .gov, .info, .jobs, .mobi, .int, .mil, .museum, .name, .net, .org, .pro, .tel and .travel
o .gov for the United States Government .mil for the United States Military
o .edu for accredited postsecondary institutions
EP1100 Datakommunikation och datornät 33
Name Lookup (Resolution)
•
Request/response
•
A client is assigned a
set of DNS servers
•
DNS servers remember
previous lookups
EP1100 Datakommunikation och datornät 35
Simple Mail Transfer Protocol (SMTP)
•
SMTP delivers mail to a user’s mailbox
Normally via an outgoing SMTP mail server
EP1100 Datakommunikation och datornät
SMTP Mail Format
•
Plain text
•
MIME encoding of
non-text data
Multipurpose
Internet Mail
Extension
Mail From: [email protected] RCPT TO: [email protected] From: Alice
To: Bob
Date: 2004-02-19 08:01 Subject: Important mail
EP1100 Datakommunikation och datornät 37
User Mail Delivery
POP, IMAP, WWW, ...
File Transfer Protocol (FTP)
• File transfers between computers • TCP
Normally two connections Data and control (ports 20 and 21)
World Wide Web
EP1100 Datakommunikation och datornät
World Wide Web
• Distributed system
CERN 1989
Tim Berners-Lee and Robert Cailliau
• Hypertext
EP1100 Datakommunikation och datornät 41
Uniform Resource Locator
• Identifies the location for a document on the Internet and a method to access it
Method: eg, http, https, ftp Host: host name within a domain
o default is www, eg www.kth.se Port: default is port 80; often omitted Path to a subdirectory
o www.ee.kth.se/lcn
• The file name is appended to the URL www.ee.kth.se/lcn/index.html
Default is index.html or index.htm
Hypertext Transfer Protocol (HTTP)
• Methods
GET – request a document HEAD – request information about POST – send information from
client
PUT – send document
TRACE – echos incoming request CONNECT
EP1100 Datakommunikation och datornät 43
Hypertext Markup Language (HTML)
<HTML> <HEAD> <TITLE> My Web Page </TITLE> </HEAD> <BODY> <H1>
Welcome to My Web Page! </H1>
<P>
This is my web page. It has a
<A href=“http://www.somewhere.com/ anotherpage.html”>
link to another web page. </A>
</P> </BODY> </HTML>
EP1100 Datakommunikation och datornät
Persistent and Non-persistent Connections
•
One TCP connection per HTTP
request/response
•
Setting up a TCP connection is
costly (slow)
•
With persistent connections, the
server leaves the TCP connection
open
More request/responses over same
EP1100 Datakommunikation och datornät 45
Non-Static Pages
•
Run a program on the server to create the
page
”Server-side includes” (SSI)
o HTML ”macros” evaluated by the web server — ”.shtml” extension
Dynamic pages
o CGI, PHP, ASP, ...
•
Get a program from the server and run it on
the client
Active pages
o Java, JavaScript, ...
Extensible Markup Language (XML)
<?xml version="1.0" encoding=“ISO-8859-1"?>
<?xml-stylesheat type=“text/xsl” href=“contact.xsl”> <Contacts name=“Job contacts“>
<Contact> <Name><G. Persson></Name> <Phone>+4686981222</Phone> <Email>[email protected]</Email> </Contact> <Contact> <Name><B. Gates></Name> <Phone>+14029981234</Phone> <Email>[email protected]</Email> </Contact>
• For creating specific markup languages
• Data description
• Presentation of the data through style sheets CSS, XSL
EP1100 Datakommunikation och datornät 47
XML Example: RSS
•
“Real Simple Syndication”
Atom is a similar and on the IETF
standardization track
•
Syndication: providing automated
updates with RSS/Atom/…
•
News sites, blogs, …
•
News readers (aggregators) check
feeds for updates
“Live Bookmarks”
EP1100 Datakommunikation och datornät
Network Management
• Simple Network Management Protocol (SNMP)
• To monitor and control network devices (interface cards, routers, etc.)
• Elements:
manager: machine with special software (client) agents: small software in each managed device (server) management information base (MIB) : the set of
managable objects in each device
• Processes:
the manager gets and sets parameters from the MIB agents notify the manager of significant events • UDP, port 161
EP1100 Datakommunikation och datornät 49
Dynamic Host Configuration Protocol
• IP address
Static or dynamic (leasing)
• Subnet mask
• IP address of default router (”gateway”)
• IP address of DNS server Internet DNS Gateway Subnet DHCP Mail
NAT and Private Network Addresses
• Network Address Translation
• NAT box gets a global address via DHCP
• Changes address fields in all packets going to/from private network Internet 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8 Private networks DNS DHCP Gateway NAT Private network ISP
Voice over IP
EP1100 Datakommunikation och datornät
Voice over IP
•
Voice calls over IP networks
”IP-telephony”, ”Voice over packet”,
...
•
Integration
Voice and data in the same network
Applications may integrate different
media
EP1100 Datakommunikation och datornät 53
VoIP Protocols
•
Signalling
Keep track of users, call set up and tear-down, etc.
Session Initiation Protocol (SIP), H.323
•
Media
Transport voice calls in IP packets
Real-Time Transport Protocol (RTP)
•
Support
Name-address translation, AAA (Authentication,
Accounting, Authorization), Quality of service, ...
DNS, TRIP, COPS, Diameter, ...
Session Initiation Protocol (SIP)
•
Establishing session
VoIP calls
Instant messaging
Presense
Event notification
•
Tracking users
EP1100 Datakommunikation och datornät 55
Simple Session Directly Between Parties
EP1100 Datakommunikation och datornät
SIP Distributed Architecture
Redirect Server Location Server Registrar Server User Agent Proxy Server Gateway PSTN SIP Components Proxy Server From http://www.vovida.org/document/protocol.html
EP1100 Datakommunikation och datornät 57
SIP Call Setup
From http://www.vovida.org/document/protocol.html 302 (Moved Temporarily) INVITE 200 (OK) 200 (OK) ACK INVITE 302 (Moved Temporarily) ACK INVITE 180 (Ringing) 180 (Ringing) 180 (Ringing) 200 (OK) ACK ACK ACK RTP MEDIA PATH BYE BYE BYE 200 (OK) 200 (OK) 200 (OK) Call Teardown Media Path Call Setup INVITE Location/Redirect Server
Proxy Server Proxy Server User Agent User Agent
INVITE
Real-Time Transport Protocol (RTP)
• Runs over UDP
When used in SIP: Established using Session Description Protocol (SDP), attached to SIP INVITE method and 1xx responses.
• Designed for adaptive (elastic) applications, which can
adjust sender/receiver to varying traffic conditions
• Each RTP packet contains:
Sequence number
Timestamp (time when sent)
Synchronization Source Identifier (SRC) Payload – sound samples
o Example: 8-bit samples, sampling rate 8000 Hz, packet
EP1100 Datakommunikation och datornät 59
RTCP—RTP Control Protocol
•
Reports packet losses and delay between RTP
endpoints
•
Sender Report (SR)
Sender counts (packets sent, bytes sent)
Timestamp
•
Receiver Report (RR)
Receiver counts (packets received, lost)
Jitter (variations in inter-packet delay)
Last SR timestamp received
Delay since last SR (time between receiving SR and
sending RR)
EP1100 Datakommunikation och datornät
Peer-to-Peer (P2P) Architectures
• Hosts communicate directly with each other
Community of hosts P2P network
• File sharing
Napster, Gnutella, KaZaA, BitTorrent, … Content-location problem
Major part of traffic on the Internet today Copyright issues
• IP telephony
Skype
o Only for locating and addressing parties o Calls are point-to-point using UDP or TCP (!)
EP1100 Datakommunikation och datornät 61
Summary
•
Transport protocols
TCP: how to achieve
reliable transfer over IP o retransmission o congestion control UDP: an unreliable transport protocol
•
Distributed
applications
the client-server model Applications o DNS o SMTP o FTP o SNMP o HTTP o DHCPo Voice over IP (SIP) o RTP