• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Question about networks (layer 2)

Matts0344

Member
This is more of a basic network question. Just curious.

If I have, say, a switch and then one PC connected to one port (A) and another on another port (B). They each have static IP addresses, say 192.168.0.1 and .2

From the .1 PC I ping the .2 machine, then the switch knows the MAC of the .1 is on port A but how does the .1 PC know what MAC address to put for the "Destination Address" field in the ethernet packet?
 
Address Resolution Protocol. ARP.

It's a layer2 broadcast asking for "who has this IP address? Respond to my source mac address"
 
A switch is essentially a fast, multi-port bridge, and it operates as a bridge does (@ Layer 2).

The bridge gets it's addresses (MACs) by passively listening and noting the *source* address of the frame on the "wire". If it hasn't seen that source before, it adds it to the forwarding table (for whatever the defined amount of time). It goes in the table as 'this MAC came in from this Port'.

When one device send a frame to another, the switch/bridge looks at the destination MAC ... if it's in the table, it sends the frame out that port. It also looks at the source address ... if that source is not in the table, it's added.

If the destination MAC is not in the table (unknown), the switch/bridge "Floods" the frame out all ports except the one it came in on.

Do not confuse "Flooding" with "Broadcasting" ... they are different.

With a broadcast, the destination MAC is all ones (usually, by convention) which matches all addresses in the broadcast domain.

Flooding sends the frame out all ports with the source and destination address intact (not all ones destination). The general idea is that if the destination evice is out there, it'll get the frame and respond accordingly.

Hope this helps

Scott

Edit: Nuts. I somehow managed to miss the whole last paragraph of the OP ... I gotta get some better drugs ...
 
So do each of the PCs keep a table of IPs to MAC address entries?

I understand how a switch knows how to forward to which port, just confused on how the PCs know which MAC address to put in for the DA MAC.
 
Originally posted by: Matts0344
So do each of the PCs keep a table of IPs to MAC address entries?

I understand how a switch knows how to forward to which port, just confused on how the PCs know which MAC address to put in for the DA MAC.
Yup, each host keeps an arp table/cache of the other hosts they can connect to over layer 2. If you're running a windows machine bring up a command prompt and type "arp -a" to see what your machine has in it's cache right now.

Erik
 
Back
Top