Title: Transmission Control Protocol
1Transmission Control Protocol
2Review
- How does the router know where to send an IP
packet? - Whats in the packet? Whats in the router?
- How does a destination host know what order a
series of packets was sent in? - If we were to define a streaming audio protocol
as a spanning layer - Where would it have to run?
- Could people use different media players to
listen to audio streamed with this protocol?
3Learning Objectives
- Understand TCP and relationship to IP
- Service
- Protocol
- Commercial Internet Provision
- Network Address Translation
- The End-to-End Principle
4Conceptual Layering of Internet Protocols
Application
HyperText Transport Protocol (HTTP)
Real-time Transport Protocol (RTP)
Application Layer
User Datagram Protocol (UDP)
Transmission Control Protocol (TCP)
Transport Layer
Todays topic
Internet Protocol (IP)
Network Layer
Subnetworks
Physical and Data Link Layer
Last sessions topic
5TCP Services
- TCP picks up where IP leaves off
- Message fragmentation and reassembly
- Packet sequence numbers
- Guarantees delivery
- Error detection
- ACKs and retransmits
- Maintains conversational context
- Sessions
- Specifies process at destination
- Port numbers in TCP packet header
6Layered View of TCP and IP
Reliable connection between peers
TCP
TCP
Best-effort (unreliable) delivery between peers
IP
IP
7Layered Headers
- Each layer adds its own header to the message
that it receives from the layer above - As far as the lower layer is concerned, the
higher layers headers are just a part of the
message to be delivered - The higher layers never see the lower layer
headers because the lower layers remove them
before passing the message up
8Layered Headers In TCP/IP
- The TCP layer fragments a message into packets,
puts headers on the packets, and passes them to
the IP layer - The IP layer adds its own header to each packet
that it receives from TCP - The IP layer removes its header before passing
the delivered packet back to the TCP layer - The TCP layer removes its headers and reassembles
the message before passing the result back to the
layer above
9Generalized View of Layered Communication
Protocols
Layer n1 protocol header
Layer n1
Layer n1
Peer-to-peer operation
Layer n
Layer n
Layer n protocol header
Encapsulated layer n1 packet, including header
10TCP Protocol Message Fragmentation And Reassembly
- TCP client at source divides message into packets
- Each packet gets a sequence number
- Stored in the header
- TCP packet becomes payload of IP packet
- TCP software at destination reassembles
- If arrive out of order, use sequence number
11Header
Payload
Original packet
TCP divides original into packet fragments
Adds headers to new packets and passes to IP to
deliver
At destination, TCP uses headers to correctly
reassemble original packet
12TCP Fragmentation And Sequencing Demo
- Same routing tables as on Thursday
- Dont forget to decrement HopLimit
- New message takes several index cards
- Each index card is a TCP fragment
- The card is placed in a small envelope that has a
TCP header - The small envelope is placed in a big envelope
with an IP header
13Why Fragment Messages?
- If part of message is lost or garbled, you only
have to resend the affected packet(s) - Speed
- Store-and-forward delay is minimized
- A can send packet 1 to B while receiving packet 2
from S - Not possible if whole message sent at once
14TCP Protocol Guaranteed Delivery
- Error Detection on TCP Packets
- Checksum detects if IP packet is corrupt
- E.g., parity check even or odd number of 1s in
payload - If error detected, discard packet
- Sender remembers packets it sent
- Receiver ACKs each packet received
- Clever optimization piggyback ACK to data packet
already flowing other direction - If ACK not received within a specified timeout
interval, the sender resends packet - Receiver may get two copies!
- Just ignore the second one
15TCP Guaranteed Delivery Demo
- Same as before, except
- The sender will retransmit if ACK not received
within the timeout interval - When packet reaches destination, receiver must
acknowledge by telling the class the sequence
number of the packet received - The TCP header includes error checking
information.
16TCP Service Conversational Context
- Two machines must establish a connection before
they can exchange data - Must agree on a session ID before sending first
message - Each message includes the session ID
- At end of conversation the machines agree that
the conversation is over - Called session tear-down
17TCP Service Specify Process at Destination
- TCP packets specify a source and destination port
number - The source and destination port numbers do not
have to be the same - The port number is used to determine which
process (application) will receive the message - For example, port 80 specifies that the message
should be sent to a web server, while port 23
indicates that the message is destined for a
Telnet server
18TCP Service Specify Process at Destination
Port
Port
IP host-to-host
Process
Process
Host
Host
19Identifying A Connection Another Use Of TCP
Ports
- Each side of a TCP connection is referred to as a
socket, and can be identified by the IP address
and port - A logical connection between a source and
destination host is uniquely identified by the
two sockets involved
20Questions?
- About TCP services?
- About anything else?
21TCP Congestion
- If a router is overworked
- Its queues fill up
- It drops additional packets
- Because TCP provides guaranteed delivery through
ACK, the source clients resend the packets - Even more congestion
22TCP Congestion Control
- Start slow, using a low rate of packet sends
- Slowly increase the rate as long as ACKs are
regularly received - Quickly decrease if packet ACKs are slow (not
received within timeout interval) - Called exponential backoff
- The algorithm for determining when and how much
to backoff is a potential opportunity for
innovation - E.g., FAST TCP in optional readings
23Flow Control
- Similar to congestion, but not due to network
interference - Destination hosts own traffic is too much
- Destination unable to receive so fast
- TCP flow control implementation is similar to
solution for congestion control - Receiver can explicitly request lower send rate
in ACKs
24Summary of TCP/IP
- IP
- Best-effort delivery to remote destination
- Globally unique addresses
- Routers forward to next hop
- TCP
- Message fragmentation and reassembly
- Guaranteed delivery
- Sessions
- Port numbers
- Congestion and flow control
25Review
- Which layer in the network protocol stack is
responsible for each of the following? - Breaking a message into smaller pieces for
transmission over the network - Placing a header on the message
- Specifying the destination address
- Specifying the process that will receive the
message - Directing a packet as it travels over the network
26Commercial Provision of TCP/IP
- Internet Access Providers (IAPs)
- Customers connect computer or network to IAP
(ISP) - IAP connects to rest of the Internet
- Routes may involve intermediate transit carriers
- Transit traffic neither source nor destination
address is a direct customer of the carrier - Interconnection between transit carriers
- Peering
- NAPs (multilateral peering between IAPs)
- Paid interconnects (small providers to big ones
that carry lots of transit traffic) - Usually flat rate based on maximum bitrate, not
actual bitrate of transfers
27Internet Interconnections
NAP
Hosts
Big IAPs Subnet
Point of Presence
Small IAP
28More Internet Interconnections
Transit carrier for small IAP
Peering
Hosts
Point of Presence
Small IAP
29NAT Sharing an IP Address
- Network Address Translationthat indirection
thing again - Some IP addresses are not globally unique
designated for local use/reuse - Host has local address behind the NAT device
- NAT translates outgoing packet headers
- Rewrites source IP address to be NATs IP address
- Rewrites source port
- Saves map of internal-external address/port
mappings - Reverse for incoming packet headers
30NAT Example
- Hypothetical example
- Sources internal socket is IP 192.168.0.101,
port 1341 - Translated to IP 68.40.162.3 (address assigned to
customer by IAP) port 5280 - Traffic from NAT device identifies translated
address/port as source - NAT forwards traffic sent to it (IP 68.40.162.3)
with port 5280 to source host (192.168.0.101)
using port 1341
31NAT Example
Messages sent between host B to another host on
the Internet Host B original source
socket 192.168.0.101 port 1341 Host B translated
socket 68.40.162.3 port 5280
IAPs Point of Presence
A
B
C
Router with NAT External IP 68.40.162.3 Internal
IP 192.168.0.0
Router assigns internal IPs to hosts on LAN A
192.168.0.100 B 192.168.0.101 C 192.168.0.102
32NAT Advantages and Disadvantages
- Rest of Internet unaffected
- Transparent benefit of indirection
- Internal addresses dont need to be globally
unique - Allows simultaneous use benefit of local
namespace - Multiple hosts can share one external IP address
- E.g., useful for home networks
- but protocols that depend on IP address of host
(e.g., early versions of Kerberos) get confused - Host says it has an internal IP address
- Different (external) address used for routing
33The End-to-End Principle
- If function needs to be done as
endpoint-to-endpoint service, dont implement it
link-to-link - More generally, if function will need to be
(re)done at higher layer, dont do it at lower
layer - Examples in TCP/IP
- Error detection
- Guaranteed delivery of packets
- Not encryption -- implemented at higher layer
34The End-to-End Principle
Layer n1
Layer n1
If you need it at this layer, implement it here
Layer n
Layer n
And dont implement it here.