Network and Transport Layer
Network and Transport Layer
The transmission Control Protocol (TCP) is one of the most important protocols of Internet Protocols suite. It is most widely used protocol for
data transmission in communication network such as internet.
Features
• TCP is reliable protocol. That is, the receiver always sends either positive or negative acknowledgement about the data packet to the sender,
so that the sender always has bright clue about whether the data packet is reached the destination or it needs to resend it.
• TCP ensures that the data reaches intended destination in the same order it was sent.
• TCP is connection oriented. TCP requires that connection between two remote points be established before sending actual dat a.
• TCP provides full duplex server, i.e. it can perform roles of both receiver and sender.
TCP Header format
The header of a TCP segment can range from 20-60 bytes. 40 bytes are for options. If there are no options, header is of 20
bytes else it can be of upmost 60 bytes.
Header Fields:
• Source Port (16-bits) - It identifies source port of the application process on the sending device.
• Destination Port (16-bits) - It identifies destination port of the application process on the receiving device.
• Acknowledgement Number (32-bits) - When ACK flag is set, this number contains the next sequence
number of the data byte expected and works as acknowledgement of the previous data received.
• Data Offset (HLEN) (4-bits) - This field implies both, the size of TCP header (32-bit words) and the offset
of data in current packet in the whole TCP segment.
• Reserved (3-bits) - Reserved for future use and all are set zero by default.
• Flags (1-bit each)
➢URG - It indicates that Urgent Pointer field has significant data and should be processed.
➢ACK - It indicates that Acknowledgement field has significance. If ACK is cleared to 0, it indicates
that packet does not contain any acknowledgement.
➢PSH - When set, it is a request to the receiving station to PUSH data (as soon as it comes) to the
receiving application without buffering it.
➢RST - Reset flag has the following features:
• It is used to refuse an incoming connection.
• It is used to reject a segment.
• It is used to restart a connection.
➢SYN - This flag is used to set up a connection between hosts.
➢FIN - This flag is used to release a connection and no more data is exchanged thereafter. Because
packets with SYN and FIN flags have sequence numbers, they are processed in correct order.
• Windows Size - This field is used for flow control between two stations and indicates the amount of buffer (in bytes) the receiver has allo cated for a segment,
i.e. how much data is the receiver expecting.
• Checksum - This field contains the checksum of Header, Data and Pseudo Headers.
• Urgent Pointer - It points to the urgent data byte if URG flag is set to 1.
• Options - It facilitates additional options which are not covered by the regular header. Option field is always described in 32-bit words. If this field contains
data less than 32-bit, padding is used to cover the remaining bits to reach 32-bit boundary.
Congestion Control
• When large amount of data is fed to system which is not capable of handling it, congestion occurs. TCP controls congestion by means of Window mechanism.
TCP sets a window size telling the other end how much data segment to send. TCP may use three algorithms for congestion control:
• Additive increase, Multiplicative Decrease
• Slow Start
• Timeout React
Timer Management
• TCP uses different types of timer to control and management various tasks:
• Keep-alive timer: This timer is used to check the integrity and validity of a connection.
• When keep-alive time expires, the host sends a probe to check if the connection still exists.
• Retransmission timer: This timer maintains full session of data sent.
• If the acknowledgement of sent data does not receive within the Retransmission time, the data segment is sent again.
• Persist Timer: TCP session can be paused by either host by sending Window Size 0.
• To resume the session a host needs to send Window Size with some larger value.
TCP 3-Way Handshake Process
1. The client sends the SYN to the server: When the client wants to connect to the server. It sets the 'SYN' flag as
1 and sends the message to the server. The message has also some additional information like the sequence
number, the ACK is set here to 0, the window size, and the maximum segment size. For Example, if the window
size is 2000 bits, and the maximum segment size is 200 bits then a maximum of 10 data segments (2000/200 =
10) can be transmitted in the connection.
2. The server replies with the SYN and the ACK to the client: After receiving the client's synchronization
request, the server sends an acknowledge to the client by setting the ACK flag to '1'. The acknowledgement
number of the ACK is one more than the received sequence number. For Example, if the client has sent the SYN
with sequence number = 1000, then the server will send the ACK with acknowledgement number = 1001. After
completion of this step, the connection is established from the client to the server-side.
3. The client sends the ACK to the server: After receiving the SYN from the server, the client sets the ACK flag
to '1' and sends it with an acknowledgement number 1 greater than the server's SYN sequence number to the
client. Here, the SYN flag is kept '0'. After completion of this step, the connection is now established from the
server to the client-side also.
User Datagram Protocol
➢ (UDP) is a Transport Layer protocol. UDP is a part of Internet Protocol suite, referred as UDP/IP suite.
➢ Unlike TCP, it is unreliable and connectionless protocol. So, there is no need to establish connection prior to data transfer.
➢ Though Transmission Control Protocol (TCP) is the dominant transport layer protocol used with most of Internet services; provides assured delivery,
reliability and much more but all these services cost us with additional overhead and latency.
➢ Here, UDP comes into picture. For the real time services like computer gaming, voice or video communication, live conferences; we need UDP. Since high
performance is needed, UDP permits packets to be dropped instead of processing delayed packets.
➢ User Datagram Protocol (UDP) is more efficient in terms of both latency , bandwidth and speed.
Uses of UDP
• UDP is used when acknowledgement of data does not hold any significance.
• UDP is stateless.(sender does not get the acknowledgement for the packet which has been sent.)
UDP Header Format
Source Port number:
Source Port is a 16 bit field. It identifies the port of the sending application.
Destination Port number:
It identifies which port is going to accept the information. It is 16-bit information which is used to identify
application-level service on the destination machine.
Length:
It is 16-bit field that specifies the entire length of the UDP packet that includes the header also. The minimum value
would be 8-byte as the size of the header is 8 bytes.
Checksum:
checksum field checks whether the information is accurate or not as there is the possibility that the information can
be corrupted while transmission. In UDP, the checksum field is applied to the entire packet, i.e., header as well as
data part whereas, in IP, the checksum field is applied to only the header field.
(8 bytes = 64 bits) ; (16+16+16+16)
Unlike TCP, Checksum calculation is not mandatory in UDP. No Error control or flow control is provided by UDP.
Hence UDP depends on IP and ICMP for error reporting.
IPv4 Addresses
• There are two versions of IP in use today IPv4 and IPv6.
• However, the IPv4 protocol only allowed for 232 addresses.
• This led to a situation where there would not be enough unique addresses for all devices connected to the internet.
• IPv6 was developed by the Internet Engineering Task Force (IETF), and was formalized in 1998.
• This upgrade substantially increased the available address space and allowed for 2 128 addresses to improve the efficiency of IP packet headers, as well as
improvements to routing and security.
• IPv4 addresses are actually 32-bit binary numbers, consisting of the two sub addresses (identifiers) that is to identify the network and the host to the network.
• An IP address is generally shown as 4 octets of numbers from 0-255 represented in decimal form instead of binary form.
• For example, the address 168.212.226.204 represents the 32-bit binary number 10101000.11010100.11100010.11001100.
• The binary number is important because that will determine which class of network the IP address belongs to.
• An IPv4 address is typically expressed in dotted-decimal notation, with every eight bits (octet) represented by a number from 1 to 255, each separated by a dot.
• IPv4 addresses are composed of two parts: The first numbers in the address specify the network, while the latter numbers specify the specific host.
• A subnet mask specifies which part of an address is the network part, and which part addresses the specific host.
Subnet masks
• A single IP address identifies both a network and a unique interface on that network.
• A subnet mask can also be written in dotted decimal notation and determines where the network part of an IP address ends and the host portion of the
address begins.
• The bits marking the subnet mask must be consecutive ones.
• Most subnet masks start with 255. and continue on until the network mask ends.
• Class C subnet mask would be 255.255.255.0.
IP address classes(Classful Address)
Private addresses
Within the address space, certain networks
are reserved for private networks. Packets
from these networks are not routed across
the public internet. This provides a way for
private networks to use internal IP
addresses without interfering with other
networks.
Supernetting
• Supernetting means creating bigger network from smaller one.
• Supernetting means decreasing networks bits(i.e. 1s) in subnet mask If network bit is decreased host bits will be increased, so number of host
will be decreased.
• Class C network have 24 bits for network (2 power 8 IP address available) if you wanted bigger block IP from class C decrease the network
bits / increasing host bits.
• Supernetting just opposite of subnetting.
• In subnetting, a single big network is divided into multiple smaller subnetworks. In Supernetting, multiple networks are combined into
a bigger network termed as a Supernetwork or Supernet.
IPv4 Datagram format and fragmentation
IPv4 is a connectionless protocol for a packet-switching network that uses the datagram
approach. This means that each datagram is handled independently and each datagram can follow
a different route to the destination.
• VERSION: Version of the IP protocol (4 bits), which is 4 for IPv4
• HLEN: IP header length (4 bits), which is the number of 32 bit words in the header.
• Total Length: Length of header + Data (16 bits), which has a minimum value 20 bytes and the maximum is 65,535 bytes.
• Identification: Unique Packet Id for identifying the group of fragments of a single IP datagram (16 bits)
• Flags: 3 flags of 1 bit each : reserved bit (must be zero), do not fragment flag, more fragments flag (same order)
• Fragment Offset: Represents the number of Data bytes ahead of the particular fragment in the particular Datagram.
• Time to live: Datagram’s lifetime (8 bits).It prevents the datagram to loop through the network by restricting the number of
Hops taken by a Packet before delivering to the Destination.
• Header Checksum: 16 bits header checksum for checking errors in the datagram header
IPv6 (Internet Protocol Version 6)
• An IPv6 address is made of 128 bits divided into eight 16-bits blocks.
• Each block is then converted into 4-digit Hexadecimal numbers separated by colon symbols.
• For example, given below is a 128 bit IPv6 address represented in binary format and divided into eight 16-bits blocks:
0010000000000001 0000000000000000 0011001000111000 1101111111100001 0000000001100011
0000000000000000 0000000000000000 1111111011111011
• Each block is then converted into Hexadecimal and separated by ‘:’ symbol:
2001:0000:3238:DFE1:0063:0000:0000:FEFB
Rules
Rule 1: Discard leading Zero(es): In Block 5, 0063, the leading two 0s can be omitted.
2001:0000:3238:DFE1:63:0000:0000:FEFB
Rule.2: If two or more blocks contain consecutive zeroes, omit them all and replace with double colon sign ::, such as (6th and 7th
block):
2001:0000:3238:DFE1:63::FEFB
Rule 3: Consecutive blocks of zeroes can be replaced only once by :: so if there are still blocks of zeroes in the address, they can
be shrunk down to a single zero, such as (2nd block):
2001:0:3238:DFE1:63::FEFB
IPV6 Header
• IP version 6 is the new version of Internet Protocol, which is way better than IP version 4 in terms of complexity
and efficiency.
• Version (4-bits) : Indicates version of Internet Protocol which contains bit sequence.
• Traffic Class (8-bits) : The Traffic Class field indicates class or priority of IPv6 packet which is similar
to Service Field in IPv4 packet. It helps routers to handle the traffic based on priority of the packet.
• Flow Label (20-bits) : Flow Label field is used by source to label the packets belonging to the same flow in
order to request special handling by intermediate IPv6 routers, such as non-default quality of service or real
time service.
• Payload Length (16-bits) : It is a 16-bit field, indicates total size of the payload which tells routers about
amount of information of a particular packet contains in its payload.
• Next Header (8-bits) : Next Header indicates type of extension header(if present) immediately following the
IPv6 header.
• Hop Limit (8-bits) : Hop Limit field is same as TTL in IPv4 packets. It indicates the maximum number of
intermediate nodes IPv6 packet is allowed to travel.
• Extension Headers : In order to rectify the limitations of IPv4 Option Field, Extension Headers are
introduced in IP version 6. The extension header mechanism is very important part of the IPv6 architecture. It
decides how to direct or process an IPv6 packet.
• Source Address (128-bits) : Source Address is 128-bit IPv6 address of the original source of the packet.
• Destination Address (128-bits) : Destination Address field indicates the IPv6 address of the final
destination(in most cases). All the intermediate nodes can use this information in order to correctly route the
packet.
IPV4 to IPV6 Transition mechanisms
• Dual Stack:
A dual-stack device is a device with network interfaces that can originate and understand both IPv4 and IPv6 packets.
• This technology does not change the packet header and it also does not make encapsulation between IPv4 and IPv6.
• Host chooses IPv4 and IPv6 address. In most cases, IPV6 is chosen by default. Thus IPV6 session is established.
But what will happen if IPV6 address does not work in server of www.example.com ??
• The client experience some delay; When IPv6 connection is failed, the client would try again to establish the connection using
IPv4.
• Here , the client or host need to make two trips for connection establishment to the server.
In order to solve this kind of delay, an application called Happy Eyeballs comes to its rescue.
• With Eyeballs working together with a browser, a dual stack device makes a more aggressive connection over both IPv4 and
IPv6 simultaneously but trying IPv6 first.
➢ From the above Figure, it is shown that two IPv6 hosts from two different networks are connecting each other through IPv4
network infrastructure.
➢ The IPv6 packets are encapsulated inside IPv4 packets for the transmission within IPv4 network.
➢ The global IPv4 address that is assigned to a host, a 48-bit 6to4 IPv6 prefix can be constructed by that host by appending the
IPv4 address to 2002::/16.
NAT(Network Address Translation)
• 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 local IP address is translated into Global IP address and vice versa in order to provide Internet access
to the local hosts.
• Private IP can be used for local communication without permission of Internet authorities.
• Public IP should be globally unique.
• Private IP should be unique inside a organization, not globally, NAT router consist of public IP in exit interface and internal interface consist of Private IPs.
• 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.
What is Transport Layer?
What are the basic functions?
➢ 4th layer from the top.
➢ This layer treats each packet independently because each packet belongs to a different message.
➢ The transport layer ensures that each message should reach its destination completely and in order so that it maintains error and flow
control to the source to destination to ensure proper data transmission.
➢ The transport layer establishes a connection between two end ports. A connection is a single logical path from source to dest ination
which is associated with all the packets in a message.
➢ Transport Layer uses some standard protocols to enhance its functionalities are TCP(Transmission Control Protocol), UDP( User
Datagram Protocol), DCCP( Datagram Congestion Control Protocol).
Connection Establishment
• Establishing a connection sounds easy, but it is actually surprisingly tricky.
• At first glance, it would seem sufficient for one transport entity to just send a CONNECTION REQUEST TPDU to the destination and wait for a
CONNECTION ACCEPTED reply.
• The problem occurs when the network can lose, store, and duplicate packets.
• Three-way handshake process is designed in such a way that both ends help you to initiate, negotiate, and separate TCP socket co nnections
at the same time. It allows you to transfer multiple TCP socket connections in both directions at the same time.
➢ SYN: In the first step, the client establishes a connection with a server. It sends a segment with SYN and informs the server about the client
should start communication, and with what should be its sequence number.
➢ SYN-ACK: In this step server responds to the client request with SYN-ACK signal set. ACK helps you to signify the response of segment
that is received and SYN signifies what sequence number it should able to start with the segments.
➢ ACK: In this final step, the client acknowledges the response of the Server, and they both create a stable connection will begin the actual data
transfer process.
Two protocol scenarios for establishing a connection using a three-way handshake.
CR denotes CONNECTION REQUEST.
(a) Normal operation.
(b) Old duplicate CONNECTION REQUEST appearing out of nowhere.
Connection Release
Connection at transport can be released in two way.
1. Asymmetric: if one of host terminates connection, then in both the direction, data communication will be terminated.
2. Symmetric: if one of the host disconnects connection, then it can not send the data but it can receive it.
Asymmetric release is the way the telephone system works:
➢ Symmetric release treats the connection as two separate unidirectional connections and requires each one to be released separately.
➢ Consider the scenario of Figure. After the connection is established, host 1 sends a TPDU that arrives properly at host 2.The n host 1sends another TPDU. Unfortunately,
host2 issues a DISCONNECT before the second TPDU arrives. The result is that the connection is released and data are lost
DR= Disconnect Request
The timer is used to check the integrity and validity of a connection. When keep-alive time expires, the host sends a
probe(program) to check if the connection still exists.
• DHCP client will find the server by sending DHCP discover message.
• The broadcast message is sent to the network. As the DHCP client doesn’t know the IP address
of the server so the message is broadcast with a destination IP is 255.255.255.255. And the
source IP will be 0.0.0.0 as the client does not have any IP address.
• Here the DHCP discover message in the data link layer and network layer is always broadcast.
• The server sends a DHCP offer message with filled information. It has information about
the IP address and duration of time that a host can use.
• Here destination IP address will be 255.255.255.255 as the DHCP client still does not
have its IP address. But this DHCP offer message is broadcast in the network layer and
unicast in the data link layer.
• This message tells the server that it accepts the IP address given by the server. Here destination address will be
255.255.255.255 means it’s again broadcast.
• The reason for this is there might be many DHCP servers in the network so the client may receive multiple offer
messages and it will accept the request that reaches him first and send a broadcast message to eliminate other
DHCP servers.
• Here source IP address will be 0.0.0.0 as the DHCP server hasn’t yet assigned an IP address to the client.
• A Partially Qualified Domain Name (PQDN) starts with a host name, but it may not
reach up to the root.
• A PQDN is a domain name on an internal network that may include a host name and
a domain name but does not include an ICANN registered TLD if any at all.
**For example, on local network if the name of your computer is (batman), and your
company’s domain is (.centre. Local), your computer’s partially qualified domain name
is batman.centre.local.
Types of Routing Protocols