I'm taking a computer networking course and i struggle to get to flow of things when it comes to learning switches and routers.

Lets say we have a AS with LANs that connected with switches, and there also router in each LAN .

Now, when a station in LAN A want so send packet to the far most station in entirely different LAN B, and A connected only to one switch, the switch "learn" A, and update its forwarding table and broadcast the packet. But when the data will come eventually to a router, is it true to say that the router already used OSPF to know how to forward the packet? I'll be happy i somone can clarify this to me with maybe more informative example , thanks in advance

  • 1
    While it may not answer your specific questions about OSPF, I just finished writing an article series that covers exactly what needs to happen to move a packet through the Internet.
    – Eddie
    Feb 19, 2016 at 1:17
  • 1
    Fantastic. little bit late, but it really helped me. Apr 6, 2016 at 9:58

3 Answers 3


When a host wants to send something to a host in a different LAN, the sending host can tell it is sending to a different LAN because its own network and mask are configured in it. Based on that knowledge, it knows it needs to send the traffic to its configured gateway (router). It may have the MAC address of the gateway in its ARP cache, or it may not. If it doesn't, it needs to use ARP to resolve the gateway's IP address to its MAC address.

Once it has the gateway's MAC address, it can encapsulate the IP packet in the ethernet frame, and send the frame to the gateway. The router will get the frame and strip the frame off the packet. It will inspect the packet and look to see if it has a route to the destination IP address in its routing table. The routing table could be populated in multiple ways, including routing protocols like OSPF.

If the router cannot find a route to the destination, it drops the packet. If it does find a route, it will switch the packet to the outbound interface where it will apply a new layer-2 frame for the outbound interface. This may involve ARP, again.

When the second router gets the frame from the first router, it will repeat the process that the first router did. It will send the frame it created out the LAN interface toward the receiving host.

Switches will learn the MAC address of devices connected to the switch ports as those devices send traffic through the port. The switch updates its MAC address table. Switches don't have forwarding tables the way routers do, but they will send a frame to a port where the destination MAC address is known, and they will flood frames with unknown destination MAC addresses to all ports.

Routers get route information to populate their forwarding tables from multiple sources. The most common source is from the directly connected networks. Routes can be statically configured, or they can be learned via a routing protocol (RIP, OSPF, IS-IS, BGP, etc.). Traffic without a route in the forwarding table will be dropped.

If your router already knows the route to the destination (directly connected, statically configured, or dynamically learned from a routing protocol) it will forward it out the proper interface toward the destination. If it has not already learned the route to the destination, the traffic will be dropped.

If you have new questions beyond clarification, you need to ask a new question, but this question is really too broad to get into more detail than what I have outlined above.


When you connect two OSPF routers that have adjacency, the switch that comes in between to connect those routers can be considered as a dumb switch/bridge.

If you use one port to connect to Router A and second port to Router C. Mac addresses get learned by the switch to enable switching between the routers.

What you do with the rest of ports in the switch is a different open-ended discussion.

Switch doesn't care about ip address or OSPF. (again I doubt you are going through layer 3 switch in the intro course). All it does is using the mac addresses of the interfaces Router A and B are using. Then it's up to the routers to form adjacency.


To recap:

Layer 2 Switch uses MAC addresses to send stuff.

Layer 3 Switch (with routing capability) or a router use IP Addresses to direct packets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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