Term of the Moment

AI in a nutshell


Look Up Another Term


Redirected from: TCP abc's

Definition: TCP/IP abc's


TCP/IP is a layered networking protocol, which means that packets of data from the application are passed through several stages, or layers, until they move onto the wire as pulses or into the air as frequencies. Each layer adds its own header. At the destination side, the corresponding layers strip the headers and move the packets to the receiving application. See protocol stack and TCP/IP.

All Nodes Have an IP Address
All machines (PCs, servers, routers, etc.) have a physical address built into their hardware. However, a TCP/IP network also assigns a "logical" IP address, which is written as four numbers between dots, such as 193.4.64.01. This logical address assignment, which is often temporary, enables TCP/IP networks to realign themselves in the event of conflicts or catastrophe. See IP address and DHCP.

TCP and IP
Transmission Control Protocol (TCP) sets up a connection at both ends and guarantees reliable delivery by testing for errors and retransmitting if necessary. TCP passes its data to the Internet Protocol (IP), which routes packets to another network. For example, a wireless router in the home sends all packets to the IP address of the household's Internet service provider (see ISP).

Ports
A TCP/IP port is a logical number assigned to an application category. There are "well-known ports" for Web (HTTP), email (SMTP), file transfer (FTP) and other common applications. For example, an HTTP server (Web server) is identified as port 80. Companies can assign private port numbers for their own applications. See port 80.

A Socket Is IP Address and Port
The sending program identifies the program it wishes to communicate with by "socket," which is the combination of IP address and port number. If only the domain such as ComputerLanguage.com is known, TCP/IP sends a request to the Domain Name System (DNS) to convert the name to the IP address. See TCP/IP socket, DNS and URL.




The TCP/IP Protocol Stack
Comprising five of the seven layers of the OSI model, the TCP/IP layers are described below.



Application Layer 7
The top layer of the protocol stack refers to the programs that initiate the communications.

TCP/IP Applications: HTTP, SMTP and FTP
The most common TCP/IP application programs are website query and retrieval (HTTP), email transfer (SMTP) and file transfer (FTP). There are other applications that are part of the TCP/IP suite as well as countless applications that have a language and format used only by the sending and receiving programs. At the sending side, data are "handed down the stack" from the Application Layer to the lower layers for transport. At the receiving end, they are "handed up the stack" from the transport layers to the Application Layer for processing. See HTTP, SMTP and FTP.




From Layer 7 to Layer 4
TCP/IP Layer 7 encompasses Layers 5 and 6 of the OSI standard. The application passes its data directly to the transport layer along with the socket (IP and port) of the destination machine. The dotted lines represent a DNS request (or earlier WINS request), which goes down the stack like every other packet in order to get onto the network.



Transport Layer 4 - TCP & UDP
TCP establishes a connection at both ends and negotiates the size of the packet, which can be up to 64KB. In most cases, the size is based on the underlying network, such as Ethernet, which holds a maximum of 1,518 bytes. TCP attaches a header to the packet that contains source and destination ports as well as the packet's sequence number. TCP Layer 4 hands the packet to the IP Layer 3 along with the destination IP address. A TCP packet is technically a Protocol Data Unit (PDU) or segment but is called a "packet" in common parlance.

Sliding Windows and Flow Control
TCP's sliding window is an adjustable buffer that allows a number of packets to be received before an acknowledgment is sent back. TCP handles this "flow control" in real time by adjusting the window size as conditions change. TCP also retransmits packets received with errors.

Unreliable UDP (User Datagram Protocol)
For real-time audio and video, UDP is used instead of TCP because there is no time to retransmit dropped or erroneous packets. UDP does not establish a connection, makes no guarantees and provides no flow control or error detection.




From Transport to Network Layer
TCP and UDP hand over their packets to IP along with the IP address of the destination node. The packet size is typically the size of the underlying data link layer such as Ethernet or Wi-Fi.





Network (Internet) Layer 3 - IP
The IP protocol accepts the packets from TCP or UDP and prepares them for the Data Link Layer below by turning the IP addresses into physical station addresses (MAC addresses) and fragmenting the packets (if necessary) into the required frame size. IP uses the Address Resolution Protocol (ARP) to obtain the MAC address, unless (1) the address has already been ARP'd and is in the cache or (2) there is a predefined configuration file that contains the addresses. An ARP request is broadcast onto the network, and the machine with that IP address responds with its MAC address. If the target machine is in a different network or subnetwork than the source machine, IP supplies the target address of the default gateway, which is the router that can direct the packet to the appropriate network.

Datagrams
IP packets are called "datagrams," and each datagram is prefixed with an IP header that contains source and destination IP addresses. If IP has to fragment the packet further, it creates multiple datagrams with sequence numbers so that they can be reassembled by IP on the other end. IP hands over each datagram to the data link layer below along with the Ethernet or Wi-Fi MAC address of the target station or router.

Multicast
IP supports a very useful feature called "multicast," which allows one message to be delivered to multiple recipients. That means one IP data stream can travel a long, circuitous route before it is fanned out to all the target stations by the last router.




From Network to Data Link Layer
IP datagrams are handed over to Ethernet, Wi-Fi or some other data link protocol responsible for moving the data to the next station. The dotted lines in the diagram are conceptual. ARP requests go down the stack like everything else in order to go out onto the network.




IP Is the Routing Mechanism
On the Internet or in a large enterprise, the IP protocol is used to route packets from network to network. Routers contain routing tables that move the datagrams to the next "hop," which is either the destination network or another router. Datagrams can traverse several routers within an enterprise and dozens of routers over the Internet.

Fragmentation
Routers that span different types of networks may have to fragment the datagrams even further if they direct them onto routes that use a smaller frame size than the incoming frame.

From Hop to Hop
Routers inspect only the network portion (netid) of the address and direct the incoming datagrams to the appropriate outgoing port for the next hop. Routers move datagrams from one hop to the next as they are mostly aware of only the devices that are directly connected to them. Eventually, if the routing tables are correctly updated, the datagrams reach their destination. Routers use routing protocols to obtain current routing information about the networks and hosts that are directly connected to them.




Routing Table Example
If a router receives packets destined for a remote network, it sends them out the port that will reach the next router. Router ports are entirely different than socket ports. Router ports are physical pathways to and from the router connected via cable. Socket ports are logical assignments made to running programs.





Data Link Layer 2 - Ethernet/Wi-Fi
IP can connect directly to Ethernet, Wi-Fi, ATM, SONET and other networks. Because Ethernet is the most widely used network access method, it is used in the example below. Ethernet wraps the IP datagrams into its own frame format, which includes a header with source and destination MAC addresses and a trailer that contains checksum data.

Ethernet Packets Can Collide
Ethernet's carrier sense multiple access/collision detection (CSMA/CD) access method broadcasts the frames onto the wire. If two stations transmit at the same time, their frames collide, and they each back off and wait a random number of milliseconds before trying again. The data link layer is responsible for reliable node to node transmission. If an Ethernet frame is received with errors, Ethernet handles retransmission until it is received error free.

LAN to WAN
IP datagrams typically start out in a LAN, go to a wide area network (WAN) and then to a LAN at the other end. Ethernet frames are converted into WAN frames by a router and back again to Ethernet frames by a router at the other side.




Onto the Wire
The data link layer is responsible for reliable node to node transmission within a subnetwork. When Ethernet frames traverse several routers, the same frames are retransmitted over again by the next router.





Packets, Datagrams and Frames
A message starts out in one host, goes down the protocol stack, over the wire, and back up the stack on the receiving host. The counterpart protocols unpackage the frames, datagrams and packets and deliver the data to the application for processing.

Although the terms are technically TCP segments, IP datagrams and Ethernet frames, they all ride over packet-switched networks and are frequently called packets at all stages.




Transporting IP
Transporting IP packets over a LAN is typically done via Ethernet or Wi-Fi. Over the WAN, IP can ride over various networking technologies. See ATM, SONET, MPLS and WDM.







Summary of the TCP/IP Stack




TCP/IP References
Perhaps the simplest reference ever written on the subject is "An Introduction to TCP/IP" by John Davidson (Springer-Verlag, 1988). Although written decades ago and only 100 pages, it is a very easy read on the subject.

The Bibles for TCP/IP have been "Internetworking with TCP/IP," Volumes I, II and III, by Douglas E. Comer. Updated to its 6th edition, Volume I covers the principles, protocols and architecture of the subject. (Prentice Hall, 2006).