Networking for Developers – part 3: Network and Physical layers


NOTE: Catch up with the previous posts in this post series:

Part 1: Overview

Part 2: Application and Transport layers

In the Internet, the network layer uses the Internet Protocol and it’s responsible to analyse the destination address in the packets and direct them to where they should go. The job to actually move the packets around belongs to the Physical layer, the bottom-most layer who sits on top of the hardware.

If you are the person configuring a local network (a small office, for example) you will need to learn how subnets mask and network prefixes work in order to route the packets properly to send them either to another host (computer) in your internal network or to tell the GATEWAY to send packets to another network, which could be the internet. I will not cover that kind of information because that is not the focus of this series.

Two main protocols used by the network layer are the ICMP (Internet Control Message Protocol), responsible for connectivity and routing, and the DNS (Domain Name Service), responsible for mapping host names to IP addresses.

When it comes to actually moving the data around, the physical layer takes over: all devices in a network have a physical address, the MAC (Media access Control) address. The data here is wrapped and is sent around as frames. The frame will have the origin and the destination MAC address, so the device in the physical layer of the network will know to which device it should move the data to.

A router (a physical device in the network), can re-frame some data in case it needs to send it to a host in a different physical network.

The main tools to troubleshoot the network layer are the following:


If used with no arguments will display the status of the host’s network interface. This is the command you should use to find out the IP address of the host. The output will display at least Ethernet (eth0) or Wifi (wlan0) interfaces, the localhost (lo) interface, which is a virtual network interface called loopback, among others.



It will send an ICMP echo request to a network host. If the receiving host gets the packet and is configured to respond, it will send back an ICMP echo response. Two main things to pay attention in the output of this command are the icmp_seq which ideally will be in sequence so this tells you that no packets were lost in this transmission and the time, which tells you how long the round-trip took. If you see a number higher than 1000ms, that means a slow connection.

You can use a host name or an IP address:


You can stop ping‘s output with CTRL+C or you can limit the output count by using the -c option like this:

ping -c 3


It tracks the path that the packets take to reach a remote host. It can be helpful to detect in which point of the path there’s a hold up or block, for example. This command can take a host name or IP address:



It’s a DNS lookup utility and will convert names to IP addresses and vice-versa.


Two useful tools to troubleshoot the physical layer:


It displays information about network driver and hardware settings. It takes as an argument a network interface name – that we just learned we can find out by using ifconfig 😉 The main thing to pay attention on ethtool‘s output is the link detected which will tell you that the hardware is actually on and connected. It might also be helpful to check the speed, which is the speed that the hardware is able to transmit data, and the duplex that will tell you what is the current duplex mode. Note that not all interfaces will have these extra info.

ethtool eth0


arp stands for Address Resolution Protocol and is used to find the MAC address of a device in the network. This can be useful to check that there aren’t conflicts in the network configuration. It can take an IP address as argument or no arguments at all, in which case will display all known MAC addresses.


Once again, there’s a lot more that could be said about these layers and network in general. Here are some resources to expand the information I shared in this series (most of them are from Julia because she rocks explaining stuff!):

The post Networking for Developers – part 3: network and physical layers was originally published at

Related Posts

One thought on “Networking for Developers – part 3: Network and Physical layers

Comments are closed.