Internetworking 101 series – Packets (Network Layer)

Internetworking 101 series – Packets (Network Layer)

July 29, 2013 1 By Eric Shanks

ChalkboardThis is a series of posts designed to help readers understand how the Internet works.  This specific post looks directly at how machines on different network segments communicate.

In my previous post, we looked at how two machines on the same network segment exchange information by using frames.  So what happens when two machines on different segments need to communicate?

Encapsulation

Before we get too involved in the discussion, we should take a peak at what an IP packet looks like.  IP Packets relate to Ethernet frames much like one nesting doll relates to the rest in the set.

matrioska_carolinaantunesAn IP Packet isn’t useful on it’s own.  It needs an Ethernet frame in order to travel to it’s destination.  So the IP Packet is encapsulated inside of an Ethernet frame for travel along a network segment.

comparison

IPackets contain a source and a destination, as well as the data it’s trying to send (called the payload).  IP Packets will also contain other things such as priority, checksums, time to live etc, but to keep it simple, just think of it as the source, destination and payload with a few other things thrown in.

Routing

In the below example I’ve revisited a scenario where two computers are trying to exchange information, and are on different network segments.  In order for different networks to communicate we need to have a layer three device. In this case our layer three device is a router (you could have a layer three switch but in this case we have layer 2 switches to illustrate the point).

Packets

When Computer A attempts to send information to Computer B, it first checks to see if the destination IP address is in the same network segment.  In the above example we find that the two machines are on different networks so instead of sending the frame to Computer B, it is sent to the default gateway which has a MAC address of CC:CC:CC:CC:CC:CC.

Once the Router receives the frame on the CC:CC:CC:CC:CC:CC physical adapter, it will break down the Ethernet Frame and read the IP Packet which is encapsulated inside the frame.  The router can then compare the source and destination IP addresses in the packet and compare them to it’s routing table.  For our example we’ll assume there is a route to computer B.  The router will then encapsulate the IP Packet in a new frame and send it to Computer B.

Visually it looks like this: (Please excuse the crude diagram.  There is more to a frame and a packet than shown, but this illustrates how the encapsulation works.)

Frame is sent to the default gateway with a destination IP Address of 192.168.50.1.

Encapsulated1

 

Frame is delivered to the router.  The router strips the frame apart to reveal the Packet.  The packet can then be compared against the routing table for a next hop.

Encapsulated2

The router makes a routing decision and forwards a new frame to Computer B.

Encapsulated3

Notice that the packet information didn’t change, but the source MAC and the destination MAC in the new frame is different.