I'm an application developer working on getting a working knowledge of network engineering, so basically a newbie. I've been trying to figure out exactly when routers decapsulate frames into packets and encapsulate packets into frames. I found Does a router send frames or packets?, and I'm still having difficulty getting clear on just when packets get encapsulated and decapsulated during the process of sending them from a source to a destination.
Ron Maupin answers the question I linked in this way:
A router must strip off the layer-2 frame in order to get to the layer-3 packet. The router then routes the packet to the next interface toward the destination, based on the layer-3 destination address. At the next interface, it must build a new frame for the packet for the layer-2 protocol on the next interface, which could be a completely different layer-2 protocol than the one used on the first interface.
Based on the beginning of this answer, I'm seeing that a router strips off the layer-2 frame, and then routes the packet. That suggests that routers route packets rather than frames. But then the answer says "at the next interface, it must build a new frame for the packet," and I'm having trouble reconciling that statement with the beginning one.
As I understand the process, routers route to other routers until the one associated with the destination network node gets it and send it to that node. As such, I'm seeing the "next interface" in the answer is the next router on the route until the final hop, when the "next interface" is the destination node. If so, then that seems to be saying that routers wrap packets in frames before sending them to the next router on the way to the destination.
So, I'm still not entirely clear after reading Ron's answer whether routers send frames or "naked" packets out on the internet. It seems to me that it would be simpler to decapsulate any frames that are sent out on the internet, leave them as "naked" packets while they are being passed from router to router (presumably routers use IP to figure out where to send the packet, and as such don't need a frame to move it along), and then, when the packet hits the router that is connected to the destination, that router re-encapuslates the packet in the frame type consistent with whatever layer-2 protocol it uses.
Is that what's actually happening, or do routers have to encapsulate packets into frames before forwarding them to other routers, and as such have to know what type of frame each router that it can send to needs? (That doesn't seem very scalable to me.)
Edit: this is the sort of thing that's confusing me, from the Wikipedia article on the Data-Link layer:
The data link layer is concerned with local delivery of frames between nodes on the same level of the network. Data-link frames, as these protocol data units are called, do not cross the boundaries of a local area network. Inter-network routing and global addressing are higher-layer functions, allowing data-link protocols to focus on local delivery, addressing, and media arbitration.
This comes pretty close to asserting, with no room for interpretation, that L2 involvement is limited to LAN boundaries, and is not a part of sending packets out on the internet.