1

I'm reading about link and network layers for the first time and I'm trying to put the pieces together to understand how they work together. My question may not have to do with the link layer but I'm not sure. Here is my concern:

Let's say that an IP A wants to send a packet to a destination IP B. The best path(route) is known and includes a router with IP Ra and a router with IP Rb.

So, our path is A->Ra->Rb->B.

I know that in an IPv4 packet format, there is a field for the destination IP.

Q1:For the packet in system A, does that field include IP B or Ra?

Q2: If B is in that field, where is Ra written so that the proper MAC address in the link layer is found? Is the path/route determined in layer 3 or layer 2? If it is determined in layer 3, the information for Ra must be included somewhere as it goes down to layer 2, right?

  • Think about it for a second... if the IP header lists Ra as the dest, how would Ra know it's supposed to go to B? – Ricky Beam Feb 4 at 13:37
2

IP was designed as an end-to-end protocol. The source and destination IP addresses are the actual source and destination host IP addresses. With the exception of NAT (which breaks the IP end-to-end paradigm), the IP addresses in a packet header do not change.

Host A sending a packet to Host B will create the packet with the source IP address of Host A, and destination IP address of Host B.


Edit:

For your new question, the frame gets the MAC address of the configured gateway of Host A. Host A determines that Host B is on a different network, so when it creates the frame, it uses the MAC address of its configured gateway for the destination address in the frame. That hs nothing to do with the IP packet.

| improve this answer | |
2

Q1:For the packet in system A, does that field include IP B or Ra?

As Ron Maupin already wrote, the IP packet contains the IP address B.

However, the Ethernet frame that contains this IP packet will contain the MAC address of Ra (the network is an Ethernet network).

Q2: ... If it is determined in layer 3, the information for Ra must be included somewhere as it goes down to layer 2, right?

In principle, every computer in an IP (IPv4 or IPv6) network has a so-called "routing table":

This table contains information about the next router required to reach the "final" destination computer.

Let's say the address of "A" is 10.11.20.21 "B" is 10.11.12.13. In computer "A" the routing table may look like this:

10.11.20.0 - 10.11.21.255: Sent directly over network card #1
10.11.30.0 - 10.11.30.255: Sent over router "Rc" (10.11.20.23)
All others: Sent over router "Ra" (10.11.20.22)

... and on router "Ra" the table may look like this:

10.11.20.0 - 10.11.21.255: Sent directly over network card #2
10.11.40.0 - 10.11.41.255: Sent directly over network card #3
10.11.30.0 - 10.11.30.255: Sent over router "Rc" (10.11.20.23)
All others: Sent over router "Rb" (10.11.40.41)

... and on router "Rb" the table could look like this:

10.11.12.0 - 10.11.12.255: Sent directly over network card #4
10.11.40.0 - 10.11.41.255: Sent directly over network card #5
10.11.20.0 - 10.11.21.255: Sent over router "Ra" (10.11.40.44)
All others: Sent to internet provider (PPP connection)

This information is not sent together with the IP packet. It cannot even be sent together with the IP packet because computer "A" does not know about router "Rb" at all.

To get the MAC address belonging to the IP address of the next node (e.g. router), the ARP protocol is used.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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