Chapter 2
Chapter 2
TCP/IP Architecture
The four-level model illustrated in Figure 1.1. This model provides a reasonable
pictorial representation of the layers in the TCP/IP protocol hierarchy.
Application layer
This is the top layer of TCP/IP protocol suite. This layer includes applications or
processes that use transport layer protocols to deliver the data to destination
computers.
At each layer there are certain protocol options to carry out the task designated
to that particular layer. So, application layer also has various protocols that
applications use to communicate with the second layer, the transport layer. Some
of the popular application layer protocols are :
HTTP (Hypertext transfer protocol)
FTP (File transfer protocol)
SMTP (Simple mail transfer protocol)
SNMP (Simple network management protocol) etc
2. Transport Layer
This layer provides backbone to data flow between two hosts. This layer receives
data from the application layer above it. There are many protocols that work at
this layer but the two most commonly used protocols at transport layer are TCP
and UDP.
3. Network Layer
This layer is also known as Internet layer. The main purpose of this layer is to
organize or handle the movement of data on network. By movement of data, we
generally mean routing of data over the network. The main protocol used at this
layer is IP. While ICMP(used by popular ‘ping’ command) and IGMP are also used
at this layer.
4. Data Link Layer
This layer is also known as network interface layer. This layer normally consists of
device drivers in the OS and the network interface card attached to the system.
Both the device drivers and the network interface card take care of the
communication details with the media being used to transfer the data over the
network. In most of the cases, this media is in the form of cables. Some of the
famous protocols that are used at this layer include ARP(Address resolution
protocol), PPP(Point to point protocol) etc.
Different Protocols in TCP/IP
TCP:
TCP (Transmission Control Protocol) is a standard that defines how to establish
and maintain a network conversation through which application programs can
exchange data. TCP works with the Internet Protocol (IP), which defines how
computers send packets of data to each other. Together, TCP and IP are the basic
rules defining the Internet.
1. Connection oriented service
Transmission Control Protocol (TCP) is a connection-
oriented protocol. For connection-oriented communications, each
end point must be able to transmit so that it can communicate. ...
Because they can keep track of a conversation, connection-
oriented protocols are sometimes described as stateful.
2. Flow Control
Flow Control basically means that TCP will ensure that a
sender is not overwhelming a receiver by sending packets faster
than it can consume. ... Congestion control is about preventing a
node from overwhelming the network (i.e. the links between two
nodes), while Flow Control is about the end-node.
3. Multiplexing
Gathering data from multiple application processes of sender,
enveloping that data with header and sending them as a whole to
the intended receiver is called as multiplexing. Delivering received
segments at receiver side to the correct app layer processes is called
as demultiplexing.
TCP PROTOCOL HEADER FORMAT:
Opcode is 1 for a request and 2 for a reply. The hardware type field is 1 for a 10
Mbits/sec Ethernet, the same value that is in the field of the same name in an ARP
request or reply. Similarly, the hardware address length is 6 bytes for an Ethernet.
The hop count is set to 0 by the client, but can be used by a proxy server.
The transaction ID is a 32-bit integer set by the client and returned by the server.
This lets the client match a response with a request. The client should set this to a
random number for each request.
Number of seconds can be set by the client to the time since it started trying to
bootstrap. The servers can look at this value, and perhaps a secondary server for
a client won't respond until the number of seconds has exceeded some value,
implying that the client's primary server is down.
If the client already knows its IP address, it fills in the client IP address. Otherwise,
the client sets this to 0. In the latter case the server fills in your IP address with the
client's IP address. The server IP address is filled in by the server. If a proxy server
is used, that proxy server fills in its gateway IP address.
The client must set its client hardware address. Although this is the same value as
in the Ethernet header, by placing the field in the UDP datagram also, it is easily
available to any user process (e.g., a BOOTP server) that receives the datagram. It
is normally much harder (or impossible ) for a process reading UDP datagrams to
determine the fields in the Ethernet header that carried the UDP datagram.
The server hostname is a null terminated string that is optionally filled in by the
server. The server can also fill in the boot filename with the fully qualified, null
terminated pathname of a file to bootstrap from.
The vendor-specific area is used for various extensions to BOOTP. Section 16.6
describes some of these extensions.
When a client is bootstrapping using BOOTP (an opcode of 1) the request is
normally a link-layer broadcast and the destination IP address in the IP header is
normally 255.255.255.255. The source IP address is often 0.0.0.0 since the client
does not know its own IP address yet. Recall from Figure 3.9 that 0.0.0.0 is a valid
source IP address when a system is bootstrapping itself.
Port Numbers
There are two well-known ports for BOOTP: 67 for the server and 68 for the client.
This means the client does not choose an unused ephemeral port, but uses 68
instead. The reason two port numbers were chosen , instead of just one for the
server, is that a server's reply can be (but normally isn't) broadcast.
If the server's reply were broadcast, and if the client were to choose an ephemeral
port number, these broadcasts would also be received by other applications on
other hosts that happen to be using the same ephemeral port number. Hence, it is
considered bad form to broadcast to a random (i.e., ephemeral) port number.
If the client also used the server's well-known port (67) as its port, then all servers
on the network are awakened to look at each broadcast reply. (If all the servers
were awakened, they would examine the opcode, see that it's a reply and not a
request, and go back to sleep.) Therefore the choice was made to have all clients
use a single well-known port that differs from the server's well-known port.
If multiple clients are bootstrapping at the same time, and if the server broadcasts
the replies, each client sees the replies intended for the other clients. The clients
can use the transaction ID field in the BOOTP header to match replies with
requests, or the client can examine the returned client hardware address.
DHCP
DHCP (Dynamic Host Configuration Protocol) is a protocol that provides quick,
automatic, and central management for the distribution of IP addresses within a
network. DHCP is also used to configure the subnet mask, default gateway,
and DNS server information on the device.
Dynamic Host Configuration Protocol (DHCP) Message Format
All Dynamic Host Configuration Protocol (DHCP) messages include a FIXED format
section and a VARIABLE format section. The fixed format section consists of
several fields that are the same in every Dynamic Host Configuration Protocol
(DHCP) message. The variable format section in the Dynamic Host Configuration
Protocol (DHCP) contains "OPTIONS", which carry additional configuration
parameters.
Protocol Version(4 bits) : This is the first field in the protocol header. This field
occupies 4 bits. This signifies the current IP protocol version being used. Most
common version of IP protocol being used is version 4 while version 6 is out in
market and fast gaining popularity.
Header Length(4 bits) : This field provides the length of the IP header. The
length of the header is represented in 32 bit words. This length also includes IP
options (if any). Since this field is of 4 bits so the maximum header length
allowed is 60 bytes. Usually when no options are present then the value of this
field is 5. Here 5 means five 32 bit words ie 5 *4 = 20 bytes.
Type of service(8 bits) : The first three bits of this field are known as
precedence bits and are ignored as of today. The next 4 bits represent type of
service and the last bit is left unused. The 4 bits that represent TOS are :
minimize delay, maximize throughput, maximize reliability and minimize
monetary cost.
Total length(16 bits): This represents the total IP datagram length in bytes.
Since the header length (described above) gives the length of header and this
field gives total length so the length of data and its starting point can easily be
calculated using these two fields. Since this is a 16 bit field and it represents
length of IP datagram so the maximum size of IP datagram can be 65535
bytes. When IP fragmentation takes place over the network then value of this
field also changes. There are cases when IP datagrams are very small in
length but some data links like ethernet pad these small frames to be of a
minimum length ie 46 bytes. So to know the exact length of IP header in case
of ethernet padding this field comes in handy.
Identification(16 bits): This field is used for uniquely identifying the IP
datagrams. This value is incremented every-time an IP datagram is sent from
source to the destination. This field comes in handy while reassembly of
fragmented IP data grams.
Flags(3 bits): This field comprises of three bits. While the first bit is kept
reserved as of now, the next two bits have their own importance. The second
bit represents the ‘Don’t Fragment’ bit. When this bit is set then IP datagram is
never fragmented, rather its thrown away if a requirement for fragment arises.
The third bit represents the ‘More Fragment’ bit. If this bit is set then it
represents a fragmented IP datagram that has more fragments after it. In
case of last fragment of an IP datagram this bit is not set signifying that this is
the last fragment of a particular IP datagram.
Fragment offset(13 bits): In case of fragmented IP data grams, this field
contains the offset( in terms of 8 bytes units) from the start of IP datagram. So
again, this field is used in reassembly of fragmented IP datagrams.
Time to live(8 bits) : This value represents number of hops that the IP
datagram will go through before being discarded. The value of this field in the
beginning is set to be around 32 or 64 (lets say) but at every hop over the
network this field is decremented by one. When this field becomes zero, the
data gram is discarded. So, we see that this field literally means the effective
lifetime for a datagram on network.
Protocol(8 bits) : This field represents the transport layer protocol that handed
over data to IP layer. This field comes in handy when the data is demultiplex-
ed at the destination as in that case IP would need to know which protocol to
hand over the data to.
Header Checksum(16 bits) : This fields represents a value that is calculated
using an algorithm covering all the fields in header (assuming this very field to
be zero). This value is calculated and stored in header when IP data gram is
sent from source to destination and at the destination side this checksum is
again calculated and verified against the checksum present in header. If the
value is same then the datagram was not corrupted else its assumed that
data gram was received corrupted. So this field is used to check the integrity
of an IP datagram.
Source and destination IP(32 bits each) : These fields store the source and
destination address respectively. Since size of these fields is 32 bits each so an
IP address os maximum length of 32 bits can be used. Options(Variable
length) : This field represents a list of options that are active for a particular IP
datagram. This is an optional field that could be or could not be present. If any
option is present in the header then the first byte is represented as follows.