0

I am learning networks from hardware and software aspects.

assume below scenario: we call computers with c prefix, switches with s and routers with r. all macs and IPs are summerized.

c1 ip=1 mac=xx

c2 ip=2 mac=yy

connected to switch s1

c3 ip=3 mac=zz

c4 ip=4 mac=ww

connected to switch s2

each switch is one network. both switches s1 and s2 are connected to r1 which is our router.

my questions are:

when c1 sends a message to c2, will it go directly to c2 without traversing through router?

how switch s1 knows mac addr of c3 which is in another network?

what happen to src/dst mac addr of frames which going to one port of router, doesn't router check src mac addr of frames? does it accept any src mac addr?

does router know all nodes in any network recursively in sub networks or it only knows what actually connected to its ports, like only switches?

or if we sum all questions into one:

how packets and frames go through switches and routers to rich their destination without being modified?

thanks

1

1 Answer 1

1

when c1 sends a message to c2, will it go directly to c2 without traversing through router?

When c1 and c2 share a common subnet then no router is involved.

how switch s1 knows mac addr of c3 which is in another network?

It doesn't.

When s1 and s2 are connected together all ports are on the same network (=L2 segment) and both switches learn all MAC addresses.

When there's a router in between (your scenario) the switch ports are on different networks and each switch only learns MAC addresses on its side of the router.

what happen to src/dst mac addr of frames which going to one port of router, doesn't router check src mac addr of frames? does it accept any src mac addr?

When the router is required as gateway, encapsulating frames are first addressed to the gateway. The gateway removes the source frame, extracts the packet, decides the next hop, creates a new frame for the packet and transmits it.

does router know all nodes in any network recursively in sub networks or it only knows what actually connected to its ports, like only switches?

A router uses ARP for IPv4 or NDP for IPv6 to learn the MAC addresses of the nodes it requires. It doesn't know any MAC addresses it doesn't use for forwarding.

how packets and frames go through switches and routers to rich their destination without being modified?

Short answer:

  1. frames do not cross routers, packets cross routers
  2. frames are not modified by switches
  3. packets are not modified by routers, except for the TTL field
7
  • thanks, so does router accept multiple src mac address from one port? Commented Jan 25 at 10:13
  • A router doesn't care about the source MAC address of a frame it receives. It cares about the destination IP address (and of course the destination MAC address).
    – Zac67
    Commented Jan 25 at 11:21
  • 1
    ok, in s2 we have two computers with two different mac addresses. does router map two mac to a port to find many destination in a single port? Commented Jan 25 at 11:49
  • 1
    When a router forwards a packet, it uses its routing table to determine the next hop (gateway or final destination) and the interface. It uses ARP or NDP to resolve that hop's MAC address (for a MAC-based network) and uses that MAC as destination for L2 encapsulation.
    – Zac67
    Commented Jan 25 at 13:05
  • 1
    A router does not first map the destination IP to a MAC address and then figure out where that MAC might be located. It's a switch that forwards by MAC address and MAC address alone.
    – Zac67
    Commented Jan 25 at 13:21

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.