TCP/IP is the glue that holds the Internet together. Without it, or an equivalent standard, the Internet as we know it today could not exist.TCP/IP is actually two separate protocols, although TCP depends on IP. IP (Internet Protocol) is responsible for addressing, enabling long data streams to be divided into separate packages that are then sent separately through the network. It operates in a best effort manner; thus, packets may be lost enroute and/or they may arrive out of sequence. TCP addresses these issues.
TCP (Transmission Control Protocol) uses IP to exchange acknowledgments and other messages between sender and receiver. Thus, a sender can send a designated packet and wait for an acknowledgment. When the sender knows the packet has arrived safely, it can send the next packet, etc. However, if the acknowledgment does not come in a reasonable length of time, the sender assumes it was lost and resends it. Actually, the process is much more efficient and much more involved than this oversimplified scenario, but it suggests the flavor of interaction supported by TCP.
The result is that TCP is able to provide the illusion that sender and receiver are connected to one another, similar to a telephone connection. However, that illusion does not include any guarantee about how quickly packets will be delivered. Thus, it is not particularly well-suited for applications that require low latency, such as real-time audio and video. Proposed extensions to IP will address some of these concerns, but whether a next-generation TCP/IP will prove to be all-inclusive in its capabilities is yet to be demonstrated.
Background
- Wide Area Networks (WANs)
- Special purpose computer to computer connections (routers)
- Long distances
- Telephone lines or satellite communications
- Modems
- Lower bandwidth (generally)
- Prior to internetworking, incompatible with LANs
- After internetworking, connect LANs into single virtual network (internetwork)
- Internet topology
- Network of separate LANs joined by WANs
- routers
- backbone
- mid-level network
- LANs
- hosts
- TCP/IP plays central role in the Internet
Internet Protocol (IP)
- IP is an unreliable, best-effort. connectionless packet delivery system
- Three basic functions:
- defines basic unit of transfer (packet or
datagram )- routing
- defines rules of operation (e.g., when to discard packet)
- Packet (datagram) format
- header
- version: 4
- header length: 4 (# of 32-bit words)
- service type: 8
- total length: 16
- identification: 16
- flags: 3
- fragment offset: 13 (# of 8-octets)
- time to live: 8
- protocol: 8
- header checksum: 16
- source IP address: 32
- destination IP address: 32
- IP options: 24
- padding: 8
- data: <64k
![]()
IP Datagram.
Adapted from Comer,IWTCP/IP, Figure 7.3.
- Encapsulation
- Ethernet
- datagrams
- Fragmentation
- problem: different maximum transfer units (MTUs) for constituent LANs
- router fragments datagram
- duplicates most of header
- adds fragment offset
- fragmented datagrams reassembled by destination host
- Routing
- performed (usually) by special-purpose computer, called a router (gateway)
- IP address
- form: X.X.X.X
- example: 152.2.128.184
- domain name
- unrelated to IP address
- form: host.domain, where domain is usually network.type
- domain names meant for human consumption
- domain names are mapped to IP addresses by a domain name server (DNS)
- direct routing
- performed by router or host when destination on same network
- map IP address into physical (e.g., Ethernet) address
- encapsulate datagram into network packet (e.g., Ethernet frame)
- deliver it to destination using network resources (e.g., send over Ethernet wire)
- indirect routing
- router to router transfers, concluding with a single direct routing transfer
- router uses IP routing table to determine where to send datagram ("next hop")
- pairs of IP addresses: (destination, next hop)
- next hop connected to router's network
- default next hop, to reduce size of table
Transmission Control Protocol (TCP)
- TCP provides a reliable, error-free virtual connection for two-way stream-oriented transfer of data
- Five basic features:
- delivers streams of bits with guaranteed delivery in the same order as sent
- virtual circuit connection
- buffered transfer with push semantics
- unstructured data stream
- full duplex connection
- Reliability provided through positive acknowledgment with retransmission strategy
- Ideal communication
- Sender sends Packet 1
- Receiver receives Packet 1
- Receiver sends acknowledgment (ACK) for Packet 1
- Sender receives ACK 1
- Sender sends Packet 2
- Receiver receives Packet 2
- Receiver sends ACK2
- Sender receives ACK2
- Etc.
- Faulty communication
- Sender sends Packet 1
- Sender starts timer
- Receiver does not receive Packet 1
- Sender timer expires
- Sender resends Packet 1
- Sender starts timer
- Receiver receives Packet 1
- Receiver sends ACK1
- Sender receives ACK1
- Sender cancels timer
- Etc.
- Sliding Window
- Sender sends Packet 1 and starts Timer 1
- Sender sends Packet 2 and starts Timer 2
- Sender sends Packet N and starts Timer N
- Receiver receives Packet 1 and sends ACK 1
- Receiver receives Packet 2 and sends ACK 2
- Receiver receives Packet N and sends ACK N
- Sender receives ACK 1 before Timer 1 expires
- Sender receives ACK 2 before Timer 2 expires
- Sender receives ACK N before Timer N expires
- Etc.
- Connection
- Connection is a basic TCP abstraction defined by a pair of endpoints
- Endpoint is a pair: (host, port)
- host is the host's IP address
- port is a TCP port on the host
- Operations using connections described below
- TCP Segments
- Data stream transmitted in segments, usually encapsulated within single IP packets
- Concept of sliding window of octets used
- Sender maintains pointers to octets in sequence sent, those ready to be sent but not sent, and those not ready to be sent
- Receiver sends acknowledgment of octets received plus advertisement of number it is prepared to receive
- Segment structure
- Header
- source port
- destination port
- sequence number
- acknowledgment number
- header length
- reserved
- code bits
- URG
- ACK
- PSH
- RST
- SYN
- FIN
- window
- checksum
- urgent pointer
- options
- padding
- data
![]()
TCP Segment.
Adapted from Comer,IWTCP/IP, Figure 13.7.
- Establishing TCP connection
- Receiver sends passive open request to operating system, saying it is open for business
- OS assigns Receiver TCP port number, often a well-known number, e.g., port 80
- Time passes . . .
- Sender sends message (TCP segment) requesting connection with SYN bit set and SEQ=some random number; also sends seq=x, where x is random
- Receiver receives message and returns message with SYN and ACK bits set; also saves seq=x, and sends seq=y and x+1(seq. number of first octet it expects to receive)
- Sender receives ACK message and sends its own ACK message back to Receiver; also saves y and sends y+1, confirming receipt of y
- Receiver receives Senders ACK message
- Connection is, thus, established
- Closing TCP connection
- Sender closes connection
- Sender sends close connection message with FIN bit set
- Receiver receives close message and returns message with FIN and ACK bits set
- Sender receives ACK message
- Receiver closes connection
- Receiver sends message with FIN and ACK bits set
- Sender receives FIN and ACK message
- Sender sends ACK message
- Receiver receives Senders ACK message
- Connection is, thus, closed