0

My book (Andrew S. Tanenbaum, “Computer Networks”, Fifth Edition.) mentions while explaining the network layer that the key issue with a network layer is

determining how packets are routed from source to destination

I tried to search on the internet for more of what the network layer does and everyone seems to talk about "routing packets from the source host to the destination host" or "path determination through a network".

To confirm my understanding of the layers, I started imagining receiving data through the physical layer, error detection and correction at datalink layer,... but I couldn't think next of what the network layer will do.

In particular, if this was the sender then I would know that the role of the network layer here is to route the packets or prepare the paths for them. But in this case, I think they know their way.

7
  • How would they know the way?
    – Ron Trunk
    Commented Oct 15, 2022 at 12:31
  • My imagination is that once the network layer at the sender has determined the path, the packets will follow that path which ends at the receiver. So I don't see what the network layer does at the receiver.
    – Essam
    Commented Oct 15, 2022 at 12:39
  • @Essam You seem to be thinking about circuit switching, not packet switching. There's no predefined path for packets. Those each carry a destination address and need to be forwarded across multiple hops, each deciding where to forward the packet to next.
    – Zac67
    Commented Oct 15, 2022 at 13:01
  • Okay then, I was perhaps mislead with the term "path determination". So the network layer at each node decided the next trajectory, correct? And the network layer in the last node just checks that this is where the data belongs (no more forwarding).
    – Essam
    Commented Oct 15, 2022 at 13:05
  • 1
    RE “But in this case I think they know their way”. It’s unclear whether the “network knows their way” or “packets know their way”. Nothing about networking is magical in that you plug a router in and nothing else is required. This in fact is why people hire experienced network engineers. We carefully choose and organize network connectivity based on the needs of the business. It doesn’t just happen all by itself; professional judgment is required. Commented Oct 15, 2022 at 16:49

2 Answers 2

1

What does the network layer do at the receiver

At the receiver, the network layer (L3) provides information about the destination address, the source address, and the 'next-layer protocol' used in the payload (usually transport layer/L4).

The destination address may be important as there may be multiple L3 addresses bound to an interface. That way, the destination host may react differently to requests made to different addresses (used for different roles). The source address is important for identifying the communication partner at the host level. The next-layer protocol is important for passing the payload on internally, e.g. to the TCP or the UDP protocol handler.

2

An important role of network layer is global addressing, routing and translating network addresses to data link level addresses (which is done using ARP if using Ethernet).

For example, we know that www.google.com can be reached at 216.58.209.164 (and via IPv6 at 2a00:1450:4026:804::2004).

What we don't know is which data link level address www.google.com uses. In fact, we don't even know if the address is a 48-bit Ethernet address, and if it happens to be a 48-bit Ethernet address, it doesn't even have to be globally unique (for example virtual machines don't allocate globally unique addresses but just have randomly generated addresses). It only has to be unique at that particular data link.

When we send a packet to www.google.com, we reach it via the local gateway which in my case is 10.0.2.2 (an address in private address space since I'm behind NAT). So we use ARP to translate 10.0.2.2 into a data link level address, and send a packet to this data link level address with the destination IP address field set to 216.58.209.164.

This default router, 10.0.2.2, is able to find a next hop in the path towards 216.58.209.164. Every next hop will find a next hop further. Eventually the packet reaches 216.58.209.164. Every hop decrements the time-to-live header field to prevent packets from looping in the network forever in case there are routing loops.

In the case of IP, the network layer also tells what protocol (IP, UDP, ICMP) is being used for the next header, what length the packet is (the data link layer may also do this but may have a minimum length in which case IP-level length is needed to further restrict the length), and contains also checksumming for the packet header.

IP also has fragmentation feature, allowing sending large packets (up to 65535 bytes) via routing paths containing links that don't support such large packets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.