Internet Protocol Suite (TCP/IP)

Commonly referred to as TCP/IP, this is the collection of protocols and general rules/framework for how the Internet, and communication across it, should work. The three foundational protocols are the Transmission Control Protocol (TCP), the User Datagram Protocol (UDP), and the Internet Protocol (IP).

The first versions of the modern IP Suite were developed by DARPA with funding from the US Department of Defense.

IP

Link to original

TCP/IP

  • Transmission Control Protocol/Internet Protocol
  • The Internet Protocol Suite
  • Foundational protocols are:
  • Provides end-to-end data communication specifying how data should be packetized, addressed, transmitted, routed, and received
  • Organized into 4 abstraction layers which classify all related protocols according to each protocol’s scope of networking. An implementation of the layers for a particular application forms a protocol stack.
    • Link Layer: contains communication methods for data that remains within a single network segment (link)
    • Internet Layer: provides internetworking between independent networks
    • Transport Layer: handles host-to-host communication
    • Application Layer: provides process-to-process data exchange for applications
  • Maintained by IETF
  • Predates OSI Model

Transmission Control Protocol (TCP)

Functions/Features

  • TCP is connection-oriented
    • Before actually sending data to the destination host, the two hosts communicate to establish a connection. Once the connection is established, the data exchange begins
  • TCP provides reliable communication
    • The destination host must acknowledge that it received each TCP segment
    • If a segment isn’t acknowledged, it is sent again.
  • TCP provides sequencing
    • Sequence numbers in the TCP header allow destination hosts to put segments in the correct order even if they arrive out of order
  • TCP provides flow control
    • The destination host can tell the source host to increase/decrease the rate that data is sent

Establishing/Termination Connections

Handshakes

Three-way (Establishing Connection)

Say there’s two hosts; PC1 and SRV1. PC1 wants to establish a connection with SRV1. Here’s how that works:

  1. PC1 sends a segment to SRV1 with the SYN flag set
  2. SRV1 responds with a segment with the SYN and ACK flags both set
  3. PC1 sends a segment with ACK set These first three messages, the Three-way Handshake, only establish a connection. They do not transfer any meaningful data. Remember: SYN SYN/ACK ACK
sequenceDiagram
PC1->>SRV1: SYN
SRV1->>PC1: SYN ACK
PC1->>SRV1: ACK

Four-way (Terminating Connection)

Same setup, PC1 initiates a connection with SRV1. Now PC1 wants to end the connection.

  1. PC1 sends a segment with the FIN flag set
  2. SRV1 responds with ACK
  3. Then, before PC1 sends another segment, SRV1 sends another message with FIN set
  4. Finally PC1 sends ACK
sequenceDiagram
PC1->>SRV1: FIN
SRV1->>PC1: ACK
SRV1->>PC1: FIN
PC1->>SRV1: ACK

Sequencing

Forward Acknowledgement

When a host receives a TCP segment that requires an acknowledgement, it will respond with a segment whose Acknowledgement Number = 1 + the previous message’s Sequence Number. This is next sequence number the host expects to receive. The initial Sequence numbers are chosen arbitrarily/randomly.

Flow Control

  • Acknowledging every single segment, no matter what size, is inefficient
  • The TCP header’s Window Size field allows more data to be sent before an acknowledgement is required.
    • Multiple segments may be sent before an acknowledgement is required
  • A ‘sliding window’ can be used to dynamically adjust how large the window size is

User Datagram Protocol (UDP)

  • UDP is not connection-oriented
    • The sending host does not establish a connection with the destination host before sending data, it is simply sent
  • UDP does not provide reliable communication
    • When UDP is used, acknowledgments are not sent for received segments. If a segment is lost, UDP has no mechanism to re-transmit it. Segments are sent ‘best-effort’
  • UDP does not provide sequencing
    • There is no sequence number field in the UDP header. If segments arrive out of order, UDP has no mechanism to put them back in order
  • UDP does not provide flow control
    • UDP has no mechanism like TCP’s window size to control the flow of data

Header

  • Just 4 fields: Source port, Destination port, Length, & Checksum
    • All are 2 bytes long

TCP Vs UDP

  • TCP provides more features than UDP, but at the cost of additional overhead
  • For applications that require reliable communications (for example downloading a file), TCP is preferred
  • For applications like real-time voice and video, UDP is preferred
  • There are some applications that use UDP, but provide reliability, etc. within the application itself
  • Some applications use both TCP & UDP, depending on the situation

Noteworthy Port Numbers

TCP

  • 20 - FTP Data
  • 21 - FTP Control
  • 22 - SSH
  • 23 - Telnet
  • 25 - SMTP
  • 80 - HTTP
  • 110 - POP3
  • 443 - HTTPS

UDP

  • 67 - DHCP Server
  • 68 - DHCP Client
  • 69 - TFTP
  • 161 - SNMP Agent
  • 162 - SNMP Manager
  • 514 - Syslog

TCP & UDP

  • 53 - DNS

Internet Protocol (IP)