To Previous Chapter To Table of Contents To Bottom of Page To Next Chapter

Chapter 4 - TCP and UDP

  1. What is TCP?
    1. connection-oriented protocol responsible for ensuring the transfer of a datagram from source to destination (end-to-end communications)
    2. enables an application in the upper layers to send a datagram via the network layer
    3. ensures that priorities and security are properly respected
    4. virtual circuit - communications between two "end machines"
    5. TCP is only necessary on machines that "process" datagrams (not on gateways)

  2. Following a Message
    1. message is passed to TCP from an upper-layer protocol as a stream
    2. stream of bytes is assembled into TCP segments
    3. header information (checksums and sequence numbers) is attached to the front of the data
    4. in 2-way communications (i.e. ftp & telnet), a connection (virtual circuit) is established between the sending and receiving machines
      1. TCP software issues a request for a TCP connection (sending it it's socket number)
      2. The receiving TCP software returns its own socket number
    5. TCP sends the segment down to the network layer software (usually IP) which sends the message over the network
    6. the receiving machine's IP passes the received segment to it's TCP software which strips the header info and passes the message up
    7. if the message is more than one segment, the receiving TCP reassembles the segments requesting a resend of any corrupted segments
    8. The receiving TCP software may generate an ACK back to the sender
    9. Some TCP implementations use a sliding window (buffer) where the receiver sends a window size before each message is sent
    10. a timer is used to monitor the time between the sending of a message and the ACK back

  3. Ports and Sockets
    • Port Numbers - identifies applications:
      Frequently used TCP port numbers
      Port Number Process Name Description
      1 TCPMUX TCP Port Service Multiplexer
      5 RJE Remote Job Entry
      17 Quote Quote of the Day
      20 FTP-DATA File Transfer Protocol--Data
      21 FTP File Transfer Protocol--Control
      23 TELNET Telnet
      25 SMTP Simple Mail Transfer Protocol
      43 NICNAME Who Is
      79 FINGER Finger
    • WELL KNOWN PORT NUMBERS
    • Socket - IP address of the machine & its port number

  4. TCP Communications with the Upper Layers
    ULP to TCP Service Request Primitives
    Command Parameters Expected
    ABORT Local connection name
    ACTIVE-OPEN Local port, remote socket
    Optional: ULP timeout, timeout action, precedence, security, options
    CLOSE Local connection name
    SEND Local connection name, buffer address, data length, push flag, urgent flag
    Optional: ULP timeout, timeout action

    TCP to ULP Service Request Primitives
    Command Parameters Expected
    CLOSING Local connection name
    DELIVER Local connection name, buffer address, data length, urgent flag
    ERROR Local connection name, error description
    OPEN-ID Local connection name, remote socket, destination address

  5. Passive and Active Ports
    1. active connection - TCP issues a request for a connection, based on an instruction from an ULP that provides the socket number
    2. passive connection - ULP instructs TCP to wait for the arrival of connection requests from a remote system
      1. specified passive open - connection created when the precedence and security levels are acceptable
      2. unspecified passive open - connection created for any request

  6. TCP Timers
    • The Retransmission Timer - manages retransmission timeouts (RTOs) [if the time between the send and ACK is exceeded, the message is resent with an increased RTO] (RTT - round-trip time)
    • The Quiet Timer - used to prevent just-closed ports from reopening too soon and receiving datagrams that were delayed [usually = twice the TTL]
    • The Persistence Timer - used when the receive window = 0
    • The Keep-Alive Timer and the Idle Timer - sends empty packets to keep the connection open

  7. Transmission Control Blocks (TCB) and Flow Control
    TCP send and receive variables
    Variable Name Description
    Send Variables
    SND.UNA Send Unacknowledged
    SND.NXT Send Next
    SND.WND Send window
    SND.UP Sequence # of last urgent set
    SND.WL1 Sequence # for last window update
    SND.WL2 Ack # for last window update
    SND.PUSH Seq. # of last pushed set
    ISS Initial send sequence number
    Receive Variables
    RCV.NXT Seq. # of next received set
    RCV.WND # of sets that can be received
    RCV.UP Seq. # of last urgent data
    RCV.IRS Initial receive sequence number

  8. TCP Protocol Data Units
    TCP Protocol Data Unit (PDU)
    Source Port (16 bits) Destination (16 bits)
    Sequence Number (32 bit)
    Acknowledge Number (32 bit)
    Data Offset and Flags Window (16 bits)
    Checksum (16 bits) Urgent Pointer (16 bits)
    Options and Padding

  9. TCP and Connections
    • Establishing a Connection [can be established only if no connection between the two sockets, both machines agree to the connection, and both machines have adequate TCP resources] (see figure 4.6)
    • Data Transfer (see figure 4.7)
      TCP data transport subservices:
      • full duplex - enables both ends of a connection to transmit at any given time
      • timeliness - uses timers
      • ordered - TCP reassembles the message in the correct order
      • labeled - all connections have an agreed upon precedence and security
      • controlled flow - uses buffers and windows to control the flow of information
      • error correction - uses checksums to ensure data is error-free
    • Closing Connections (see figure 4.8)

      TCP uses a connection table to keep trace of all of the connections

  10. User Datagram Protocol (UDP)

    UDP is connectionless and has no error-recovery capabilities

    UDP Header
    Source Port(16 bits) Destination Port(16 bits)
    Length(16 bits) Checksum(16 bits)
    Data

Tools for Tracing TCP Packets

LAND - TCP Bug Threatens Networked Computers

To Previous Chapter To Table of Contents To top of page To Next Chapter