The network layer gets transport layer segment, adds ip address of source and destination and creates a PDU called packet. The ip address is used to forward data at routers and distribute it among the users.
Network layer is connectionless, so it has no headache to see data is delivered or not. That’s the responsibility of the transport layer.
Two common protocols of network layer are
IPv4: Now used with 32bit ip address
IPv6: Limited usage, with 128 bit ip, it provides better security and supports more users than IPv4
Apart from ip address, some other information are added to network layer packet. They are TTL (time to live)= how many routers the packet can pass before they are dropped
TOS (Type of service)=the info that routers use to give priority to packets like VIPs
Transport layer Protocols: TCP: 06, UDP: 17
MF (More fragment): Several fragments need to be added to form the packet
DF (Don’t Fragment): Delicate packet, don’t make pieces.
A router is a layer 3 (network) device. When several networks are connected through routers, the routers exchanges information by routing protocol. So each router knows which network is connected to which router or the shortest path to a distant network. When a router gets a frame (layer 2 PDU) it decapsulates the frame and then checks the ip address in the packet and finds the network address by binary ANDing the ip address and the subnet mask. If the destined network is connected to the router it delivers the packet. Otherwise it encapsulates the packet again and resends the packet to another router which is the next hop for the desired network.