Network Layer

Flow: In Host A, the network layer encapsulates the segment into a datagram and sends this datagram to a nearby router. At the receiver’s end, this datagram is sent by a nearby router to the receiver’s network layer.

Functions of Network Layer: understand it as going from Delhi to Shimla

  • Forwarding: It is a router-local process of how to forward the datagram from input link to output link. (If you are standing at a Road then how to leave this road to reach the destination) It is done using forwarding tables.
  • Routing: Routing is determining which path one needs to follow to reach from source to destination. Forwarding tables are updated using routing algorithms.

Forwarding Table: Each router has a forwarding table that maps a unique key (mentioned in the header of a packet which is often dest. address) to an output interface of a router. When a datagram comes, the router checks in the forwarding table for its output link interface then internally forwards that datagram to this interface. It is configured using routing algorithms.

Link-Layer Switches: Devices that use-value in the link-layer frame of a packet to determine output link, therefore, switches are called link-layer devices whereas Routers use-value in the field of network layer header.

Connection Setup: In some network architectures (ATM, MPLS, etc. ), they need routers in source to destination path to handshake with each other before sending data this handshake is called connection setup at the network layer.

Network layer can provide a lot of services but the Internet’s network layer only provides Best-Effort service ( no guaranteed delivery, no in-order delivery, and no specific timing), whereas ATM (Asynchronous Transfer Mode) provides various services two of them are here:

  • CBR (Constant Bit Rate) service: Imagine it as if there was a constant bandwidth pipe between the sender and receiver and this guarantees a constant flow of packets. Loss of packets or end-to-end delay all are below specific values agreed by the sender and receiver.
  • ABR (Available Bit Rate) service: It is more like the Internet’s network layer, packet loss is possible, but packets can’t be reordered and an MCR (min. cell rate) is guaranteed and may go as high as possible and also provides feedback to the sender.

Network Layer provides two types of services: Connectionless and connection service.

  • It is a host-to-host service and implemented on both end systems and routers.
  • One architecture can provide a connectionless or connection service but not both. Networks that provide connection services are called virtual circuits(ATM, frame relay) and connectionless are called datagram networks (Internet).

Virtual Circuits

It is connection-oriented and ATM, frame relay, etc. uses it and a virtual circuit has the following components:

  • A pre-determined path between source and destination.
  • A VC number for each link in the path. Each link has a different VC number it is so because if it is the same for every link of a VC then a router has to ask every other router if that number is already used or not. Advantage- Each router has entries for input and output interface with incoming and outgoing VCs.
  • Entries in router table along the path.

Whenever a new VC is established then every router along its path must add an entry for this circuit.

Flow:

  • Connection Setup: The transport layer contacts the network layer by sending dest. address, then the network layer determines a path, adds an entry in each router, and allocate resources.
  • Data Flow: Packets begin to flow from sender to receiver.
  • VC teardown: Sender calls the network layer for termination, the network layer sends this info to the destination and removes the entry from each router’s table.

Signaling Messages: Messages sent by the end systems to the network layer for setup or termination of a VC.

Datagram Networks

When data comes to the network layer, it sends that data to a nearby router based on destination address then each router has a forwarding table that maps destination address with an output interface. Mapping each address with an interface is impossible as there are more than 4 billion addresses (32-bit IP address).

So routers have only a few addresses and the longest prefix match rule is used, the destination address is matched with entries in the table and the longest prefix is selected.

Forwarding tables are changed by routing algorithms after every 2–5 minutes, so packets may travel along different paths which is not the case with VCs.

What do you need to connect two devices on the same network? Switches and they use Mac address and on different networks? Routers that use IP addresses.

IP datagram header — typically 20 bits but options field vary

Source and Destination IP address — 32 bit each

header Checksum — checksum of every 2 bytes of just header

options field — for any reason

length — header length

version — version of protocol followed like IPV4 or IPV6

Protocol — It signifies which transport layer protocol data must be sent.

Time to live — At every router its value is decreased and if 0 and not at the destination then stop traversing, to prevent router loop.

Type of service — Some datagrams require high throughput, low delay.

Flag bits — Signifies if the datagram is complete or more to receive, 1 means more to come, 0 means last.

Identification number — identify a datagram uniquely.

Flag offset — where the piece of the datagram should fit, these last 2 are used majorly in case of fragmentation.

Fragmentation

Every link layer protocol has a different MTU, so the payload of a datagram may be fragmented into smaller units for transmission.

CIDR (Classless Interdomain Routing)

An IP address is not associated with a host but is associated with an interface. so a router can have multiple addresses.

Subnet — It is a network that connects many hosts to a router.

Subnet mask — It is of the form a.b.c.d/x.It means that the leftmost x bits of an IP address will be fixed which is known as a mask and this way many organizations are assigned subnets.

A subnet can further be divided into multiple subnets. For example — a subnet mask of 20 bits can be divided into mask of 23 bits and so on…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store