Network Layer

TCP/IP model
The network layer is also called the internet layer. lt sends packets from source hosts to destination hosts.
The network layer provides connectionless data transmission services. A network does not need to establish a connection before sending data packets. Each IP data packet is sent separately.
Functions of the network layer:
Provides logical addresses for network devices.
Routes and forwards data packets.
Common network layer protocols

Internet Protocol is the core protocol suite in the TCP/IP protocol suite. It governs the breakup of data messages into packets, the routing of the packets from sender to destination network and station, and the reassembly of the packets into the original data messages at the destination.
IP has two versions: IPv4 and IPv6. IPv4 packets prevail on the Internet, and the Internet is undergoing the transition to IPv6.
IPv4 is the core protocol in the TCP/IP protocol suite. It works at the network layer in the TCP/IP protocol stack and this layer corresponds to the network layer in the Open System Interconnection Reference Model (OSI RM).
IPv6, also called IP Next Generation (IPng), is the second-generation standard protocol of network layer protocols. Designed by the Internet Engineering Task Force (IETF), IPv6 is an upgraded version of 1Pv4.
When the IP is running, routing protocols such as OSPF, IS-IS, and BGP are required to help routers build routing tables, and ICMP is required to help control networks and diagnose network status.
Working process of a network layer Protocol
1. Packet encapsulation
When receiving data from an upper layer (such as the transport layer), the network layer encapsulates an IP packet header and adds the source and destination IP addresses to the header.

2. Packet forwarding

The network layer header of a packet sent by a source device carries the network layer addresses of the source and destination devices.
Each network device (Such as a router) that has the routing function maintains a routing table as follows (like a map of the network device).

After receiving a packet, the network device reads the network layer destination address of the packet,searches the routing table for the matching entry of the destination address, and forwards the packet according to the instruction of the matching entry.
When the IP packet reaches the destination host, the destination host determines whether to accept the packet based on the destination IP address and then processes the packet accordingly.


