TCP/IP Layers and Protocols
TCP and IP together manage the flow of data, both in and out, over a network. Whereas IP indiscriminately pumps packets into the ether, TCP is charged with making sure they get there. TCP is responsible for the following:
Opening and closing a session
Packet management
Flow control
Error detection and handling
Architecture
TCP/IP is the environment that handles all these operations and coordinates them with remote hosts. TCP/IP was created using the DoD (Department of Defense) model, which is made up of four layers instead of the seven that make up the OSI model.
The primary difference between the OSI and the TCP/IP layer formats is that the Transport Layer does not guarantee delivery at all times. TCP/IP offers the User Datagram Protocol (UDP), a more simplified protocol, wherein all the layers in the TCP/IP stack perform specific duties or run applications.
Application Layer
The Application Layer consists of protocols such as SMTP, FTP, NFS, NIS, LPD, Telnet, and Remote Login, all of which fall into areas that are familiar to most Internet users.
Transport Layer
The Transport Layer consists of UDP (User Datagram Protocol) and TCP, where the former delivers packets with almost non-existent checking, and the latter provides delivery guarantees.
Network Layer
The Network Layer is made up of the following protocols: ICMP, IP, IGMP, RIP, OSPF, EGP and BGP4. ICMP (Internet Control Message Protocol) is used for diagnostics and to report on problems with the IP layer and for obtaining information about IP parameters. IGMP (Internet Group Management Protocol) is used for managing multicasting. RIP, OSPF, EGP, and BGP4 are examples of routing protocols.
Link Layer
The Link Layer consists of ARP and RARP, and framing of data, which handle packet transmission.
Transmission Control Protocol (TCP)
Transmission Control Protocol (TCP) is a protocol that provides a reliable stream delivery and connection service to applications. TCP uses sequenced acknowledgment and is able to retransmit packets as needed.
The TCP header appears as follows:
The parts of the header are detailed in the following sections.
Source Port
The source port is the numerical value indicating the source port.
Destination Port
The destination port is the numerical value indicating the destination port.
Sequence Number
The sequence number is the number of the first data octet in any given segment.
Acknowledgement Number (ACK)
When the ACK bit is set, this field contains the next sequence number that the sender of the segment is expecting to receive. This value is always sent.
Data Offset
Data offset is the numerical value that indicates where the data begins, implying the end of the header by offset.
Reserved
Reserved is not used, but it must be off (0).
Control Bits
The control bits are as follows:
Window
The window indicates the number of octets the sender is willing to take. This starts with the packet in the ACK field.
Checksum
The checksum field is the 16-bit complement of the sum of all 16-bit words, restricted to the 1s column, in the header and text. If the result is an odd number of header and text octets, then the last octet is padded with zeros to form a 16-bit word that will checksum. Note that the pad is not sent as part of the segment.
Urgent (URG) Pointer
The URG pointer field shows the value of the URG pointer in the form of a positive offset of the sequence number from the octet that follows the URG data or points to the end of urgent data.
Options
Options may be sent at the end of a header, but must always be fully implemented and have a length that is any multiple of 8-bits. The two types of options are
Type 1: A single octet of option-kind.
Type 2: An octet of option-kind, an octet of option-length, and the actual option-data octets.
The option has a type, length and value field.
The length field includes the type, option length, as well as the value fields. The value field contains the data that makes up the options being sent. Table 3.1 shows how the octets are formatted in one of three classes. All the options are included in the checksum. An option can begin on any octet boundary as long as any remaining "dead" space is padded to meet the defined packet length.
NOTE
The list of options can be shorter than that designated by the data offset field because the contents of the header beyond the End-of-Option option must be padded with zeros (0).
Table 3.1 Formatted Octets
Class |
Length |
Description |
0 |
- |
End of options |
1 |
- |
No operation |
2 |
4 |
Maximum segment size |
The Class 0 option indicates the end of the option list, ending all options, but not each individual option. Only use this option if the end of the options list does not coincide with the end of the header.
The Class 1 option is used to align an option with a word boundary. Other than that this option does not contain any useful information. Its main purpose is for aligning and formatting.
The Class 2 option indicates the maximum segment size that it will receive. It can only be included in the initial request and in segments where the SYN item bit is set. If this option is not used, there is no size limit.
Internet Protocol (IP)
IP manages how packets are delivered to and from servers and clients.
The IP header appears as follows:
Each field contains information about the IP packet that it carries. The descriptions in the following sections should be helpful.
Version Number
The version number indicates the version of IP that is in use for this packet. IP version 4 (Ipv4) is currently in widespread use.
Header Length
The header length indicates the overall length of the header. The receiving machine then knows when to stop reading the header and start reading data.
Type of Service
Mostly unused, the Type of Service field indicates the importance of the packet in a numerical value. Higher numbers result in prioritized handling.
Total Length
Total length shows the total length of the packet in bytes. The total packet length cannot exceed 65,535 bytes or it will be deemed corrupt by the receiver.
Identification
If there is more than one packet (an invariable inevitability), the identification field has an identifier that identifies its place in line, as it were. Fragmented packets retain their original ID number.
Flags
The first flag, if set, is ignored. If the DF (Do Not Fragment) flag is set, under no circumstances can the packet be fragmented. If the MF (More Fragments) bit is turned on (1), there are packet fragments to come, the last of which is set to off (0).
Offset
If the Flag field returns a 1 (on), the Offset field contains the location of the missing piece(s) indicated by a numerical offset based on the total length of the packet.
Time To Live (TTL)
Typically 15 to 30 seconds, TTL indicates the length of time that a packet is allowed to remain in transit. If a packet is discarded or lost in transit, an indicator is sent back to the sending computer that the loss occurred. The sending machine then has the option of resending that packet.
Protocol
The protocol field holds a numerical value indicating the handling protocol in use for this packet.
Checksum
The checksum value acts as a validation checksum for the header.
Source Address
The source address field indicates the address of the sending machine.
Destination Address
The destination address field indicates the address of the destination machine.
Options and Padding
The Options field is optional. If used, it contains codes that indicate the use of security, strict or loose source routing, routing records, and timestamping. If no options are used, the field is called padded and contains a 1. Padding is used to force a byte value that is rounded. Table 3.2 indicates the bit counts for the options available.
Table 3.2 Bit Counts
Class |
Number |
Option |
0 |
0 |
End of option list |
0 |
2 |
Military security |
0 |
3 |
Loose source routing |
0 |
7 |
Routing record* |
0 |
9 |
Strict source routing |
2 |
4 |
Timestamping |
*This option adds fields.
TCP/IP provides its services via a "stack" of translation layers, which are called, of all things, TCP/IP. Because TCP and IP are separate protocols, they require a common environment for translation services. As mentioned earlier in this chapter, the TCP/IP stack has four layers as opposed to the OSI's seven layers. In a nutshell, they are
Application
Transport
Network
Link
Each of these is discussed in the following sections.
Application Layer
The Application Layer combines a few services that the OSI separates into three layers. These services are end user-related: authentication, data handling, and compression. This is where email, Web browsers, telnet clients, and other Internet applications get their connections.
Transport Layer
Again, unlike OSI, this layer is not responsible for guaranteeing the delivery of packets. Its primary responsibility is managing the transfer between the source and the destination. The OSI guarantees that packets are checked and, if they don't match, are dumped and re-requested from the source.
Network Layer
The Network Layer deals strictly with packet-routing management. This layer is well-suited to making determinations on where to send packets based on the information it receives.
Link Layer
The Link Layer manages the connection of the network and provides packet I/O over the network, but not at the application level.
Now that you have a clear idea of what TCP/IP is and what it can do (although hands-on experience is as close as your nearest Internet-connected computer), the following section moves on to the tangible benefits that TCP/IP provides you.