From the course: CompTIA Network+ (N10-009) Cert Prep

Hubs vs. switches

- If you're going to be using an ethernet network, you're going to have some box in the middle that we call a hub or a switch. Now, I know in other episodes I talk about the fact that hubs are pretty much obsolesce however they are on the exam, so let's make sure we understand very clearly the difference between a hub versus a switch. Now right in front of me, I've got all kinds of hubs and switches. I've got, this is a just a regular switch. Here's a switch. This is a cable modem with a built in. You see those yellow ports? That's a switch built into it. Here's a little tiny five port switch. So switches are everywhere and we see them all over the place, but we don't see hubs very often. Now what I want you to do is take a look at these two blue boxes. One of these boxes is a hub and the other one is a switch. So if we could look really, really carefully. It's tiny letters. Even standing up close, I can barely read it, but if we look very, very closely, we'll see one actually says hub and the other one says switch. So simply by looking at a box, you can't tell the difference between a hub or a switch. And more important than that, why are switches now predominant and hubs all but obsolete? So in order to make sure we understand the difference of hubs versus switches, let's take a look at this little diagram that I've got. So what I've got right here, this little rectangle, we're going to start off by saying that it is a eight port hub so there's eight connections in here. And then I've got four computers that make up this particular network. So let me go ahead and get these guys plugged in. So for starters, I'm going to run a cable out of here and I'm going to plug this guy into port number one and I'm going to pop this guy into port number three. Remember, it doesn't really matter where you plug these things into a hub or a switch. So we'll get over here, not enough cable to get to seven, and this guy over here, we'll put him in number six. Okay, so what I've done is I have now created a network using a hub. A hub is nothing more than a multiport repeater. So let me show you how this works. So let's just say this computer right here sends out a frame. So he sends the frame out and it comes into the repeater, the hub. Once it gets in here, the hub's job is to make multiple copies of it. It's not an amplifier, it's a repeater. It sees a signal and recreates it, but it doesn't recreate just one. It's going to recreate the exact same frame for everybody who's plugged in. So the frame gets created and then they move over to the individual computers. Now obviously it'd all be moved at once, but I've only got two hands, so I had to do 'em one at a time, and that's all that a hub does. There's some real downsides to a hub. So for example, let's say that this is a 10Base-T hub. The problem with a 10Base-T hub is that it's maximum, what we call bandwidth is 10 megabits per second. Now, so let's just say these two lower computers are having a conversation, and these two upper computers are having a conversation. As that's taking place, the throughput for each conversation is half of the total bandwidth or only five megabits per second, and that's only with two conversations going. Imagine if I had 5, 6, 7, 8 conversations going all simultaneously. So with a hub, you get a big degradation of the overall throughput because you have lots of people talking. With a hub, we use something called carrier sense multiple access/collision detection. Let me explain how this works. So what's going to happen is these two computers want to talk to each other. So this guy starts sending out a frame, and although the frame will go out to everybody, it will come to this guy as well. It'll be repeated and it comes to this guy. That works out great, but what if these two guys start talking at the same time? The problem with a hub is that only one conversation can take place at any given instant. So if these two guys, by coincidence, this computer and this computer start talking at the exact same time, their frames can potentially have a collision. A collision is when two people start talking at once. Now, as human beings, if you and I start talking at once, "Oh, excuse me, pardon, go ahead." Yeah, that kind of thing. With CSMA/CD, you go through a very different process. Basically built into the network cards of every ethernet computer on earth is a set of electronic dice. So what will happen? First, they detect the collision, CSMA/CD, collision detection, and it's easy to detect a collision because just like when you drop two stones into a pond, the waves when they come together get twice as high, sort of the same thing happens with electricity. So it's easy to electrically go, woo, I have a collision. If they do that, all of these guys have built in electronic dice. Now these electronic dice have about 15 million sides to the dice. It's a random number generator is really what's happening, and each one of these devices who detects a collision will roll their dice and everybody gets a different number, and that's how long they wait in milliseconds before they go ahead and resend their data. That's how they get around collisions. In an ethernet network, collisions are a common thing. It happens, 5% of the time, maybe up as high as 10% of the time, and it's designed to deal with that because of CSMA/CD. Now also CSMA stands for carrier sense multiple access, and what we're saying here is everybody can access the same carrier, the same bus in essence. This brings up an interesting term. The term is called collision domain. Basically anybody who's plugged into this one hub can hear the same collision. So if these two guys have a collision, he can hear it too. So anybody that's plugged into this one hub is in what we call a collision domain. Now, let's do this again, but let's make it a switch. So what I'm going to do is get rid of just generic frames. A switch is also a multiport repeater, but it's different. What a switch does that the other ones don't do is that it looks at MAC addresses. Remember, every network card on earth has a MAC address. So I've got three of these, and this is built into the network card. Now, when the switch is first turned on in the morning or whenever it's first turned on, it acts like a hub at first, but what it'll do is it will quickly figure out by looking at the frames going back and forth, that it'll sit there and go, this MAC address is plugged into me at port one, and it will memorize that and it's built into the switch in a little table that it builds itself and it stays in there. Let's make sure we get that right. So in essence, what we do is we build a MAC table, which says, this MAC address is plugged into my port one, this MAC address is plugged in my port three, this one is plugged into my port seven. If you unplug something to plug it back in, it'll take it a few milliseconds, but it'll update itself very, very quickly. Now, by knowing this, we have a huge advantage over a regular old hub. First of all, let's go ahead and watch this in action. So what I'm going to do is, this is a frame again, so it's from 80. I'm just looking at the last two numbers for ease. So we know that 80's plugged into here, That's how I knew to put it here, and he wants to send it to 1b, which is 1b here. He wants to send it to here. So what will happen now is that when this switch receives this guy right here, the beautiful part is that it doesn't make a copy for everybody because it knows who it's supposed to go to, it just sends it to him. This is a big advantage over a hub because with a switch, what you're making is in essence a point-to-point connection. With a switch, if I've got these two guys talking and I've got these two guys talking, they will still each run at 10 megabits because remember the old time telephone operators where you see some gal and she'd be like, "What's the number to which you were trying to connect?" And they plug those plugs into the wall kind of a thing. It's kind of like that. They literally plug a hardware connection between these two devices. Now, the moment this guy sends another packet to a different MAC address, he'll unplug and plug it to somebody else. Now, there's one thing that is kind of interesting here, and I want to show you. In this case, I have what's known as a broadcast. There's a lot of traffic that takes place in a network where you want to send a piece of information to everybody. Let's say you want to announce what your network name is to everybody, or you're trying to find a specific computer, we call these broadcasts. Now, in a broadcast, it is a very specific MAC address. It's all Fs. So you can never have a network card with all Fs. It's reserved for broadcast. So if this device wants to broadcast, it'll come in and because it's a broadcast, he'll act just like a switch. I'm sorry. He'll act just like a hub. He will make multiple copies just like we saw a moment ago, and send them on to every single computer that he's connected to. The beauty of this is that we're now in a situation where collisions don't happen very often, once in a great while, but because we have hardwired connections, the idea of a collision domain doesn't really happen very much. What we have instead is a group of computers that are hooked to this switch that hear each other's broadcasts. So the idea of a broadcast domain is you're hooked to a switch and any computer that can hear anybody else's broadcast is a member of the same broadcast domain. So typically when we're talking about collision domain, we mean hubs. And when we say broadcast domain, we mean switches more often than not. Let me get these out of here. The power of a switch is so intense that there's really no good reason to use hubs anymore. There are a couple of places where hubs can be convenient. For example, if I wanted to listen in on the conversations going on, in a hub, it's easy. I can just plug into another port and I can listen in to everything that's going on. With a switch, that's pretty much impossible because there's hardwired connections. If I plugged into port five, I wouldn't be able to hear it. So I'll use a hub sometimes if I want to be a little bit sneaky and listen in. I can also get switches which have what we call maintenance ports. And a maintenance port is basically saying, I don't care what's happening. You give me a copy of all traffic that's taking place. So even switches can take over some of the functions of hubs today. The bottom line is that if you were to run into a situation where you have a hub, probably the best single thing you can do to improve a network is to just unplug the hub and throw in a switch and you will instantly, dramatically improve your network throughput. Make sure you're comfortable with the concept of hubs and switches.

Contents