What is the difference between Layer 2 and Layer 3 broadcasts?

6

2

  1. As written in the title my first question is, what's the difference between Layer 2 and Layer 3 broadcasts?

  2. If a host sends a layer 2 broadcast, the switch sends it to all of his ports, but not to other switches that are connected (uplinks), that's correct isn't it? But why?

  3. How does it recognise, that there is a switch connected?

JohnnyFromBF

Posted 2011-10-07T05:49:18.220

Reputation: 4 298

Answers

7

  1. Layer 2 broadcasts are sent to the broadcast mac address ffff:ffff:ffff if ethernet and so can be received by any device. Layer 3 broadcasts are sent to the broadcast network address, which for an ip network of 10.1.1.0/24 would be 10.1.1.255. If the IP network was over ethernet, a layer 3 broadcast would also result in a layer 2 broadcast.

  2. A switch sends a layer 2 broadcast to all the ports that are in the same broadcast domain, ie the same vlan (which can be all ports). Some of those ports may have other switches connected, which will receive the broadcast on a port, and issue it out to all other ports on the same broadcast domain as the incoming port. So no, that isn't correct.

  3. It doesn't - see 2.

Note that this answer does not discuss trunking, which adds a bit of complexity to the answer but doesn't really alter the premise.

Paul

Posted 2011-10-07T05:49:18.220

Reputation: 52 173

"A switch sends a layer 2 broadcast to all the ports that are in the same broadcast domain, ie the same vlan (which can be all ports)."

What does same broadcast domain mean on Layer 2? On Layer 3 I know it's the subnet, but on Layer 2? – JohnnyFromBF – 2011-10-07T07:59:35.373

If the switch is not split into vlans, it means every device plugged into it will receive the packet. A vlan is a way of splitting a network into smaller bits, so any port in vlan1 that broadcasts will not be seen by any port in vlan2. But more than this, a switch ensures that a packet issued in vlan1 will not go to vlan2 without the help of a router (a router being a device that will pass packets between different layer 2 networks) – Paul – 2011-10-07T08:03:29.380

thanks, I think I understood it now. And on ethernet Layer 2 and Layer 3 broadcasts are basically the same?! – JohnnyFromBF – 2011-10-07T08:07:24.430

2They are different from the perspective of the recipient. Lets say you had a host on ip 10.1.1.1/24 and another on 10.10.1.1/24, on the same broadcast domain - they are plugged into the same switch on the same vlan even though they are on different subnets. The first host issues a L3 broadcast to 10.1.1.255, which is issued to mac ffff:ffff:ffff. As the mac is a broadcast, host2 will accept the packet at layer 2. It will then go up a layer to L3, and the IP address will not be part of its L3 network (10.1.1.255 does not fall into the 10.10.1.0/24 network) and the packet will be discarded. – Paul – 2011-10-07T11:31:31.337

1

Basically a layer 2 switch operates utilizing Mac addresses in it's caching table to quickly pass information from port to port. A layer 3 switch utilizes IP addresses to do the same. While the previous explanation is the "What", for folks in networking the following "How" is far more interesting.

Essentially, A layer 2 switch is essentially a multiport transparent bridge. A layer 2 switch will learn about MAC addresses connected to each port and passes frames marked for those ports. It also knows that if a frame is sent out a port but is looking for the MAC address of the port it is connected to and drop that frame. Whereas a single CPU Bridge runs in serial, todays hardware based switches run in parallel, translating to extremly fast switching. Layer 3 switching is a hybrid, as one can imagine, of a router and a switch.

There are different types of layer 3 switching, route caching andtopology-based. In route caching the switch required both a Route Processor (RP) and a Switch Engine (SE). The RP must listen to the first packet to determine the destination. At that point the Switch Engine makes a shortcut entry in the caching table for the rest of the packets to follow. Due to advancement in processing power and drastic reductions in the cost of memory, today's higher end layer 3 switches implement a topology-based switching which builds a lookup table and and poputlates it with the entire network's topology. The database is held in hardware and is referenced there to maintain high throughput. It utilizes the longest address match as the layer 3 destination.

Now when and why would one use a l2 vs l3 vs a router? Simply put, a router will generally sit at the gateway between a private and a public network. A router can perform NAT whereas an l3 switch cannot (imagine a switch that had the topology entries for the ENTIRE Internet!!). In a small very flat network (meaning only one private network range for the whole site) a L2 switch to connect all the servers and clients to the internet is probably going to suffice.

Larger networks, or those with the need to contain broadcast traffic or those utilizing VOIP, a multi network approach utilizing VLANs is appropriate, and when one is utilizing VLANs, L3 switches are a natural fit. While a router on a stick scenario can work, it can quickly overtax a router if there is any significant intervlan traffic since the router must make complicated routing decisions for every packet that it recieves.

narender

Posted 2011-10-07T05:49:18.220

Reputation: 11