Need help understanding how packets travel across the internet

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I've been learning about networks recently at a new job, and I did a presentation on what I've learnt so far. When I was describing the relationship between the datalink and network layer, I mentioned that datalink handles the hops while network is end to end. After I was done they grilled me with some questions, and one of them asked me if the datalink layer handles packets traveling across the internet, to which I replied yes. They told me I was wrong, but I didn't ask them for the right answer because I was nervous and it really didn't cross my mind to ask. But now that I've gone back to researching this topic I'm starting to get confused and I was hoping I could have someone clear this up for me. Was I wrong? Or perhaps I explained it poorly? Here's my knowledge so far:



The packet comes with headers that contain information concerning packet delivery and whatnot. The IP header has the source and destination IP address for the packet, which is used to get the packet across the internet. On the other hand the layer 2 frame header (ethernet or whatever) has the MAC address of the source (which would be the original host at this point) and the MAC address of the next router the packet is to be sent to (using ARP). The IP packet is left alone but with each hop the frame header is rewritten with a new source (the router's) MAC address and a new destination (the next hop). This is repeated within the network until a gateway within that network is reached, where the packet is then forwarded onto the ISP/provider's network. The same thing happens within the ISP/provider's network, with the packet (frame) being sent over the datalink layer while using the IP header for ARP. EGPs like BGP are used across networks, and IGPs are used within networks. And while IP addresses indicate the final destination, even over the internet MAC addresses are used to transport the data from router to router.



This makes sense to me because the internet is physically connected and MAC addresses are king when it comes to physical connections. But after being told I was wrong I've kinda lost confidence and now I'm just confusing myself. Is a different protocol or method used when data is sent from within the local network into the internet? Are MAC addresses only relevant within a network? Any help clearing this up for me is greatly appreciated. Thanks!










share|improve this question







New contributor




jwoff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    2
    down vote

    favorite












    I've been learning about networks recently at a new job, and I did a presentation on what I've learnt so far. When I was describing the relationship between the datalink and network layer, I mentioned that datalink handles the hops while network is end to end. After I was done they grilled me with some questions, and one of them asked me if the datalink layer handles packets traveling across the internet, to which I replied yes. They told me I was wrong, but I didn't ask them for the right answer because I was nervous and it really didn't cross my mind to ask. But now that I've gone back to researching this topic I'm starting to get confused and I was hoping I could have someone clear this up for me. Was I wrong? Or perhaps I explained it poorly? Here's my knowledge so far:



    The packet comes with headers that contain information concerning packet delivery and whatnot. The IP header has the source and destination IP address for the packet, which is used to get the packet across the internet. On the other hand the layer 2 frame header (ethernet or whatever) has the MAC address of the source (which would be the original host at this point) and the MAC address of the next router the packet is to be sent to (using ARP). The IP packet is left alone but with each hop the frame header is rewritten with a new source (the router's) MAC address and a new destination (the next hop). This is repeated within the network until a gateway within that network is reached, where the packet is then forwarded onto the ISP/provider's network. The same thing happens within the ISP/provider's network, with the packet (frame) being sent over the datalink layer while using the IP header for ARP. EGPs like BGP are used across networks, and IGPs are used within networks. And while IP addresses indicate the final destination, even over the internet MAC addresses are used to transport the data from router to router.



    This makes sense to me because the internet is physically connected and MAC addresses are king when it comes to physical connections. But after being told I was wrong I've kinda lost confidence and now I'm just confusing myself. Is a different protocol or method used when data is sent from within the local network into the internet? Are MAC addresses only relevant within a network? Any help clearing this up for me is greatly appreciated. Thanks!










    share|improve this question







    New contributor




    jwoff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I've been learning about networks recently at a new job, and I did a presentation on what I've learnt so far. When I was describing the relationship between the datalink and network layer, I mentioned that datalink handles the hops while network is end to end. After I was done they grilled me with some questions, and one of them asked me if the datalink layer handles packets traveling across the internet, to which I replied yes. They told me I was wrong, but I didn't ask them for the right answer because I was nervous and it really didn't cross my mind to ask. But now that I've gone back to researching this topic I'm starting to get confused and I was hoping I could have someone clear this up for me. Was I wrong? Or perhaps I explained it poorly? Here's my knowledge so far:



      The packet comes with headers that contain information concerning packet delivery and whatnot. The IP header has the source and destination IP address for the packet, which is used to get the packet across the internet. On the other hand the layer 2 frame header (ethernet or whatever) has the MAC address of the source (which would be the original host at this point) and the MAC address of the next router the packet is to be sent to (using ARP). The IP packet is left alone but with each hop the frame header is rewritten with a new source (the router's) MAC address and a new destination (the next hop). This is repeated within the network until a gateway within that network is reached, where the packet is then forwarded onto the ISP/provider's network. The same thing happens within the ISP/provider's network, with the packet (frame) being sent over the datalink layer while using the IP header for ARP. EGPs like BGP are used across networks, and IGPs are used within networks. And while IP addresses indicate the final destination, even over the internet MAC addresses are used to transport the data from router to router.



      This makes sense to me because the internet is physically connected and MAC addresses are king when it comes to physical connections. But after being told I was wrong I've kinda lost confidence and now I'm just confusing myself. Is a different protocol or method used when data is sent from within the local network into the internet? Are MAC addresses only relevant within a network? Any help clearing this up for me is greatly appreciated. Thanks!










      share|improve this question







      New contributor




      jwoff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I've been learning about networks recently at a new job, and I did a presentation on what I've learnt so far. When I was describing the relationship between the datalink and network layer, I mentioned that datalink handles the hops while network is end to end. After I was done they grilled me with some questions, and one of them asked me if the datalink layer handles packets traveling across the internet, to which I replied yes. They told me I was wrong, but I didn't ask them for the right answer because I was nervous and it really didn't cross my mind to ask. But now that I've gone back to researching this topic I'm starting to get confused and I was hoping I could have someone clear this up for me. Was I wrong? Or perhaps I explained it poorly? Here's my knowledge so far:



      The packet comes with headers that contain information concerning packet delivery and whatnot. The IP header has the source and destination IP address for the packet, which is used to get the packet across the internet. On the other hand the layer 2 frame header (ethernet or whatever) has the MAC address of the source (which would be the original host at this point) and the MAC address of the next router the packet is to be sent to (using ARP). The IP packet is left alone but with each hop the frame header is rewritten with a new source (the router's) MAC address and a new destination (the next hop). This is repeated within the network until a gateway within that network is reached, where the packet is then forwarded onto the ISP/provider's network. The same thing happens within the ISP/provider's network, with the packet (frame) being sent over the datalink layer while using the IP header for ARP. EGPs like BGP are used across networks, and IGPs are used within networks. And while IP addresses indicate the final destination, even over the internet MAC addresses are used to transport the data from router to router.



      This makes sense to me because the internet is physically connected and MAC addresses are king when it comes to physical connections. But after being told I was wrong I've kinda lost confidence and now I'm just confusing myself. Is a different protocol or method used when data is sent from within the local network into the internet? Are MAC addresses only relevant within a network? Any help clearing this up for me is greatly appreciated. Thanks!







      ip network mac-address internet






      share|improve this question







      New contributor




      jwoff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      jwoff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      jwoff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 7 hours ago









      jwoff

      133




      133




      New contributor




      jwoff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      jwoff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      jwoff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          MAC addresses are only seen or relevant on the LAN where the host with that MAC address is. Routers strip off and discard layer-2 frames, losing any layer-2 information, including MAC addresses.



          Remember that not all layer-2 protocols use MAC addresses, and there are 48-bit and 64-bit MAC addresses, depending on the IEEE LAN protocol used (it is the IEEE LAN protocols that use MAC addresses). Other layer-2 protocols, especially those used for WAN connections, may not use MAC addresses. For example frame relay uses DLCI, ATM uses VPI/VCI, PPP and HDLC do not really use addressing, etc.



          Layer-3 protocols, like IP, are used to deliver packets between networks (an internet, hence the name: Internet Protocol), but layer-2 protocols are used to deliver frames on the same network.






          share|improve this answer




















          • Thanks for the answer! Can I get some clarification on how IP is used when packets are sent between networks? I understand the IP address is used to figure out which network to send it to but doesn't the data need to go through the datalink (and physical) layer to actually get sent? Sorry if I'm not fully comprehending your answer.
            – jwoff
            6 hours ago










          • A router will search its routing table to see if it has an entry to use to forward the packet. If not it drops the packet, otherwise is builds a new frame for the protocol of the next interface, which could be a completely different protocol than on the incoming interface. The physical and data-link of the next interface have no relationship to that of the incoming interface. Layer-3 devices bound a layer-2 LAN.
            – Ron Maupin♦
            6 hours ago










          • I see, I think I understand. Thank you!
            – jwoff
            6 hours ago

















          up vote
          1
          down vote













          You need to look at the layers as each having its own mission.



          The network layer is - as you wrote - end-to-end. Its addresses have global meaning (within the scope of the entire network). Accordingly, a network layer packet has a source and a destination address that don't change. NAT messes this up, but that can be seen as a translation layer or context change.



          However, the network layer's mission is to make the packet routable along the hops across the network. It doesn't actually move the data. Instead, it uses the data link layer to get the data from one node to another within the current segment.



          The data link layer's task is to move data (frames) across the local segment. The segment can hold a fairly large number of nodes, so you need a way to distinguish or address them - that's where MAC addresses come into play (for Ethernet and other MAC-based segments). The network layer packet is encapsulated in a data link layer frame, addressed to the next hop's "hardware" address (local to the segment) and sent over. Note that the hardware/MAC address is only meaningful within the scope of its segment.



          For completeness, the data link layer doesn't actually move data either. Instead, it uses the physical layer to move the bits of the frame from one place to another, one link at a time.



          Which one of the potentially many physical layer links is used (on a switch) is controlled by the data link layer (switching). At the end of the segment, the packet is extracted from the frame and forwarded across the next segment to the next hop. Which segment is used is controlled by the network layer's routing, ie. the current hop's/router's/gateway's routing table.



          At the end, across all hops, the network packet is delivered to its destination address - voilà.






          share|improve this answer




















          • Thanks for the answer! So when a gateway finds the next router to send the packet to based on the destination IP and routing table, how does it send the packet to that gateway/router? Does something in the IP protocol do that or is a datalink protocol required?
            – jwoff
            6 hours ago

















          up vote
          1
          down vote













          ... as an afterword to the other fine answers ...



          When we look at a packet travelling multiple hops across the internet, with the IP address "staying the same" and the MAC addresses "changing per hop", or think of the routers unwrapping an IP packet from the ethernet frame and then rewrapping it for the next segment, we are taking a birds-eye understanding the purpose of the whole enterprise.



          But in an IP network, none of the machinery involved has this point of view. One of the fundamentals of the IP design is that every single packet has a routing decision made at every single hop, and these decisions are completely independent of it each other.



          Thus, when a packet arrives at a router on some ethernet interface, the actions are:



          • Receive frame

          • Extract packet


          • Decide what to do:

            • Discard packet, or

            • Consume packet, or

            • Forward packet


          This happens for every single packet on every single hop.



          (Digressing for astonishing scale: Internet traffic is supposed to be around 150 petabyte/month, which is 150 x 1015, at an illustrative 1000 bytes/packet and 5 hops/packet, would be about 285 Mevent/sec.)



          The detail is more elaborate.



          (Confining my description to a packet arriving and leaving on ethernet interfaces.)



          1. The interface hardware checks the integrity of the frame (ethernet FCS, for example) and discards it if wrong

          2. The interface hardware checks the destination MAC address, and discards the frame if not for this MAC address

          3. It checks the content type and discards the frame if its a type this router doesn't handle

          4. Assuming it's an IP payload

          5. It unwraps the payload IP packet

          6. It checks the header checksum and discards if error

          7. It checks the destination IP address and if for this router consumes it locally

          8. Assuming for some other host (and TTL > 1)

          9. Checks routing table

          10. Assuming it's for another network connected by an ethernet interface

          11. Makes appropriate change (decrement TTL, fragment, recompute header checksums)

          12. Finds target MAC address from routing table/cache/ARP

          13. Wraps IP packet in ethernet frame and transmits

          At step 2, the incoming frame's destination MAC address was the MAC address of the incoming interface; at step 13 the outgoing frame has the router's outgoing interface MAC address for source, and the next hop router's MAC address as destination.



          Of course, the operating system of the router is likely to add various security checks, logging and accounting along the way.






          share|improve this answer






















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "496"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );






            jwoff is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fnetworkengineering.stackexchange.com%2fquestions%2f54065%2fneed-help-understanding-how-packets-travel-across-the-internet%23new-answer', 'question_page');

            );

            Post as a guest






























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            MAC addresses are only seen or relevant on the LAN where the host with that MAC address is. Routers strip off and discard layer-2 frames, losing any layer-2 information, including MAC addresses.



            Remember that not all layer-2 protocols use MAC addresses, and there are 48-bit and 64-bit MAC addresses, depending on the IEEE LAN protocol used (it is the IEEE LAN protocols that use MAC addresses). Other layer-2 protocols, especially those used for WAN connections, may not use MAC addresses. For example frame relay uses DLCI, ATM uses VPI/VCI, PPP and HDLC do not really use addressing, etc.



            Layer-3 protocols, like IP, are used to deliver packets between networks (an internet, hence the name: Internet Protocol), but layer-2 protocols are used to deliver frames on the same network.






            share|improve this answer




















            • Thanks for the answer! Can I get some clarification on how IP is used when packets are sent between networks? I understand the IP address is used to figure out which network to send it to but doesn't the data need to go through the datalink (and physical) layer to actually get sent? Sorry if I'm not fully comprehending your answer.
              – jwoff
              6 hours ago










            • A router will search its routing table to see if it has an entry to use to forward the packet. If not it drops the packet, otherwise is builds a new frame for the protocol of the next interface, which could be a completely different protocol than on the incoming interface. The physical and data-link of the next interface have no relationship to that of the incoming interface. Layer-3 devices bound a layer-2 LAN.
              – Ron Maupin♦
              6 hours ago










            • I see, I think I understand. Thank you!
              – jwoff
              6 hours ago














            up vote
            1
            down vote



            accepted










            MAC addresses are only seen or relevant on the LAN where the host with that MAC address is. Routers strip off and discard layer-2 frames, losing any layer-2 information, including MAC addresses.



            Remember that not all layer-2 protocols use MAC addresses, and there are 48-bit and 64-bit MAC addresses, depending on the IEEE LAN protocol used (it is the IEEE LAN protocols that use MAC addresses). Other layer-2 protocols, especially those used for WAN connections, may not use MAC addresses. For example frame relay uses DLCI, ATM uses VPI/VCI, PPP and HDLC do not really use addressing, etc.



            Layer-3 protocols, like IP, are used to deliver packets between networks (an internet, hence the name: Internet Protocol), but layer-2 protocols are used to deliver frames on the same network.






            share|improve this answer




















            • Thanks for the answer! Can I get some clarification on how IP is used when packets are sent between networks? I understand the IP address is used to figure out which network to send it to but doesn't the data need to go through the datalink (and physical) layer to actually get sent? Sorry if I'm not fully comprehending your answer.
              – jwoff
              6 hours ago










            • A router will search its routing table to see if it has an entry to use to forward the packet. If not it drops the packet, otherwise is builds a new frame for the protocol of the next interface, which could be a completely different protocol than on the incoming interface. The physical and data-link of the next interface have no relationship to that of the incoming interface. Layer-3 devices bound a layer-2 LAN.
              – Ron Maupin♦
              6 hours ago










            • I see, I think I understand. Thank you!
              – jwoff
              6 hours ago












            up vote
            1
            down vote



            accepted







            up vote
            1
            down vote



            accepted






            MAC addresses are only seen or relevant on the LAN where the host with that MAC address is. Routers strip off and discard layer-2 frames, losing any layer-2 information, including MAC addresses.



            Remember that not all layer-2 protocols use MAC addresses, and there are 48-bit and 64-bit MAC addresses, depending on the IEEE LAN protocol used (it is the IEEE LAN protocols that use MAC addresses). Other layer-2 protocols, especially those used for WAN connections, may not use MAC addresses. For example frame relay uses DLCI, ATM uses VPI/VCI, PPP and HDLC do not really use addressing, etc.



            Layer-3 protocols, like IP, are used to deliver packets between networks (an internet, hence the name: Internet Protocol), but layer-2 protocols are used to deliver frames on the same network.






            share|improve this answer












            MAC addresses are only seen or relevant on the LAN where the host with that MAC address is. Routers strip off and discard layer-2 frames, losing any layer-2 information, including MAC addresses.



            Remember that not all layer-2 protocols use MAC addresses, and there are 48-bit and 64-bit MAC addresses, depending on the IEEE LAN protocol used (it is the IEEE LAN protocols that use MAC addresses). Other layer-2 protocols, especially those used for WAN connections, may not use MAC addresses. For example frame relay uses DLCI, ATM uses VPI/VCI, PPP and HDLC do not really use addressing, etc.



            Layer-3 protocols, like IP, are used to deliver packets between networks (an internet, hence the name: Internet Protocol), but layer-2 protocols are used to deliver frames on the same network.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 6 hours ago









            Ron Maupin♦

            58.3k1056101




            58.3k1056101











            • Thanks for the answer! Can I get some clarification on how IP is used when packets are sent between networks? I understand the IP address is used to figure out which network to send it to but doesn't the data need to go through the datalink (and physical) layer to actually get sent? Sorry if I'm not fully comprehending your answer.
              – jwoff
              6 hours ago










            • A router will search its routing table to see if it has an entry to use to forward the packet. If not it drops the packet, otherwise is builds a new frame for the protocol of the next interface, which could be a completely different protocol than on the incoming interface. The physical and data-link of the next interface have no relationship to that of the incoming interface. Layer-3 devices bound a layer-2 LAN.
              – Ron Maupin♦
              6 hours ago










            • I see, I think I understand. Thank you!
              – jwoff
              6 hours ago
















            • Thanks for the answer! Can I get some clarification on how IP is used when packets are sent between networks? I understand the IP address is used to figure out which network to send it to but doesn't the data need to go through the datalink (and physical) layer to actually get sent? Sorry if I'm not fully comprehending your answer.
              – jwoff
              6 hours ago










            • A router will search its routing table to see if it has an entry to use to forward the packet. If not it drops the packet, otherwise is builds a new frame for the protocol of the next interface, which could be a completely different protocol than on the incoming interface. The physical and data-link of the next interface have no relationship to that of the incoming interface. Layer-3 devices bound a layer-2 LAN.
              – Ron Maupin♦
              6 hours ago










            • I see, I think I understand. Thank you!
              – jwoff
              6 hours ago















            Thanks for the answer! Can I get some clarification on how IP is used when packets are sent between networks? I understand the IP address is used to figure out which network to send it to but doesn't the data need to go through the datalink (and physical) layer to actually get sent? Sorry if I'm not fully comprehending your answer.
            – jwoff
            6 hours ago




            Thanks for the answer! Can I get some clarification on how IP is used when packets are sent between networks? I understand the IP address is used to figure out which network to send it to but doesn't the data need to go through the datalink (and physical) layer to actually get sent? Sorry if I'm not fully comprehending your answer.
            – jwoff
            6 hours ago












            A router will search its routing table to see if it has an entry to use to forward the packet. If not it drops the packet, otherwise is builds a new frame for the protocol of the next interface, which could be a completely different protocol than on the incoming interface. The physical and data-link of the next interface have no relationship to that of the incoming interface. Layer-3 devices bound a layer-2 LAN.
            – Ron Maupin♦
            6 hours ago




            A router will search its routing table to see if it has an entry to use to forward the packet. If not it drops the packet, otherwise is builds a new frame for the protocol of the next interface, which could be a completely different protocol than on the incoming interface. The physical and data-link of the next interface have no relationship to that of the incoming interface. Layer-3 devices bound a layer-2 LAN.
            – Ron Maupin♦
            6 hours ago












            I see, I think I understand. Thank you!
            – jwoff
            6 hours ago




            I see, I think I understand. Thank you!
            – jwoff
            6 hours ago










            up vote
            1
            down vote













            You need to look at the layers as each having its own mission.



            The network layer is - as you wrote - end-to-end. Its addresses have global meaning (within the scope of the entire network). Accordingly, a network layer packet has a source and a destination address that don't change. NAT messes this up, but that can be seen as a translation layer or context change.



            However, the network layer's mission is to make the packet routable along the hops across the network. It doesn't actually move the data. Instead, it uses the data link layer to get the data from one node to another within the current segment.



            The data link layer's task is to move data (frames) across the local segment. The segment can hold a fairly large number of nodes, so you need a way to distinguish or address them - that's where MAC addresses come into play (for Ethernet and other MAC-based segments). The network layer packet is encapsulated in a data link layer frame, addressed to the next hop's "hardware" address (local to the segment) and sent over. Note that the hardware/MAC address is only meaningful within the scope of its segment.



            For completeness, the data link layer doesn't actually move data either. Instead, it uses the physical layer to move the bits of the frame from one place to another, one link at a time.



            Which one of the potentially many physical layer links is used (on a switch) is controlled by the data link layer (switching). At the end of the segment, the packet is extracted from the frame and forwarded across the next segment to the next hop. Which segment is used is controlled by the network layer's routing, ie. the current hop's/router's/gateway's routing table.



            At the end, across all hops, the network packet is delivered to its destination address - voilà.






            share|improve this answer




















            • Thanks for the answer! So when a gateway finds the next router to send the packet to based on the destination IP and routing table, how does it send the packet to that gateway/router? Does something in the IP protocol do that or is a datalink protocol required?
              – jwoff
              6 hours ago














            up vote
            1
            down vote













            You need to look at the layers as each having its own mission.



            The network layer is - as you wrote - end-to-end. Its addresses have global meaning (within the scope of the entire network). Accordingly, a network layer packet has a source and a destination address that don't change. NAT messes this up, but that can be seen as a translation layer or context change.



            However, the network layer's mission is to make the packet routable along the hops across the network. It doesn't actually move the data. Instead, it uses the data link layer to get the data from one node to another within the current segment.



            The data link layer's task is to move data (frames) across the local segment. The segment can hold a fairly large number of nodes, so you need a way to distinguish or address them - that's where MAC addresses come into play (for Ethernet and other MAC-based segments). The network layer packet is encapsulated in a data link layer frame, addressed to the next hop's "hardware" address (local to the segment) and sent over. Note that the hardware/MAC address is only meaningful within the scope of its segment.



            For completeness, the data link layer doesn't actually move data either. Instead, it uses the physical layer to move the bits of the frame from one place to another, one link at a time.



            Which one of the potentially many physical layer links is used (on a switch) is controlled by the data link layer (switching). At the end of the segment, the packet is extracted from the frame and forwarded across the next segment to the next hop. Which segment is used is controlled by the network layer's routing, ie. the current hop's/router's/gateway's routing table.



            At the end, across all hops, the network packet is delivered to its destination address - voilà.






            share|improve this answer




















            • Thanks for the answer! So when a gateway finds the next router to send the packet to based on the destination IP and routing table, how does it send the packet to that gateway/router? Does something in the IP protocol do that or is a datalink protocol required?
              – jwoff
              6 hours ago












            up vote
            1
            down vote










            up vote
            1
            down vote









            You need to look at the layers as each having its own mission.



            The network layer is - as you wrote - end-to-end. Its addresses have global meaning (within the scope of the entire network). Accordingly, a network layer packet has a source and a destination address that don't change. NAT messes this up, but that can be seen as a translation layer or context change.



            However, the network layer's mission is to make the packet routable along the hops across the network. It doesn't actually move the data. Instead, it uses the data link layer to get the data from one node to another within the current segment.



            The data link layer's task is to move data (frames) across the local segment. The segment can hold a fairly large number of nodes, so you need a way to distinguish or address them - that's where MAC addresses come into play (for Ethernet and other MAC-based segments). The network layer packet is encapsulated in a data link layer frame, addressed to the next hop's "hardware" address (local to the segment) and sent over. Note that the hardware/MAC address is only meaningful within the scope of its segment.



            For completeness, the data link layer doesn't actually move data either. Instead, it uses the physical layer to move the bits of the frame from one place to another, one link at a time.



            Which one of the potentially many physical layer links is used (on a switch) is controlled by the data link layer (switching). At the end of the segment, the packet is extracted from the frame and forwarded across the next segment to the next hop. Which segment is used is controlled by the network layer's routing, ie. the current hop's/router's/gateway's routing table.



            At the end, across all hops, the network packet is delivered to its destination address - voilà.






            share|improve this answer












            You need to look at the layers as each having its own mission.



            The network layer is - as you wrote - end-to-end. Its addresses have global meaning (within the scope of the entire network). Accordingly, a network layer packet has a source and a destination address that don't change. NAT messes this up, but that can be seen as a translation layer or context change.



            However, the network layer's mission is to make the packet routable along the hops across the network. It doesn't actually move the data. Instead, it uses the data link layer to get the data from one node to another within the current segment.



            The data link layer's task is to move data (frames) across the local segment. The segment can hold a fairly large number of nodes, so you need a way to distinguish or address them - that's where MAC addresses come into play (for Ethernet and other MAC-based segments). The network layer packet is encapsulated in a data link layer frame, addressed to the next hop's "hardware" address (local to the segment) and sent over. Note that the hardware/MAC address is only meaningful within the scope of its segment.



            For completeness, the data link layer doesn't actually move data either. Instead, it uses the physical layer to move the bits of the frame from one place to another, one link at a time.



            Which one of the potentially many physical layer links is used (on a switch) is controlled by the data link layer (switching). At the end of the segment, the packet is extracted from the frame and forwarded across the next segment to the next hop. Which segment is used is controlled by the network layer's routing, ie. the current hop's/router's/gateway's routing table.



            At the end, across all hops, the network packet is delivered to its destination address - voilà.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 6 hours ago









            Zac67

            21.4k21149




            21.4k21149











            • Thanks for the answer! So when a gateway finds the next router to send the packet to based on the destination IP and routing table, how does it send the packet to that gateway/router? Does something in the IP protocol do that or is a datalink protocol required?
              – jwoff
              6 hours ago
















            • Thanks for the answer! So when a gateway finds the next router to send the packet to based on the destination IP and routing table, how does it send the packet to that gateway/router? Does something in the IP protocol do that or is a datalink protocol required?
              – jwoff
              6 hours ago















            Thanks for the answer! So when a gateway finds the next router to send the packet to based on the destination IP and routing table, how does it send the packet to that gateway/router? Does something in the IP protocol do that or is a datalink protocol required?
            – jwoff
            6 hours ago




            Thanks for the answer! So when a gateway finds the next router to send the packet to based on the destination IP and routing table, how does it send the packet to that gateway/router? Does something in the IP protocol do that or is a datalink protocol required?
            – jwoff
            6 hours ago










            up vote
            1
            down vote













            ... as an afterword to the other fine answers ...



            When we look at a packet travelling multiple hops across the internet, with the IP address "staying the same" and the MAC addresses "changing per hop", or think of the routers unwrapping an IP packet from the ethernet frame and then rewrapping it for the next segment, we are taking a birds-eye understanding the purpose of the whole enterprise.



            But in an IP network, none of the machinery involved has this point of view. One of the fundamentals of the IP design is that every single packet has a routing decision made at every single hop, and these decisions are completely independent of it each other.



            Thus, when a packet arrives at a router on some ethernet interface, the actions are:



            • Receive frame

            • Extract packet


            • Decide what to do:

              • Discard packet, or

              • Consume packet, or

              • Forward packet


            This happens for every single packet on every single hop.



            (Digressing for astonishing scale: Internet traffic is supposed to be around 150 petabyte/month, which is 150 x 1015, at an illustrative 1000 bytes/packet and 5 hops/packet, would be about 285 Mevent/sec.)



            The detail is more elaborate.



            (Confining my description to a packet arriving and leaving on ethernet interfaces.)



            1. The interface hardware checks the integrity of the frame (ethernet FCS, for example) and discards it if wrong

            2. The interface hardware checks the destination MAC address, and discards the frame if not for this MAC address

            3. It checks the content type and discards the frame if its a type this router doesn't handle

            4. Assuming it's an IP payload

            5. It unwraps the payload IP packet

            6. It checks the header checksum and discards if error

            7. It checks the destination IP address and if for this router consumes it locally

            8. Assuming for some other host (and TTL > 1)

            9. Checks routing table

            10. Assuming it's for another network connected by an ethernet interface

            11. Makes appropriate change (decrement TTL, fragment, recompute header checksums)

            12. Finds target MAC address from routing table/cache/ARP

            13. Wraps IP packet in ethernet frame and transmits

            At step 2, the incoming frame's destination MAC address was the MAC address of the incoming interface; at step 13 the outgoing frame has the router's outgoing interface MAC address for source, and the next hop router's MAC address as destination.



            Of course, the operating system of the router is likely to add various security checks, logging and accounting along the way.






            share|improve this answer


























              up vote
              1
              down vote













              ... as an afterword to the other fine answers ...



              When we look at a packet travelling multiple hops across the internet, with the IP address "staying the same" and the MAC addresses "changing per hop", or think of the routers unwrapping an IP packet from the ethernet frame and then rewrapping it for the next segment, we are taking a birds-eye understanding the purpose of the whole enterprise.



              But in an IP network, none of the machinery involved has this point of view. One of the fundamentals of the IP design is that every single packet has a routing decision made at every single hop, and these decisions are completely independent of it each other.



              Thus, when a packet arrives at a router on some ethernet interface, the actions are:



              • Receive frame

              • Extract packet


              • Decide what to do:

                • Discard packet, or

                • Consume packet, or

                • Forward packet


              This happens for every single packet on every single hop.



              (Digressing for astonishing scale: Internet traffic is supposed to be around 150 petabyte/month, which is 150 x 1015, at an illustrative 1000 bytes/packet and 5 hops/packet, would be about 285 Mevent/sec.)



              The detail is more elaborate.



              (Confining my description to a packet arriving and leaving on ethernet interfaces.)



              1. The interface hardware checks the integrity of the frame (ethernet FCS, for example) and discards it if wrong

              2. The interface hardware checks the destination MAC address, and discards the frame if not for this MAC address

              3. It checks the content type and discards the frame if its a type this router doesn't handle

              4. Assuming it's an IP payload

              5. It unwraps the payload IP packet

              6. It checks the header checksum and discards if error

              7. It checks the destination IP address and if for this router consumes it locally

              8. Assuming for some other host (and TTL > 1)

              9. Checks routing table

              10. Assuming it's for another network connected by an ethernet interface

              11. Makes appropriate change (decrement TTL, fragment, recompute header checksums)

              12. Finds target MAC address from routing table/cache/ARP

              13. Wraps IP packet in ethernet frame and transmits

              At step 2, the incoming frame's destination MAC address was the MAC address of the incoming interface; at step 13 the outgoing frame has the router's outgoing interface MAC address for source, and the next hop router's MAC address as destination.



              Of course, the operating system of the router is likely to add various security checks, logging and accounting along the way.






              share|improve this answer
























                up vote
                1
                down vote










                up vote
                1
                down vote









                ... as an afterword to the other fine answers ...



                When we look at a packet travelling multiple hops across the internet, with the IP address "staying the same" and the MAC addresses "changing per hop", or think of the routers unwrapping an IP packet from the ethernet frame and then rewrapping it for the next segment, we are taking a birds-eye understanding the purpose of the whole enterprise.



                But in an IP network, none of the machinery involved has this point of view. One of the fundamentals of the IP design is that every single packet has a routing decision made at every single hop, and these decisions are completely independent of it each other.



                Thus, when a packet arrives at a router on some ethernet interface, the actions are:



                • Receive frame

                • Extract packet


                • Decide what to do:

                  • Discard packet, or

                  • Consume packet, or

                  • Forward packet


                This happens for every single packet on every single hop.



                (Digressing for astonishing scale: Internet traffic is supposed to be around 150 petabyte/month, which is 150 x 1015, at an illustrative 1000 bytes/packet and 5 hops/packet, would be about 285 Mevent/sec.)



                The detail is more elaborate.



                (Confining my description to a packet arriving and leaving on ethernet interfaces.)



                1. The interface hardware checks the integrity of the frame (ethernet FCS, for example) and discards it if wrong

                2. The interface hardware checks the destination MAC address, and discards the frame if not for this MAC address

                3. It checks the content type and discards the frame if its a type this router doesn't handle

                4. Assuming it's an IP payload

                5. It unwraps the payload IP packet

                6. It checks the header checksum and discards if error

                7. It checks the destination IP address and if for this router consumes it locally

                8. Assuming for some other host (and TTL > 1)

                9. Checks routing table

                10. Assuming it's for another network connected by an ethernet interface

                11. Makes appropriate change (decrement TTL, fragment, recompute header checksums)

                12. Finds target MAC address from routing table/cache/ARP

                13. Wraps IP packet in ethernet frame and transmits

                At step 2, the incoming frame's destination MAC address was the MAC address of the incoming interface; at step 13 the outgoing frame has the router's outgoing interface MAC address for source, and the next hop router's MAC address as destination.



                Of course, the operating system of the router is likely to add various security checks, logging and accounting along the way.






                share|improve this answer














                ... as an afterword to the other fine answers ...



                When we look at a packet travelling multiple hops across the internet, with the IP address "staying the same" and the MAC addresses "changing per hop", or think of the routers unwrapping an IP packet from the ethernet frame and then rewrapping it for the next segment, we are taking a birds-eye understanding the purpose of the whole enterprise.



                But in an IP network, none of the machinery involved has this point of view. One of the fundamentals of the IP design is that every single packet has a routing decision made at every single hop, and these decisions are completely independent of it each other.



                Thus, when a packet arrives at a router on some ethernet interface, the actions are:



                • Receive frame

                • Extract packet


                • Decide what to do:

                  • Discard packet, or

                  • Consume packet, or

                  • Forward packet


                This happens for every single packet on every single hop.



                (Digressing for astonishing scale: Internet traffic is supposed to be around 150 petabyte/month, which is 150 x 1015, at an illustrative 1000 bytes/packet and 5 hops/packet, would be about 285 Mevent/sec.)



                The detail is more elaborate.



                (Confining my description to a packet arriving and leaving on ethernet interfaces.)



                1. The interface hardware checks the integrity of the frame (ethernet FCS, for example) and discards it if wrong

                2. The interface hardware checks the destination MAC address, and discards the frame if not for this MAC address

                3. It checks the content type and discards the frame if its a type this router doesn't handle

                4. Assuming it's an IP payload

                5. It unwraps the payload IP packet

                6. It checks the header checksum and discards if error

                7. It checks the destination IP address and if for this router consumes it locally

                8. Assuming for some other host (and TTL > 1)

                9. Checks routing table

                10. Assuming it's for another network connected by an ethernet interface

                11. Makes appropriate change (decrement TTL, fragment, recompute header checksums)

                12. Finds target MAC address from routing table/cache/ARP

                13. Wraps IP packet in ethernet frame and transmits

                At step 2, the incoming frame's destination MAC address was the MAC address of the incoming interface; at step 13 the outgoing frame has the router's outgoing interface MAC address for source, and the next hop router's MAC address as destination.



                Of course, the operating system of the router is likely to add various security checks, logging and accounting along the way.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 58 mins ago

























                answered 2 hours ago









                jonathanjo

                6,770423




                6,770423




















                    jwoff is a new contributor. Be nice, and check out our Code of Conduct.









                     

                    draft saved


                    draft discarded


















                    jwoff is a new contributor. Be nice, and check out our Code of Conduct.












                    jwoff is a new contributor. Be nice, and check out our Code of Conduct.











                    jwoff is a new contributor. Be nice, and check out our Code of Conduct.













                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fnetworkengineering.stackexchange.com%2fquestions%2f54065%2fneed-help-understanding-how-packets-travel-across-the-internet%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    Long meetings (6-7 hours a day): Being “babysat” by supervisor

                    Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                    Confectionery