1
00:00:00,060 --> 00:00:00,960
In this lesson,

2
00:00:00,960 --> 00:00:03,480
we're going to discuss ethernet fundamentals.

3
00:00:03,480 --> 00:00:05,340
Now, in the early computer networks, there were

4
00:00:05,340 --> 00:00:07,800
so many different networking technologies out there,

5
00:00:07,800 --> 00:00:10,680
and each one was competing for a piece of the market share.

6
00:00:10,680 --> 00:00:12,150
Now, there wasn't much standardization

7
00:00:12,150 --> 00:00:13,350
among these different types either,

8
00:00:13,350 --> 00:00:15,300
and this led to a lot of problems.

9
00:00:15,300 --> 00:00:16,230
I distinctly remember

10
00:00:16,230 --> 00:00:18,480
back when I first started working on computer networks,

11
00:00:18,480 --> 00:00:21,370
we had things like ethernet token ring, LocalTalk,

12
00:00:21,370 --> 00:00:24,690
AppleTalk, NetBIOS, IPX and SPX,

13
00:00:24,690 --> 00:00:27,000
frame relay, asynchronous transfer mode,

14
00:00:27,000 --> 00:00:30,420
fiber distributed data interfaces, point-to-point protocols,

15
00:00:30,420 --> 00:00:32,040
high-level data link control,

16
00:00:32,040 --> 00:00:34,920
integrated service digital networks, and many, many others

17
00:00:34,920 --> 00:00:37,260
that were all fighting to be the dominant market leader

18
00:00:37,260 --> 00:00:38,640
in Layer 2.

19
00:00:38,640 --> 00:00:40,380
Well, there was really one clear winner

20
00:00:40,380 --> 00:00:41,880
in these Layer 2 wars,

21
00:00:41,880 --> 00:00:44,010
and it was the one that we use most often today,

22
00:00:44,010 --> 00:00:45,810
which is known as ethernet.

23
00:00:45,810 --> 00:00:47,640
Now, ethernet really is the number one protocol

24
00:00:47,640 --> 00:00:49,620
that we're going to use for Layer 2 communications

25
00:00:49,620 --> 00:00:51,780
in most of our local area networks.

26
00:00:51,780 --> 00:00:53,340
So, let's spend a little time together

27
00:00:53,340 --> 00:00:55,260
focusing specifically on ethernet,

28
00:00:55,260 --> 00:00:57,210
because it really is that important.

29
00:00:57,210 --> 00:00:59,130
Truthfully, I can tell you with confidence

30
00:00:59,130 --> 00:01:00,840
that if you don't understand ethernet,

31
00:01:00,840 --> 00:01:01,950
you really don't understand

32
00:01:01,950 --> 00:01:04,860
the way modern local area networks operate today.

33
00:01:04,860 --> 00:01:07,800
Now, ethernet has been with us a very long time.

34
00:01:07,800 --> 00:01:10,080
Originally, it was run over coaxial cables

35
00:01:10,080 --> 00:01:12,630
using BNC connectors and vampire taps,

36
00:01:12,630 --> 00:01:16,380
and these were called 10Base2 and 10Base5 ethernet networks,

37
00:01:16,380 --> 00:01:18,540
also named thin net and thick net

38
00:01:18,540 --> 00:01:21,570
because of the relative size of those coaxial cables.

39
00:01:21,570 --> 00:01:22,980
Now, the great thing about these networks

40
00:01:22,980 --> 00:01:24,750
is they could cover a pretty long distance

41
00:01:24,750 --> 00:01:27,510
of up to 200 meters or up to 500 meters,

42
00:01:27,510 --> 00:01:31,050
depending on if it was a 10Base2 or 10Base5 network.

43
00:01:31,050 --> 00:01:33,060
Now for the network plus exam these days,

44
00:01:33,060 --> 00:01:33,923
you do not need to memorize

45
00:01:33,923 --> 00:01:37,170
anything about 10Base2 or 10Base5 networks,

46
00:01:37,170 --> 00:01:39,060
because they are so old and antiquated

47
00:01:39,060 --> 00:01:40,740
that you're likely never going to run into them

48
00:01:40,740 --> 00:01:42,090
out in the real world.

49
00:01:42,090 --> 00:01:44,430
The only reason I'm even talking about them right now

50
00:01:44,430 --> 00:01:46,290
is because that when they were first used,

51
00:01:46,290 --> 00:01:47,490
ethernet was being introduced

52
00:01:47,490 --> 00:01:50,070
into the computer networks back in the 1980s,

53
00:01:50,070 --> 00:01:52,830
and this was the type of networks we ran these things on.

54
00:01:52,830 --> 00:01:54,240
Now, over time, we migrated

55
00:01:54,240 --> 00:01:56,850
to something known as 10Base-T ethernet.

56
00:01:56,850 --> 00:01:58,590
This allowed up to 10 megabits per second

57
00:01:58,590 --> 00:02:00,000
of data transferring your network

58
00:02:00,000 --> 00:02:01,950
and it can be run over a twisted pair of cable

59
00:02:01,950 --> 00:02:05,340
known as a category 3 or CAT 3 cable.

60
00:02:05,340 --> 00:02:06,780
These twisted pair of cables

61
00:02:06,780 --> 00:02:08,490
could be unshielded or shielded,

62
00:02:08,490 --> 00:02:09,960
and they were cheaper and easier to use

63
00:02:09,960 --> 00:02:14,340
than that older 10Base2 and 10Base5 coaxial cable networks.

64
00:02:14,340 --> 00:02:15,360
The only real disadvantage

65
00:02:15,360 --> 00:02:17,430
to using these new 10Base-T networks

66
00:02:17,430 --> 00:02:18,870
was that they could only cover a distance

67
00:02:18,870 --> 00:02:20,250
of up to a hundred meters

68
00:02:20,250 --> 00:02:21,900
before they needed to have their signal repeated

69
00:02:21,900 --> 00:02:23,730
by a hub or a switch.

70
00:02:23,730 --> 00:02:26,040
Now, I know that 10 megabits per second these days

71
00:02:26,040 --> 00:02:29,010
does not sound like a lot, but back in the 1980s,

72
00:02:29,010 --> 00:02:31,080
this was super, super fast.

73
00:02:31,080 --> 00:02:33,690
After all, a dial up modem back in those days

74
00:02:33,690 --> 00:02:36,540
was lucky to reach speeds of 300 bits per second.

75
00:02:36,540 --> 00:02:39,390
So, this internal network speed of 10 megabits per second

76
00:02:39,390 --> 00:02:41,520
is actually 10,000 bits per second,

77
00:02:41,520 --> 00:02:43,950
and this was lightning fast to those users.

78
00:02:43,950 --> 00:02:45,180
Now, the big question we had

79
00:02:45,180 --> 00:02:46,890
when it came to these network devices,

80
00:02:46,890 --> 00:02:49,380
especially when they start operating at these faster speeds,

81
00:02:49,380 --> 00:02:51,450
is how are they going to be able to connect to the network

82
00:02:51,450 --> 00:02:53,310
and then communicate on them.

83
00:02:53,310 --> 00:02:54,990
Now, this is really one of the core questions

84
00:02:54,990 --> 00:02:56,730
that ethernet had to answer.

85
00:02:56,730 --> 00:02:59,100
Should their network access be deterministic

86
00:02:59,100 --> 00:03:01,410
or should it be contention-based?

87
00:03:01,410 --> 00:03:02,940
Now, a deterministic network

88
00:03:02,940 --> 00:03:04,080
means that the network access

89
00:03:04,080 --> 00:03:06,150
should be very organized and orderly.

90
00:03:06,150 --> 00:03:08,850
Some of the competing technologies, like token rig networks,

91
00:03:08,850 --> 00:03:11,670
use a deterministic style of network access.

92
00:03:11,670 --> 00:03:13,980
If a device wants to transmit data on the network,

93
00:03:13,980 --> 00:03:15,690
that device had to wait its turn

94
00:03:15,690 --> 00:03:17,970
until some sort of electronic token was given to it

95
00:03:17,970 --> 00:03:20,550
to signify it was that device's turn to transmit data

96
00:03:20,550 --> 00:03:21,840
over the network.

97
00:03:21,840 --> 00:03:23,730
To explain how this works, let's pretend

98
00:03:23,730 --> 00:03:25,650
that we're all sitting in a classroom together.

99
00:03:25,650 --> 00:03:27,480
In this room is you and me

100
00:03:27,480 --> 00:03:29,100
and maybe 20 or 30 other students

101
00:03:29,100 --> 00:03:30,780
all sitting in this classroom.

102
00:03:30,780 --> 00:03:32,940
Now, if everybody started talking at the same time,

103
00:03:32,940 --> 00:03:34,980
nobody could be heard or understood.

104
00:03:34,980 --> 00:03:36,900
Instead, we'd have a bunch of collisions

105
00:03:36,900 --> 00:03:38,820
as everyone tries to talk over each other

106
00:03:38,820 --> 00:03:40,950
and it just sounds like a jumbled mess.

107
00:03:40,950 --> 00:03:42,720
So instead, we need to create

108
00:03:42,720 --> 00:03:44,520
some sort of deterministic system

109
00:03:44,520 --> 00:03:47,280
to determine who's going to speak at any given time.

110
00:03:47,280 --> 00:03:49,320
So whenever I'm teaching in a classroom,

111
00:03:49,320 --> 00:03:50,527
I always say to my students,

112
00:03:50,527 --> 00:03:51,930
"You have to raise your hand

113
00:03:51,930 --> 00:03:53,370
and then when I call on you,

114
00:03:53,370 --> 00:03:55,050
you're then going to be able to talk."

115
00:03:55,050 --> 00:03:58,080
That is a deterministic method of accessing the network

116
00:03:58,080 --> 00:04:01,260
or in our case, the shared environment in the classroom.

117
00:04:01,260 --> 00:04:02,970
Now, since I was the instructor,

118
00:04:02,970 --> 00:04:05,910
I was the one who determined who got to talk and when.

119
00:04:05,910 --> 00:04:07,200
When I called on a student,

120
00:04:07,200 --> 00:04:09,720
they were given this virtual token, this permission,

121
00:04:09,720 --> 00:04:11,850
so they can then speak until that virtual token

122
00:04:11,850 --> 00:04:13,380
was given back by the student

123
00:04:13,380 --> 00:04:16,019
or by me taking back the virtual token

124
00:04:16,019 --> 00:04:18,390
and speaking up myself, because I'm the instructor

125
00:04:18,390 --> 00:04:19,860
and I can speak whenever I want

126
00:04:19,860 --> 00:04:23,400
and I get to determine who gets to talk and for how long.

127
00:04:23,400 --> 00:04:25,260
Now, if you use a token-ring network,

128
00:04:25,260 --> 00:04:27,330
that is essentially how they operated.

129
00:04:27,330 --> 00:04:28,380
Now, the great thing about this

130
00:04:28,380 --> 00:04:31,290
is there are no collisions or in my classroom example,

131
00:04:31,290 --> 00:04:32,760
there's no chance that other students

132
00:04:32,760 --> 00:04:34,260
are going to talk over each other,

133
00:04:34,260 --> 00:04:36,750
because everyone knows they have to wait their turn

134
00:04:36,750 --> 00:04:38,310
until the instructor calls on them

135
00:04:38,310 --> 00:04:40,740
and then they can transmit their message.

136
00:04:40,740 --> 00:04:42,810
Now, alternatively, a network can also use

137
00:04:42,810 --> 00:04:44,760
what's known as a contention-based system

138
00:04:44,760 --> 00:04:46,590
to determine who gets to access and communicate

139
00:04:46,590 --> 00:04:48,510
on the network at a given time.

140
00:04:48,510 --> 00:04:50,070
Now, a contention-based network

141
00:04:50,070 --> 00:04:52,200
tends to be very chaotic in nature.

142
00:04:52,200 --> 00:04:53,580
Unlike my classroom example,

143
00:04:53,580 --> 00:04:55,050
which was very deterministic

144
00:04:55,050 --> 00:04:57,720
and the instructor got to tell everybody who could talk

145
00:04:57,720 --> 00:05:00,330
and for how long, contention-based model

146
00:05:00,330 --> 00:05:02,340
is more like when you go to a local bar or a pub

147
00:05:02,340 --> 00:05:04,110
with your friends on a Friday night.

148
00:05:04,110 --> 00:05:05,910
Maybe you're hanging out with five of your friends

149
00:05:05,910 --> 00:05:07,410
and you're all having some drinks.

150
00:05:07,410 --> 00:05:09,330
Now, normally people know how to interact

151
00:05:09,330 --> 00:05:12,000
in these situations and carry on a conversation, right?

152
00:05:12,000 --> 00:05:13,207
There isn't somebody in your group saying,

153
00:05:13,207 --> 00:05:15,330
"Hold on, Alex, it's Jasmine's turn to speak,"

154
00:05:15,330 --> 00:05:18,030
or, "Okay, Barbara, you've had your 90 seconds.

155
00:05:18,030 --> 00:05:19,980
Now, it's Jamario's turn to talk."

156
00:05:19,980 --> 00:05:21,660
I don't know about you, but if I had a friend

157
00:05:21,660 --> 00:05:23,730
that tried to moderate our conversations like that,

158
00:05:23,730 --> 00:05:26,010
I probably wouldn't enjoy hanging out with them very much,

159
00:05:26,010 --> 00:05:27,930
and I probably wouldn't be going to next week's meetup

160
00:05:27,930 --> 00:05:29,190
at the pub either.

161
00:05:29,190 --> 00:05:31,230
Instead, when you're hanging out with your friends,

162
00:05:31,230 --> 00:05:33,390
you just naturally take turns talking.

163
00:05:33,390 --> 00:05:34,950
Each of us talks more or less

164
00:05:34,950 --> 00:05:37,350
because it takes more or less time to tell our stories,

165
00:05:37,350 --> 00:05:40,500
and so the flow of conversation naturally just happens.

166
00:05:40,500 --> 00:05:41,940
Now, this is the real world example

167
00:05:41,940 --> 00:05:44,220
of how contention-based discussions work.

168
00:05:44,220 --> 00:05:46,170
Essentially, you're going to be sitting there

169
00:05:46,170 --> 00:05:48,390
and whenever you hear a gap in the conversation,

170
00:05:48,390 --> 00:05:50,460
you know it's going to be okay for you to speak

171
00:05:50,460 --> 00:05:52,290
or to transmit your message.

172
00:05:52,290 --> 00:05:53,670
If somebody else is speaking,

173
00:05:53,670 --> 00:05:55,320
You're just going to stop and listen

174
00:05:55,320 --> 00:05:57,840
until you find an appropriate time for you to transmit

175
00:05:57,840 --> 00:05:59,700
or say whatever it is you wanted to add

176
00:05:59,700 --> 00:06:01,680
to that particular conversation.

177
00:06:01,680 --> 00:06:02,730
Now, the problem with using

178
00:06:02,730 --> 00:06:04,470
a contention-based method like this

179
00:06:04,470 --> 00:06:06,240
is that you can start having collisions

180
00:06:06,240 --> 00:06:08,430
where people start talking over each other.

181
00:06:08,430 --> 00:06:09,263
I know in the past

182
00:06:09,263 --> 00:06:10,410
when I've been hanging out with my friends,

183
00:06:10,410 --> 00:06:12,090
I may hear a gap in the conversation

184
00:06:12,090 --> 00:06:14,430
and begin to start speaking, and at the same time,

185
00:06:14,430 --> 00:06:17,040
one of my other friends starts talking as well.

186
00:06:17,040 --> 00:06:18,450
This creates a collision,

187
00:06:18,450 --> 00:06:20,520
because both of us speak at the same time

188
00:06:20,520 --> 00:06:22,200
and nobody could be listening or understanding

189
00:06:22,200 --> 00:06:23,820
what either of us was saying.

190
00:06:23,820 --> 00:06:26,460
So what I usually do is I will pause,

191
00:06:26,460 --> 00:06:28,110
let my friend continue their story,

192
00:06:28,110 --> 00:06:30,180
and then I'll wait for the next gap in the conversation

193
00:06:30,180 --> 00:06:31,860
to try talking again.

194
00:06:31,860 --> 00:06:34,320
Now, because of this natural way of having a conversation

195
00:06:34,320 --> 00:06:36,510
can lead to some people talking over each other,

196
00:06:36,510 --> 00:06:38,670
some of your friends taking up more time than others,

197
00:06:38,670 --> 00:06:40,050
and other issues like this,

198
00:06:40,050 --> 00:06:43,260
contention-based models can become pretty chaotic.

199
00:06:43,260 --> 00:06:46,320
Oddly enough though, this is exactly how an ethernet network

200
00:06:46,320 --> 00:06:48,060
is going to work, because ethernet

201
00:06:48,060 --> 00:06:50,790
is a contention-based networking protocol.

202
00:06:50,790 --> 00:06:53,070
Now, you may be wondering why would they choose

203
00:06:53,070 --> 00:06:55,890
a contention-based network over a deterministic one?

204
00:06:55,890 --> 00:06:58,080
Why we have all that chaos added?

205
00:06:58,080 --> 00:07:00,960
Well, the reason is because contention-based networks

206
00:07:00,960 --> 00:07:02,700
actually have much lower overhead,

207
00:07:02,700 --> 00:07:05,190
because you don't need to pass around that electronic token

208
00:07:05,190 --> 00:07:06,480
and they can then make better use

209
00:07:06,480 --> 00:07:08,010
of the full bandwidth in the network

210
00:07:08,010 --> 00:07:10,920
because anybody can talk at any given time.

211
00:07:10,920 --> 00:07:12,570
Now, I know this may seem odd,

212
00:07:12,570 --> 00:07:14,670
but this is actually a really good thing.

213
00:07:14,670 --> 00:07:15,870
You see when you're dealing

214
00:07:15,870 --> 00:07:17,940
with a traditional deterministic network,

215
00:07:17,940 --> 00:07:20,790
you might split up the communications into chunks of time

216
00:07:20,790 --> 00:07:23,970
and then give each person an assigned time slot to transmit.

217
00:07:23,970 --> 00:07:26,670
For example, if we have eight devices on our network,

218
00:07:26,670 --> 00:07:28,230
we can say that everybody is going to get

219
00:07:28,230 --> 00:07:29,820
an equal amount of time to communicate

220
00:07:29,820 --> 00:07:32,100
of one eighth of one second.

221
00:07:32,100 --> 00:07:34,200
That way they'll talk for one eighth of a second

222
00:07:34,200 --> 00:07:36,270
and pass the token to the next network device,

223
00:07:36,270 --> 00:07:38,400
and then they'll communicate for one eighth of a second,

224
00:07:38,400 --> 00:07:39,900
and we'll continue to do this.

225
00:07:39,900 --> 00:07:41,580
So out of every one second,

226
00:07:41,580 --> 00:07:42,810
you're only going to be able to transmit

227
00:07:42,810 --> 00:07:44,700
one eighth of that second.

228
00:07:44,700 --> 00:07:47,460
Now, if you're using a 10 megabit per second network,

229
00:07:47,460 --> 00:07:48,810
you are only going to be able to transmit

230
00:07:48,810 --> 00:07:51,390
a single device 1.25 megabits

231
00:07:51,390 --> 00:07:53,790
during their portion of that second.

232
00:07:53,790 --> 00:07:55,830
Effectively, if you have eight clients,

233
00:07:55,830 --> 00:07:58,650
you just cut the network speed down by a factor of eight

234
00:07:58,650 --> 00:08:00,900
because most of the time, all of these devices

235
00:08:00,900 --> 00:08:03,270
don't have something they need to communicate.

236
00:08:03,270 --> 00:08:04,470
Think about it, if you and your friends

237
00:08:04,470 --> 00:08:05,970
were sitting around the table at the pub

238
00:08:05,970 --> 00:08:08,010
and I said that each of you had to take turns

239
00:08:08,010 --> 00:08:10,590
and you can only speak for one minute at a time.

240
00:08:10,590 --> 00:08:12,330
Now, some of your friends could fill up that one minute

241
00:08:12,330 --> 00:08:14,940
during their term and still not get out their whole story,

242
00:08:14,940 --> 00:08:17,220
but others, they might tell a quick one line joke

243
00:08:17,220 --> 00:08:18,840
that only took 15 seconds

244
00:08:18,840 --> 00:08:20,520
and now the rest of us are sitting there

245
00:08:20,520 --> 00:08:23,280
and waiting and listening to silence for 45 seconds,

246
00:08:23,280 --> 00:08:25,620
until it's the next person's turn to talk.

247
00:08:25,620 --> 00:08:27,840
For this reason, deterministic models

248
00:08:27,840 --> 00:08:29,730
are going to waste a lot of resources.

249
00:08:29,730 --> 00:08:31,590
So when they designed ethernet,

250
00:08:31,590 --> 00:08:34,049
they chose to maximize the efficiency of the network

251
00:08:34,049 --> 00:08:36,419
by allowing anyone to use all the bandwidth in the network

252
00:08:36,419 --> 00:08:39,179
at any time for as long as they need.

253
00:08:39,179 --> 00:08:40,950
Now, if any network device can transmit

254
00:08:40,950 --> 00:08:42,270
at any time of the network,

255
00:08:42,270 --> 00:08:44,280
how are we going to prevent collisions?

256
00:08:44,280 --> 00:08:46,350
Well, the way ethernet approaches this

257
00:08:46,350 --> 00:08:50,220
is by using something known as CSMA/CD,

258
00:08:50,220 --> 00:08:52,770
and this stands for carrier sense multiple access

259
00:08:52,770 --> 00:08:54,600
with collision detection.

260
00:08:54,600 --> 00:08:57,510
Now, carrier sense multiple access with collision detection

261
00:08:57,510 --> 00:08:59,430
is going to work just like when you're sitting at the pub

262
00:08:59,430 --> 00:09:01,080
on a Friday night with your friends.

263
00:09:01,080 --> 00:09:02,160
You're first going to listen

264
00:09:02,160 --> 00:09:04,650
and wait until you hear that gap in the conversation,

265
00:09:04,650 --> 00:09:06,240
and then you'll start to talk.

266
00:09:06,240 --> 00:09:08,707
If two people spoke at the same time, you simply say,

267
00:09:08,707 --> 00:09:09,990
"Oh, I'm sorry,"

268
00:09:09,990 --> 00:09:11,910
and then you pause for a random amount of time

269
00:09:11,910 --> 00:09:13,020
and then try to speak again

270
00:09:13,020 --> 00:09:15,180
if there's another gap in the conversation.

271
00:09:15,180 --> 00:09:17,040
Well, this is the exact same idea here

272
00:09:17,040 --> 00:09:21,060
inside of ethernet when we're using CSMA/CD.

273
00:09:21,060 --> 00:09:25,020
So, let's break down CSMA/CD into each of its parts.

274
00:09:25,020 --> 00:09:28,080
First, we have CS, which means that our ethernet devices

275
00:09:28,080 --> 00:09:30,300
must be able to do carrier sensing,

276
00:09:30,300 --> 00:09:32,070
and that means they can listen to the network

277
00:09:32,070 --> 00:09:34,140
to determine if there's already a signal being transmitted

278
00:09:34,140 --> 00:09:36,330
over that network at that time.

279
00:09:36,330 --> 00:09:38,820
Carrier is just a fancy word in electronics

280
00:09:38,820 --> 00:09:41,130
that is referring to the signal that carries information

281
00:09:41,130 --> 00:09:44,580
or data over a given media like a cable, a fiber,

282
00:09:44,580 --> 00:09:46,620
or a radio frequency wave.

283
00:09:46,620 --> 00:09:48,570
Now, if there's a gap in the communication,

284
00:09:48,570 --> 00:09:52,253
then we can move into the MA part of CSMA/CD.

285
00:09:52,253 --> 00:09:55,800
MA is going to stand for multiple access, and all this means

286
00:09:55,800 --> 00:09:57,600
is that there are going to be many different devices

287
00:09:57,600 --> 00:09:59,460
that all have the ability to access,

288
00:09:59,460 --> 00:10:02,340
listen for, or transmit on that same network

289
00:10:02,340 --> 00:10:03,780
at a given time.

290
00:10:03,780 --> 00:10:05,070
So, ethernet is going to have

291
00:10:05,070 --> 00:10:06,990
a lot of devices connected to the network

292
00:10:06,990 --> 00:10:09,360
and they're all going to be listening before they speak.

293
00:10:09,360 --> 00:10:14,280
This is the CSMA part of CSMA/CD.

294
00:10:14,280 --> 00:10:15,810
Now, this brings us to the last part,

295
00:10:15,810 --> 00:10:18,270
which is CD or collision detection.

296
00:10:18,270 --> 00:10:19,650
Since all of these network devices

297
00:10:19,650 --> 00:10:21,090
are listening on the network,

298
00:10:21,090 --> 00:10:22,950
if they detect a collision has occurred

299
00:10:22,950 --> 00:10:24,480
when they're transmitting something,

300
00:10:24,480 --> 00:10:27,060
then those two devices that we're talking over each other

301
00:10:27,060 --> 00:10:29,940
are going to have to decide who's going to transmit their data now

302
00:10:29,940 --> 00:10:32,430
and who's going to have to wait and then retransmit.

303
00:10:32,430 --> 00:10:34,020
To simplify this process,

304
00:10:34,020 --> 00:10:36,000
ethernet is going to use a pretty clever method

305
00:10:36,000 --> 00:10:38,430
to determine who gets to transmit first.

306
00:10:38,430 --> 00:10:40,380
Now, whenever there's a collision detected,

307
00:10:40,380 --> 00:10:41,760
both of those ethernet devices

308
00:10:41,760 --> 00:10:43,980
are going to stop transmitting immediately

309
00:10:43,980 --> 00:10:45,840
and they're going to pick a random number.

310
00:10:45,840 --> 00:10:48,480
Then, they're going to wait that amount of milliseconds

311
00:10:48,480 --> 00:10:51,240
before they try to retransmit their message again.

312
00:10:51,240 --> 00:10:53,610
So if you and your friend both speak at the same time

313
00:10:53,610 --> 00:10:55,350
when you're sitting around the table at the pub,

314
00:10:55,350 --> 00:10:57,270
you might have a rule that you both need to pick

315
00:10:57,270 --> 00:10:59,820
a rate of number, count up to that number in your head,

316
00:10:59,820 --> 00:11:01,620
and then if nobody is speaking,

317
00:11:01,620 --> 00:11:03,630
you can then transmit your message.

318
00:11:03,630 --> 00:11:05,790
This is exactly what an ethernet device does

319
00:11:05,790 --> 00:11:07,230
when they detect a collision.

320
00:11:07,230 --> 00:11:09,450
They'll stop transmitting, they pick a random number,

321
00:11:09,450 --> 00:11:10,920
and then they start counting.

322
00:11:10,920 --> 00:11:13,890
This is officially known as a random back off timer,

323
00:11:13,890 --> 00:11:15,300
and this allows the two devices

324
00:11:15,300 --> 00:11:18,900
to attempt to retransmit again when their timer hits zero.

325
00:11:18,900 --> 00:11:20,460
I want you to think about it this way.

326
00:11:20,460 --> 00:11:22,320
Have you ever been walking down the hallway at work

327
00:11:22,320 --> 00:11:24,060
and somebody's coming from the other direction,

328
00:11:24,060 --> 00:11:25,260
and it's a small hallway.

329
00:11:25,260 --> 00:11:26,610
And as you walk up to each other,

330
00:11:26,610 --> 00:11:28,920
you kind of do that little dance of I'll go left,

331
00:11:28,920 --> 00:11:31,440
you go right, I'll go right, you go left,

332
00:11:31,440 --> 00:11:33,720
and neither of you is actually getting out of the way.

333
00:11:33,720 --> 00:11:36,030
Now in this case, if neither of you say anything,

334
00:11:36,030 --> 00:11:37,470
you're just going to try to figure it out

335
00:11:37,470 --> 00:11:39,420
by kind of doing this dance back and forth,

336
00:11:39,420 --> 00:11:41,130
and that's not really that efficient.

337
00:11:41,130 --> 00:11:42,780
Well, if this has ever happened to you,

338
00:11:42,780 --> 00:11:46,680
you are smack dab in the middle of a CSMA/CD collision.

339
00:11:46,680 --> 00:11:49,230
So, what should you do to be more effective

340
00:11:49,230 --> 00:11:50,370
when this happens?

341
00:11:50,370 --> 00:11:51,900
Well, I'll tell you what I do.

342
00:11:51,900 --> 00:11:54,930
Whenever I do it, I do exactly what ethernet does.

343
00:11:54,930 --> 00:11:56,820
I literally will stop in the middle of the hallway

344
00:11:56,820 --> 00:12:00,000
where I am and I'll count in my head to two or three.

345
00:12:00,000 --> 00:12:01,440
Now, if the person walks around me

346
00:12:01,440 --> 00:12:04,110
during those two or three seconds, great, I will let them,

347
00:12:04,110 --> 00:12:05,580
and then I'll continue to walk down the hall

348
00:12:05,580 --> 00:12:06,750
once they pass me.

349
00:12:06,750 --> 00:12:09,090
But if they don't move during that two to three seconds,

350
00:12:09,090 --> 00:12:10,290
I will walk around them

351
00:12:10,290 --> 00:12:12,480
and then continue down the hallway myself.

352
00:12:12,480 --> 00:12:15,060
This is really CSMA/CD at work,

353
00:12:15,060 --> 00:12:17,070
and it effectively ends that side to side dance

354
00:12:17,070 --> 00:12:19,440
that can go on during a collision in the hallway.

355
00:12:19,440 --> 00:12:21,060
So, let's take a quick look at

356
00:12:21,060 --> 00:12:23,580
what this looks like in an ethernet network.

357
00:12:23,580 --> 00:12:26,220
In this example, I have six devices on the network

358
00:12:26,220 --> 00:12:27,600
and they're using a bust apology

359
00:12:27,600 --> 00:12:29,580
just to make it easier for you to see.

360
00:12:29,580 --> 00:12:32,430
With ethernet, we could use a star, a bus, a ring,

361
00:12:32,430 --> 00:12:33,930
or any topology you want.

362
00:12:33,930 --> 00:12:35,190
It really doesn't matter.

363
00:12:35,190 --> 00:12:36,300
But for this illustration

364
00:12:36,300 --> 00:12:37,710
and to fit everything on the screen,

365
00:12:37,710 --> 00:12:39,930
I'm just going to go ahead and use a bus.

366
00:12:39,930 --> 00:12:41,940
So if device number 4 wants to talk

367
00:12:41,940 --> 00:12:43,920
to device number 5, they can communicate

368
00:12:43,920 --> 00:12:44,940
over this network segment

369
00:12:44,940 --> 00:12:46,380
and there's not going to be any problems

370
00:12:46,380 --> 00:12:48,540
because nobody else is talking right now.

371
00:12:48,540 --> 00:12:50,370
Then if device number 2 wants to talk

372
00:12:50,370 --> 00:12:51,450
to device number 1,

373
00:12:51,450 --> 00:12:52,950
they can see through carrier sensing

374
00:12:52,950 --> 00:12:54,150
that the line is clear,

375
00:12:54,150 --> 00:12:55,890
and so device number 2 will transmit

376
00:12:55,890 --> 00:12:58,050
and device number 1 will receive that data,

377
00:12:58,050 --> 00:12:59,820
and there'll be no issues either.

378
00:12:59,820 --> 00:13:01,680
But what happens if two devices

379
00:13:01,680 --> 00:13:03,270
try to talk at the same time,

380
00:13:03,270 --> 00:13:06,030
like device number 3 and device number 5?

381
00:13:06,030 --> 00:13:07,680
First, they listen to the carrier.

382
00:13:07,680 --> 00:13:09,316
If they don't see anybody else talking already,

383
00:13:09,316 --> 00:13:11,397
that means they can both try to talk.

384
00:13:11,397 --> 00:13:13,590
And if they do that simultaneously,

385
00:13:13,590 --> 00:13:16,170
that transmitted data is going to cause a collision,

386
00:13:16,170 --> 00:13:19,140
and we will get this big red X on our screen.

387
00:13:19,140 --> 00:13:20,910
Now, a collision is detected,

388
00:13:20,910 --> 00:13:23,100
so now that we have a collision detected,

389
00:13:23,100 --> 00:13:24,720
device 3, and device 5

390
00:13:24,720 --> 00:13:27,360
are both going to pick a random back off timer.

391
00:13:27,360 --> 00:13:28,770
In the case of device 3,

392
00:13:28,770 --> 00:13:30,890
it's going to choose to wait 30 milliseconds.

393
00:13:30,890 --> 00:13:34,770
In the case of device 5, it chooses 150 milliseconds.

394
00:13:34,770 --> 00:13:36,750
Both of these are chosen at random.

395
00:13:36,750 --> 00:13:38,610
So, what's going to happen next?

396
00:13:38,610 --> 00:13:40,860
Well, 30 milliseconds goes by,

397
00:13:40,860 --> 00:13:42,690
device number 3 is going to listen to the carrier

398
00:13:42,690 --> 00:13:44,580
and it doesn't detect anybody else transmitting,

399
00:13:44,580 --> 00:13:46,530
so it starts transmitting.

400
00:13:46,530 --> 00:13:49,830
At the same time, device number 5 is still going to be waiting

401
00:13:49,830 --> 00:13:52,320
because we've only had 30 milliseconds pass by

402
00:13:52,320 --> 00:13:54,810
and it chose to wait 150 milliseconds,

403
00:13:54,810 --> 00:13:57,180
so it still has to wait another 120 milliseconds

404
00:13:57,180 --> 00:13:59,670
on its back off timer before it checks the carrier

405
00:13:59,670 --> 00:14:01,591
to see if anybody's communicating well.

406
00:14:01,591 --> 00:14:04,170
Now, the device number 5 is going to be waiting.

407
00:14:04,170 --> 00:14:06,540
It waits until the end of the 150 milliseconds.

408
00:14:06,540 --> 00:14:08,100
Once that timer hits zero,

409
00:14:08,100 --> 00:14:09,810
it's going to listen to the carrier again,

410
00:14:09,810 --> 00:14:11,310
and if it hears somebody transmitting,

411
00:14:11,310 --> 00:14:14,010
which in this case device number 3 is still transmitting,

412
00:14:14,010 --> 00:14:15,900
it can wait until it finds a new open spot

413
00:14:15,900 --> 00:14:17,520
in the conversation, which will occur

414
00:14:17,520 --> 00:14:19,620
when device number three is done transmitting,

415
00:14:19,620 --> 00:14:20,453
which in this case

416
00:14:20,453 --> 00:14:23,070
is about another 180 milliseconds from now.

417
00:14:23,070 --> 00:14:25,530
Now, whenever device number three is done communicating

418
00:14:25,530 --> 00:14:27,630
and the carrier seems clear for transmission,

419
00:14:27,630 --> 00:14:29,850
device number 5 will transmit its message

420
00:14:29,850 --> 00:14:31,410
and hopefully it will get through this time

421
00:14:31,410 --> 00:14:32,910
without a collision.

422
00:14:32,910 --> 00:14:35,040
Now, if during this time somebody else happens

423
00:14:35,040 --> 00:14:37,410
to transmit the same time as one of these devices,

424
00:14:37,410 --> 00:14:38,790
we're going to have another collision,

425
00:14:38,790 --> 00:14:39,720
and both of these devices

426
00:14:39,720 --> 00:14:42,300
will choose a random back off time again to wait,

427
00:14:42,300 --> 00:14:44,130
and then the cycle repeats until everybody

428
00:14:44,130 --> 00:14:46,590
has transmitted everything they want to send.

429
00:14:46,590 --> 00:14:48,810
Now, if this seems like a bad way of doing things,

430
00:14:48,810 --> 00:14:50,880
because as our networks get busier and busier

431
00:14:50,880 --> 00:14:52,380
and have more and more clients,

432
00:14:52,380 --> 00:14:53,970
we would end up having more collisions,

433
00:14:53,970 --> 00:14:57,540
well, you would be 100% accurate and correct.

434
00:14:57,540 --> 00:14:59,250
The more devices you have communicating

435
00:14:59,250 --> 00:15:00,810
on a single network segment,

436
00:15:00,810 --> 00:15:03,120
the more collisions you are going to have.

437
00:15:03,120 --> 00:15:05,430
Each area of the network that shares a single segment

438
00:15:05,430 --> 00:15:07,710
is what we call a collision domain.

439
00:15:07,710 --> 00:15:09,780
In the example I showed you of this bus network,

440
00:15:09,780 --> 00:15:12,900
we have six devices all sharing a single bus cable

441
00:15:12,900 --> 00:15:15,270
and this makes up our collision domain.

442
00:15:15,270 --> 00:15:18,330
With ethernet, anytime you have devices on the same cable,

443
00:15:18,330 --> 00:15:20,070
or if they're connected to a hub,

444
00:15:20,070 --> 00:15:22,740
they're all going to be sharing the same collision domain.

445
00:15:22,740 --> 00:15:24,600
Because of the shared collision domain,

446
00:15:24,600 --> 00:15:27,600
all of the devices will need to operate in half duplex mode,

447
00:15:27,600 --> 00:15:29,370
so they can either listen or talk,

448
00:15:29,370 --> 00:15:31,830
but they can't do both at the same time.

449
00:15:31,830 --> 00:15:34,140
If a device talks and listens at the same time,

450
00:15:34,140 --> 00:15:35,640
they're simply going to hear themself

451
00:15:35,640 --> 00:15:36,840
and think that some other device

452
00:15:36,840 --> 00:15:38,280
is on the network transmitting,

453
00:15:38,280 --> 00:15:40,020
and so they're not going to send their message.

454
00:15:40,020 --> 00:15:42,210
So, they can't operate in full duplex

455
00:15:42,210 --> 00:15:44,850
when you're using a hub or a shared network segment

456
00:15:44,850 --> 00:15:47,850
or simply, they'll end up being way too many collisions.

457
00:15:47,850 --> 00:15:50,730
For this reason, we need to keep our collision domain small

458
00:15:50,730 --> 00:15:52,080
inside of our networks.

459
00:15:52,080 --> 00:15:53,940
If you have a very large collision domain,

460
00:15:53,940 --> 00:15:55,740
there's a very high possibility

461
00:15:55,740 --> 00:15:57,240
that collisions are going to occur

462
00:15:57,240 --> 00:15:58,860
and each time a collision occurs,

463
00:15:58,860 --> 00:16:00,840
this requires the data to be remitted

464
00:16:00,840 --> 00:16:03,720
after Waiting a random back off timer to finish.

465
00:16:03,720 --> 00:16:05,550
This will slow down the entire network segment

466
00:16:05,550 --> 00:16:07,350
and actually slow down your entire network

467
00:16:07,350 --> 00:16:10,170
to a much lower bandwidth than what you should be getting.

468
00:16:10,170 --> 00:16:11,940
If you have a hub with four devices,

469
00:16:11,940 --> 00:16:14,070
this probably won't be a major issue for you.

470
00:16:14,070 --> 00:16:17,010
But if you're using a 24 or 48 port hub,

471
00:16:17,010 --> 00:16:18,660
these collisions will bring your network

472
00:16:18,660 --> 00:16:20,400
to a screeching halt.

473
00:16:20,400 --> 00:16:22,590
Think about it this way, if we're going to the pub

474
00:16:22,590 --> 00:16:23,760
with a group of four people,

475
00:16:23,760 --> 00:16:26,160
we can make that conversation work fairly naturally

476
00:16:26,160 --> 00:16:27,990
without having too many collisions.

477
00:16:27,990 --> 00:16:30,510
But if we have 20 or 25 people,

478
00:16:30,510 --> 00:16:32,370
we're going to have entirely too many collisions

479
00:16:32,370 --> 00:16:33,960
and it simply won't work.

480
00:16:33,960 --> 00:16:36,120
So, we're going to need to break our larger group

481
00:16:36,120 --> 00:16:37,350
into smaller groups.

482
00:16:37,350 --> 00:16:38,970
If we're going to the pub this weekend,

483
00:16:38,970 --> 00:16:42,300
we may do this by breaking up our group of 20 to 25 friends

484
00:16:42,300 --> 00:16:44,160
into groups of four or five people,

485
00:16:44,160 --> 00:16:46,170
and then sit them each at different tables.

486
00:16:46,170 --> 00:16:48,420
This breaks down our large single collision domain

487
00:16:48,420 --> 00:16:49,920
of 20 to 25 people

488
00:16:49,920 --> 00:16:52,110
into five or six smaller collision domains

489
00:16:52,110 --> 00:16:54,060
of four to five people each.

490
00:16:54,060 --> 00:16:56,760
In our networks, the way we break down our collision domains

491
00:16:56,760 --> 00:16:59,490
is by using ethernet switches or bridges.

492
00:16:59,490 --> 00:17:00,810
This drastically will increase

493
00:17:00,810 --> 00:17:02,280
the scalability of our networks

494
00:17:02,280 --> 00:17:04,200
by creating a lot of collision domains.

495
00:17:04,200 --> 00:17:05,369
And that's a really good thing

496
00:17:05,369 --> 00:17:06,708
because when you look at a switch,

497
00:17:06,708 --> 00:17:08,369
every single switch port

498
00:17:08,369 --> 00:17:11,069
is considered to be its own collision domain.

499
00:17:11,069 --> 00:17:13,170
And so here, you can see with my switch in the center,

500
00:17:13,170 --> 00:17:14,880
I have four collision domains,

501
00:17:14,880 --> 00:17:17,730
one in between each computer and the switch itself.

502
00:17:17,730 --> 00:17:20,369
Now, if I was using a hub, all four devices

503
00:17:20,369 --> 00:17:22,290
and the hub itself are all going to share

504
00:17:22,290 --> 00:17:23,819
a single collision domain,

505
00:17:23,819 --> 00:17:25,770
and this will end up causing a lot more problems for us

506
00:17:25,770 --> 00:17:28,290
as these hubs get larger in size.

507
00:17:28,290 --> 00:17:30,690
So by simply replacing a hub with a switch,

508
00:17:30,690 --> 00:17:32,580
I can actually increase the speed of my network

509
00:17:32,580 --> 00:17:34,950
because nobody else is talking on that switch port

510
00:17:34,950 --> 00:17:37,140
except for the devices I cable to it,

511
00:17:37,140 --> 00:17:39,420
and therefore the switch port can now operate

512
00:17:39,420 --> 00:17:41,100
in full duplex mode.

513
00:17:41,100 --> 00:17:43,170
After all, if there's only my device

514
00:17:43,170 --> 00:17:44,970
and the switch on this network segment,

515
00:17:44,970 --> 00:17:47,010
there is no chance a collision.

516
00:17:47,010 --> 00:17:49,290
It's like if I was sitting in a room all by myself,

517
00:17:49,290 --> 00:17:52,020
I can talk all I want and I'm never going to have a collision

518
00:17:52,020 --> 00:17:54,390
because nobody else is there to talk with me.

519
00:17:54,390 --> 00:17:56,310
So when you're using a switch,

520
00:17:56,310 --> 00:17:58,260
you can operate in full duplex mode

521
00:17:58,260 --> 00:18:00,600
because all of your devices will not have to listen

522
00:18:00,600 --> 00:18:02,670
before they transmit because they know

523
00:18:02,670 --> 00:18:05,700
they have a full-time dedicated channel between themselves,

524
00:18:05,700 --> 00:18:08,430
the device, and the switch they're communicating to.

525
00:18:08,430 --> 00:18:10,470
This allows us to transmit data faster

526
00:18:10,470 --> 00:18:13,290
and to get more bandwidth out of our connections.

527
00:18:13,290 --> 00:18:15,030
Now, I know this was a long lesson,

528
00:18:15,030 --> 00:18:16,230
but the key takeaway here

529
00:18:16,230 --> 00:18:18,990
is that ethernet is our preferred Layer 2 protocol

530
00:18:18,990 --> 00:18:20,550
that's going to be used in our modern networks

531
00:18:20,550 --> 00:18:22,290
for most of our use cases.

532
00:18:22,290 --> 00:18:24,330
Also, if you're using ethernet,

533
00:18:24,330 --> 00:18:26,400
you should be using switches instead of hubs

534
00:18:26,400 --> 00:18:27,480
because each switch port

535
00:18:27,480 --> 00:18:29,190
is going to be its own collision domain

536
00:18:29,190 --> 00:18:30,840
and can operate in full duplex mode

537
00:18:30,840 --> 00:18:33,570
instead of half duplex mode like a hub has to

538
00:18:33,570 --> 00:18:35,820
because of the way carrier sets multiple access,

539
00:18:35,820 --> 00:18:37,970
collision detection systems are going to work.

