广播域和冲突域

What is a broadcast domain?

In Ethernet LANs, a broadcast is one-to-all communication, which means that if a node sends a broadcast frame, everybody receives a copy of it. At the Ethernet layer, broadcast frames have a destination MAC address of FF-FF-FF-FF-FF-FF. When a switch receives a frame with this MAC, it sends a copy of the frame out all its interfaces, except the one it received the broadcast on. An example of this behavior is shown in Figure 1.

Figure 1. Example of one broadcast domain

A broadcast domain is a segment of the network where all devices receive a copy of every broadcast frame sent. To better understand the concept let's look at the example in Figure 1. PC1 sends a broadcast frame with a destination MAC address ff-ff-ff-ff-ff-ff. When the switch receives the frame, it looks in the Ethernet header of the frame and understands, based on the destination MAC, that this is a broadcast frame. The switch then floods the frame out all its ports, except the one it received the frame on (the port towards PC1). In the end, the broadcast frame reached all devices in the LAN -(PC1 originated the frame, and PC2,3 and 4 get a copy of it through the switch) Therefore PC1,2,3 and 4 are in one broadcast domain.

Multiswitch broadcast domain

The same network logic applies when the LAN is made of more than one switch. When a node sends a broadcast frame, it is "flooded" to everybody in the broadcast domain.


Figure 2. Example of a multi-switch broadcast domain

Let's look at the example in Figure 2. PC2 sends a broadcast frame with destination MAC address FF-FF-FF-FF-FF-FF. When Switch1 gets the frame, it looks at the Ethernet header and sees based on the MAC address that this is a broadcast, so it floods it out all its port, except the port, it was received on. So the frame goes out the link towards Switch2. When Switch2 receives the frame, it does the same thing as switch1. It understands based on the MAC addresses that this is a broadcast frame and floods it out all its ports. Eventually, the frame goes to every connected device in the LAN. Therefore all devices are in one broadcast domain.

This logic applies to LANs with many switches. If we connect another switch to the topology in Figure 2, the broadcast domain will be extended across the new switch, and so on.

Broadcast Domains and Routers

At this point, you may be wondering when this flood of broadcast ends and whether a whole network environment a one broadcast domain. If we want to break down a broadcast domain into smaller domains, we use a router. Routers don't flood broadcast frames but instead decapsulate the ethernet frames and act upon the layer 3 information within the IP packets.

Figure 3. Example of one broadcast domain and a router

Let's look at the example in Figure 3. PC2 sends a broadcast frame. The switch floods the frame out all its ports, so PC1,3 and router 1 get a copy of it. But note that the router doesn't flood the frame to PC4 and PC5, because routers don't forward broadcast frames and the domain ends there. Every interface of the router creates a separate broadcast domain as shown in Figure 3.

There is another way to split a broadcast domain into multiple ones. It can be done with a technology called Virtual LANs (VLANs).

Summary

So in summary, the most important points about broadcast domains are:

  • A broadcast domain is a segment of the network where all devices receive a copy of every broadcast frame sent.
  • Switches flood broadcast traffic out all interfaces, except the one they received the broadcast on.
  • Routers stop broadcast flood and break broadcast domains.
  • A broadcast domain can be split into smaller one with VLANs

Collision Domains

To understand what a collision domain is, we have to look a little bit in the past when Ethernet LANs were built using devices like Hubs and Bridges.

Ethernet LAN with Hubs

Ethernet Hub is a network device that is used for connecting multiple nodes and making them act as connected to a single network segment. It works purely at the physical layer of the OSI model. It has multiple ports, in which the incoming electrical signals on one port are repeated at the output of every other port. There is no forwarding logic at all.

A Hub makes all connected devices to be part of one single network segment because every electrical signal on every cable is replicated to all other cables. This creates a single shared medium and a network collision occurs when more than one device attempts to send a frame on the segment at the same time.

Figure 1. Example of one collision domain

Figure 1 shows an example of two PCs trying to send an Ethernet frame simultaneously. Because they are connected to a shared network segment, they are part of one collision domain. It is also visible in Figure 2 that only one the PCs in the collision domain may transmit at any one time otherwise collision occurs.
Figure 2. Two devices trying to transmit data simultaneously via Ethernet Hub

Carrier-sense multiple access with Collision Detection (CSMA/CD)

So at that point, you may be wondering if collisions happen all the time, how are devices connected to an Ethernet Hub even able to communicate? There is a media access control method called CSMA/CD that devices use when trying to communicate over a shared medium. CSMA/CD stands for Carrier Sense Multiple Access with Collision Detection. The key here is the Collision Detection. When a device wants to transmit a frame, it checks to see if the segment is free. If the segment is not free, the device waits a random amount of time before re-transmitting. If the network segment is free and two devices send frames at the same time, their signals collide. When the collision is detected, they both stop and wait a random amount of time before re-transmitting.

To understand what is behind Carrier Sense Multiple Access with Collision Avoidance let's look at each component individually:

  • Carrier sense (CA): The idea that nodes may only send data over the network if the shared medium is free.

  • Multiple access (MA): Several nodes share a network segment so they need an access method to resolve collisions.

  • Collision detection (CD): If a collision does occur, it will be detected and the transmission will be tried again after a random amount of time.

The concept of collision domains applies also in wireless networks because the radio signals traverse a shared medium which is the wi-fi radio spectrum. So all things we have said by now apply to Wireless networks as well - only one node in a wireless LAN may transmit at any one time otherwise collision occurs as shown in Figure 3.

Figure 3. Two devices trying to transmit data simultaneously via radio

Several techniques were introduced over the year to resolve this scaling problem. For now, we are going to focus only on the Wired LANs.

Ethernet Bridges

Ethernet Bridges are the predecessor of modern LAN switches. They were introduced to resolve the scaling problem with shared segments and collisions. Bridges are layer 2 devices, which means they can read the Ethernet Header of the frames they forward and take decisions based on the information in the headers. This eliminated the need to send all frames out all ports, which practically means to repeat all electrical signals out to all ports. Therefore, Ethernet bridges split a network segment into two collision domains as shown in Figure 4.


Figure 4. Ethernet LAN with Hubs and a Bridge

At the time, that was a huge scaling improvement and enabled the creation of larger LAN segments. As local area networks grew bigger, demand for more scale was needed so devices with better performance and more interfaces were introduced - LAN switches.

Ethernet Switches

LAN switches completely resolve the problem with collisions. They operate at layer 2 of the OSI model, meaning that they look at the ethernet header and trailer. Their main advantage is that all their ports can operate in full-duplex(全双工), meaning they can simultaneously transmit and receive frames on any given port at any given time. Because of this, the media access algorithm for collision detection (CSMA/CD) is no longer required and is disabled by default. Another big advantage of switches is that they forward frames based on MAC addresses so any given frame doesn't need to be sent to all ports as hubs do.

Figure 5. Ethernet LAN with a Switch

That why these days all wired local area networks are built with LAN switches.

Summary

So in summary, the most important points about collision domains are:

  • All devices connected to a Hub are into a single collision domain.
  • When devices are into a single collision domain, they must use half-duplex communication. They either transmit or receive frames at any given time but not both.
  • Only one device may transmit into the collision domain at any one time otherwise collision occurs. The other devices detect the transition with the CSMA/CD method, wait a random amount of time, and re-transmit again.
  • Each switch interface is a separate collision domain.
  • Each switch interface can transmit and receive frames at the same time - full-duplex.
  • CSMA/CD is disabled by default on switches because collisions cannot occur.

你可能感兴趣的:(广播域和冲突域)