Tcpip, Nat, 3 Way
Tcpip, Nat, 3 Way
Here, hierarchical means that each upper-layer protocol is supported by two or more lower-level
protocols.
IP Protocol: IP protocol is used in this layer, and it is the most significant part of the entire TCP/IP suite.
o IP Addressing: This protocol implements logical host addresses known as IP addresses. The IP
addresses are used by the internet and higher layers to identify the device and to provide
internetwork routing.
o Host-to-host communication: It determines the path through which the data is to be transmitted.
o Data Encapsulation and Formatting: An IP protocol accepts the data from the transport layer
protocol. An IP protocol ensures that the data is sent and received securely, it encapsulates the
data into message known as IP datagram.
o Fragmentation and Reassembly: The limit imposed on the size of the IP datagram by data link
layer protocol is known as Maximum Transmission unit (MTU). If the size of IP datagram is
greater than the MTU unit, then the IP protocol splits the datagram into smaller units so that they
can travel over the local network. Fragmentation can be done by the sender or intermediate
router. At the receiver side, all the fragments are reassembled to form an original message.
o Routing: When IP datagram is sent over the same local network such as LAN, MAN, WAN, it is
known as direct delivery. When source and destination are on the distant network, then the IP
datagram is sent indirectly. This can be accomplished by routing the IP datagram through various
devices such as routers.
ARP Protocol
Transport Layer
The transport layer is responsible for the reliability, flow control, and correction of data which is being
sent over the network.
The two protocols used in the transport layer are User Datagram protocol and Transmission control
protocol.
Application Layer
o HTTP: HTTP stands for Hypertext transfer protocol. This protocol allows us to access the data
over the world wide web. It transfers the data in the form of plain text, audio, video. It is known
as a Hypertext transfer protocol as it has the efficiency to use in a hypertext environment where
there are rapid jumps from one document to another.
o SNMP: SNMP stands for Simple Network Management Protocol. It is a framework used for
managing the devices on the internet by using the TCP/IP protocol suite.
o SMTP: SMTP stands for Simple mail transfer protocol. The TCP/IP protocol that supports the e-
mail is known as a Simple mail transfer protocol. This protocol is used to send the data to another
e-mail address.
o DNS: DNS stands for Domain Name System. An IP address is used to identify the connection of
a host to the internet uniquely. But, people prefer to use the names instead of addresses.
Therefore, the system that maps the name to the address is known as Domain Name System.
o TELNET: It is an abbreviation for Terminal Network. It establishes the connection between the
local computer and remote computer in such a way that the local terminal appears to be a terminal
at the remote system.
o FTP: FTP stands for File Transfer Protocol. FTP is a standard internet protocol used for
transmitting the files from one computer to another computer.
Transmission Control Protocol (TCP) provides a secure and reliable connection between two devices
using the 3-way handshake process. TCP uses the full-duplex connection to synchronize (SYN) and
acknowledge (ACK) each other on both sides. There are three steps for both establishing and closing a
connection. They are − SYN, SYN-ACK, and ACK.
The following diagram shows how a reliable connection is established using 3-way handshake. It will
support communication between a web browser on the client and server sides whenever a user navigates
the Internet.
Synchronization Sequence Number (SYN) − The client sends the SYN to the server
When the client wants to connect to the server, then it sends the message to the server by setting the
SYN flag as 1.
The message carries some additional information like the sequence number (32-bit random
number).
The ACK is set to 0. The maximum segment size and the window size are also set. For example, if
the window size is 1000 bits and the maximum segment size is 100 bits, then a maximum of 10
data segments can be transmitted in the connection by dividing (1000/100=10).
Synchronization and Acknowledgement (SYN-ACK) to the client
The server acknowledges the client request by setting the ACK flag to 1.
The ACK indicates the response of the segment it received and SYN indicates with what sequence
number it will start the segments.
For example, if the client has sent the SYN with sequence number = 500, then the server will send
the ACK using acknowledgment number = 5001.
The server will set the SYN flag to '1' and send it to the client if the server also wants to establish
the connection.
The sequence number used for SYN will be different from the client's SYN.
The server also advertises its window size and maximum segment size to the client. And, the
connection is established from the client-side to the server-side.
Acknowledgment (ACK) to the server
The client sends the acknowledgment (ACK) to the server after receiving the synchronization
(SYN) from the server.
After getting the (ACK) from the client, the connection is established between the client and the
server.
Now the data can be transmitted between the client and server sides.
3 -Way Handshake Closing Connection Process
To close a 3-way handshake connection,
First, the client requests the server to terminate the established connection by sending FIN.
After receiving the client request, the server sends back the FIN and ACK request to the client.
After receiving the FIN + ACK from the server, the client confirms by sending an ACK to the
server.
Network Address Translation (NAT)
To access the Internet, one public IP address is needed, but we can use a private IP address in our
private network. The idea of NAT is to allow multiple devices to access the Internet through a single
public address. To achieve this, the translation of a private IP address to a public IP address is
required. Network Address Translation (NAT) is a process in which one or more local IP address is
translated into one or more Global IP address and vice versa in order to provide Internet access to the
local hosts. Also, it does the translation of port numbers i.e. masks the port number of the host with
another port number, in the packet that will be routed to the destination. It then makes the
corresponding entries of IP address and port number in the NAT table. NAT generally operates on a
router or firewall.
Network Address Translation (NAT) working –
Generally, the border router is configured for NAT i.e the router which has one interface in the local
(inside) network and one interface in the global (outside) network. When a packet traverse outside the
local (inside) network, then NAT converts that local (private) IP address to a global (public) IP address.
When a packet enters the local network, the global (public) IP address is converted to a local (private)
IP address.
If NAT runs out of addresses, i.e., no address is left in the pool configured then the packets will be
dropped and an Internet Control Message Protocol (ICMP) host unreachable packet to the destination is
sent.
Why mask port numbers ?
Suppose, in a network, two hosts A and B are connected. Now, both of them request for the same
destination, on the same port number, say 1000, on the host side, at the same time. If NAT does only
translation of IP addresses, then when their packets will arrive at the NAT, both of their IP addresses
would be masked by the public IP address of the network and sent to the destination. Destination will
send replies to the public IP address of the router. Thus, on receiving a reply, it will be unclear to NAT
as to which reply belongs to which host (because source port numbers for both A and B are the same).
Hence, to avoid such a problem, NAT masks the source port number as well and makes an entry in the
NAT table.
NAT inside and outside addresses –
Inside refers to the addresses which must be translated. Outside refers to the addresses which are not in
control of an organization. These are the network Addresses in which the translation of the addresses
will be done.
Inside local address – An IP address that is assigned to a host on the Inside (local) network. The
address is probably not an IP address assigned by the service provider i.e., these are private IP
addresses. This is the inside host seen from the inside network.
Inside global address – IP address that represents one or more inside local IP addresses to the
outside world. This is the inside host as seen from the outside network.
Outside local address – This is the actual IP address of the destination host in the local network
after translation.
Outside global address – This is the outside host as seen from the outside network. It is the IP
address of the outside destination host before translation.
1. Static NAT – In this, a single unregistered (Private) IP address is mapped with a legally registered
(Public) IP address i.e one-to-one mapping between local and global addresses. This is generally
used for Web hosting. These are not used in organizations as there are many devices that will need
Internet access and to provide Internet access, a public IP address is needed.
Suppose, if there are 3000 devices that need access to the Internet, the organization has to buy 3000
public addresses that will be very costly.
2. Dynamic NAT – In this type of NAT, an unregistered IP address is translated into a registered
(Public) IP address from a pool of public IP addresses. If the IP address of the pool is not free, then
the packet will be dropped as only a fixed number of private IP addresses can be translated to public
addresses.
Suppose, if there is a pool of 2 public IP addresses then only 2 private IP addresses can be translated
at a given time. If 3rd private IP address wants to access the Internet then the packet will be dropped
therefore many private IP addresses are mapped to a pool of public IP addresses. NAT is used when
the number of users who want to access the Internet is fixed. This is also very costly as the
organization has to buy many global IP addresses to make a pool.
3. Port Address Translation (PAT) – This is also known as NAT overload. In this, many local
(private) IP addresses can be translated to a single registered IP address. Port numbers are used to
distinguish the traffic i.e., which traffic belongs to which IP address. This is most frequently used as
it is cost-effective as thousands of users can be connected to the Internet by using only one real
global (public) IP address.
Advantages of NAT –
It provides privacy as the device’s IP address, sending and receiving the traffic, will be hidden.
Disadvantage of NAT –
Also, the router being a network layer device, should not tamper with port numbers(transport layer)
but it has to do so because of NAT.