1

I am new to networking, so please excuse me if I am saying stupid stuff.

From my understanding, PCs are sending packets to switches, which then decide which physical port to forward that packet to.

But how does my computer know where to send that packet so it goes to the switch? do switches have IP addresses or MAC addresses?
If they do, does that mean that my Default Gateway is the switch? How can I find the switch's IP/MAC address?

Thanks.

  • For transient traffic (traffic going through a switch) a switch doesn't have an IP address or MAC address. It is conceptually serving simply as a multi-point cable (sort of). For traffic meant to go to a switch, then a switch is acting as host -- which has an IP address and a MAC address and follows all the typical rules a host follows for how packets move through a network. – Eddie Mar 31 at 15:10
1

Hosts send frames out interfaces that are connected to switches. The packets are the payload of the frames. The frames have the MAC addresses of both the source and destination hosts in the frame header, and the switch will switch the frames based on the destination header. The switch learns where hosts are connected to it by looking at the source addresses on the frames and building a MAC address table.

A host will use ARP for IPv4 or NDP for IPv6 to determine the MAC address related to the IP address, and it uses that to address the frames its sends. The switch looks at everyu frame that enters the switch to build its MAC address table.

The default gateway is just another host connected to the switch. The source host will look at the destination IP address to see if it is on the same network. If it is, it will address the frame with the destination host MAC address. If the IP destination is on a different network, the host will address the frame with the gateway MAC address.

The switch is a transparent device, and it does not need a MAC or IP address. Managed switches have MAC and IP addresses in order to connect to the management interface, but that has nothing to do with the switching of frames.

| improve this answer | |
  • Say I have PC A and PC B who are both connected to the same switch. If PC A wants to PC B data, what is the source MAC and destination MAC of that frame? is it source=PC A's MAC and destination=PC B's MAC? – ori6151 Mar 31 at 14:56
  • As I wrote in my answer, "The frames have the MAC addresses of both the source and destination hosts in the frame header." A frame from PCA to PCB will have the source MAC address of the source host (PCA) and the destination MAC address of the destination host (PCB). – Ron Maupin Mar 31 at 14:59
  • Ok, so how does the frame end up at the switch? because it's physically connected? – ori6151 Mar 31 at 15:01
  • The host has a routing table to tell it to which interface it should send the packet. The packet gets its frame at the interface, and the interface sends the frame out the wire. The device on the other end of the link (the switch, in this case) will get the frames. – Ron Maupin Mar 31 at 15:07

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.