WEBVTT

00:00:00.000 --> 00:00:03.690
Welcome back to CSE 316 — Data Communication and Networking.

00:00:03.740 --> 00:00:09.320
This is the detailed video version of Session ten, and this is the mask lecture.

00:00:09.370 --> 00:00:17.250
Last session ended with a promise: the address stopped telling you where its own network part ends, so something else has to.

00:00:17.300 --> 00:00:26.010
Today is that something else — two ways of saying the same thing, and one machine instruction that makes it worth saying.

00:00:26.060 --> 00:00:35.010
This hour is repetitive on purpose. Everything in the next six sessions is this hour, applied over and over.

00:00:36.384 --> 00:00:39.664
I want you to write a number down before we start anything.

00:00:39.714 --> 00:00:44.584
Two five five, dot two five five, dot two five five, dot one nine two.

00:00:44.634 --> 00:00:53.494
Put it in the top corner of your page and leave it alone. We come back to it in the last five minutes.

00:00:53.544 --> 00:01:02.494
Because that number is not an abstraction. It is sitting in your router right now, on the line under your IP address, labelled "subnet mask".

00:01:02.984 --> 00:01:09.924
Every device you own carries one. And a mask, by definition, hides something.

00:01:09.974 --> 00:01:14.064
So: a mask of what? What is it hiding, and from whom?

00:01:14.114 --> 00:01:23.064
Write one guess. "It hides part of the address" is nearly right: what it hides is the host part, and the last slide of the session says why hiding it is useful.

00:01:25.754 --> 00:01:30.014
And the whole session, in five words: where the ones stop.

00:01:30.064 --> 00:01:38.601
That is it. That is the sentence. Everything else today is an elaboration of it.

00:01:38.651 --> 00:01:39.821
Section one.

00:01:39.871 --> 00:01:42.191
The boundary has to arrive separately.

00:01:42.241 --> 00:01:51.191
Classful addressing had exactly one real virtue, and classless threw it away. Understanding what was lost is how the rest of the hour makes sense.

00:01:54.817 --> 00:02:00.027
Classless addressing is three sentences long. Here they are.

00:02:00.077 --> 00:02:07.457
One. A block can be any power-of-two size. One, two, four, eight, sixteen, and up.

00:02:07.507 --> 00:02:16.457
Not three fixed sizes chosen in nineteen eighty-one — a size chosen for the customer who is actually asking.

00:02:16.517 --> 00:02:22.067
Two. The first n bits still name the network, and the rest still name the host.

00:02:22.117 --> 00:02:28.377
That idea did not change at all. If you were worried the ground had moved, it has not.

00:02:28.427 --> 00:02:32.167
Three. And n can be anything from zero to thirty-two.

00:02:32.217 --> 00:02:36.027
That is the entire difference. One variable was unpinned.

00:02:36.077 --> 00:02:45.027
The fence between network and host is no longer nailed to a byte boundary, and it is no longer nailed to a class.

00:02:46.450 --> 00:02:51.700
Now precisely what survived, because it is more than people expect.

00:02:51.750 --> 00:02:57.460
Still thirty-two bits, still four octets. The address itself is untouched.

00:02:57.510 --> 00:03:06.460
Nothing you learned about notation last session is obsolete. The conversions still work, the weights still work, the rules about legal dotted decimal still work.

00:03:08.730 --> 00:03:17.680
Still a network part on the left and a host part on the right. That two-part structure is the whole basis of routing, and it survives intact.

00:03:18.400 --> 00:03:23.820
What is gone: the address deciding its own class. The leading bits mean nothing now.

00:03:23.870 --> 00:03:32.820
One six seven dot one nine nine dot one seven zero dot eighty-two could be a slash eight, or a slash thirty. Nothing about the address prefers one.

00:03:34.780 --> 00:03:38.920
And also gone: the guarantee that the boundary lands on a dot.

00:03:38.970 --> 00:03:47.420
n equals twenty-seven sits inside the fourth octet. Boundaries stopped respecting the dots when they stopped respecting the classes.

00:03:47.470 --> 00:03:55.633
That is the discomfort of the day, and it is where this topic's marks are won and lost.

00:03:55.683 --> 00:04:01.833
Classful addressing had one real virtue, and it disappeared with the classes.

00:04:01.883 --> 00:04:10.833
Under classes, you could always tell. One nine three dot fourteen dot fifty-six dot twenty-two begins one one zero, so it is class C, so the network part is the first twenty-four bits.

00:04:12.783 --> 00:04:17.643
The address arrived carrying its own boundary, free of charge. It confessed.

00:04:17.693 --> 00:04:26.643
Under classless, you cannot. One six seven dot one nine nine dot one seven zero dot eighty-two — where does the network part stop?

00:04:28.383 --> 00:04:37.333
You cannot tell. Nobody can. Not your router, not your professor, not the address itself.

00:04:37.573 --> 00:04:42.083
So the boundary has to be delivered separately, alongside the address.

00:04:42.133 --> 00:04:51.083
And there are exactly two ways to deliver it: one for humans, one for machines. They are the same fact in two costumes, and they are the rest of this session.

00:04:55.417 --> 00:04:59.397
Method one is for humans, and it is simple.

00:04:59.447 --> 00:05:06.207
Write n after a slash. One six seven dot one nine nine dot one seven zero dot eighty-two, slash twenty-seven.

00:05:06.257 --> 00:05:14.517
The address, plus the confession the address can no longer make for itself: the first twenty-seven bits are network.

00:05:14.567 --> 00:05:21.687
Formally this is CIDR — Classless Interdomain Routing. Nobody says that out loud.

00:05:21.737 --> 00:05:26.037
Everybody says "slash notation", or just "slash twenty-seven".

00:05:26.087 --> 00:05:35.037
And n counts bits. Not octets, not bytes, not dots. Twenty-seven bits, starting at the very first bit of the address.

00:05:35.137 --> 00:05:41.887
Say "bits" in your head every time you read a slash. It is the single most common place people go wrong.

00:05:41.937 --> 00:05:50.887
So the prefix length is the boundary. "Slash twenty-seven" and "the fence is after bit twenty-seven" are the same sentence.

00:05:52.717 --> 00:06:00.930
There is nothing else in the notation. No hidden cleverness.

00:06:00.980 --> 00:06:04.950
Now look at where twenty-seven actually lands.

00:06:05.000 --> 00:06:13.740
Three octets is twenty-four bits. So one six seven, one nine nine and one seven zero are entirely inside the network part.

00:06:13.790 --> 00:06:20.700
Nothing interesting happens to them. Remember that — section four turns it into the shortcut.

00:06:20.750 --> 00:06:28.070
Three bits more, and those three sit inside the fourth octet. The boundary cuts the number eighty-two in half.

00:06:28.120 --> 00:06:35.970
Not at a digit. At a bit. There is no pen stroke you can draw through "eighty-two" that shows you where it fell.

00:06:36.020 --> 00:06:41.480
And that is why decimal intuition fails here, permanently and without exceptions.

00:06:41.530 --> 00:06:50.480
You cannot see bit three of eighty-two by looking at eighty-two. For the octet the fence cuts, there is no shortcut through decimal. Ever.

00:06:53.743 --> 00:06:59.773
Copy this slide verbatim into your notes. It is worth marks on its own.

00:06:59.823 --> 00:07:07.663
"What is the network address of one six seven dot one nine nine dot one seven zero dot eighty-two?" is not a question.

00:07:07.713 --> 00:07:12.453
It is half a question. The honest answer is: tell me n.

00:07:12.503 --> 00:07:16.583
Because the same address sits in a different network under every n.

00:07:16.633 --> 00:07:25.583
Slash eight puts it in one six seven dot zero dot zero dot zero. Slash sixteen puts it in one six seven dot one nine nine dot zero dot zero. Slash twenty-seven puts it in one six seven dot one nine nine dot one seven zero dot sixty-four.

00:07:31.653 --> 00:07:36.383
All three are correct answers — to three different questions.

00:07:36.433 --> 00:07:41.023
So n is not extra credit. It is half the information.

00:07:41.073 --> 00:07:47.933
An address without a prefix length is a house number without a street.

00:07:47.983 --> 00:07:56.933
And if an exam question genuinely omits n, say so. "Insufficient information — the prefix length is not given" is a correct and complete answer.

00:07:58.213 --> 00:08:07.026
Under classful you could always work it out. Under classless, refusing to guess is the skill.

00:08:07.076 --> 00:08:12.716
Checkpoint one. Paper, pen, and stop the video.

00:08:12.766 --> 00:08:19.816
One. In one sentence: what did classless addressing change, and what did it leave alone?

00:08:19.866 --> 00:08:28.816
Two. Under classful addressing, how did you know where the network part of one nine three dot fourteen dot fifty-six dot twenty-two ended?

00:08:29.976 --> 00:08:38.926
Three. Why is "what network is one six seven dot one nine nine dot one seven zero dot eighty-two on?" not a complete question?

00:08:39.526 --> 00:08:40.446
Answers.

00:08:40.496 --> 00:08:49.446
One. It unpinned n. The boundary can now sit anywhere from zero to thirty-two. The thirty-two-bit address, and the two-part structure, are unchanged.

00:08:51.516 --> 00:09:00.466
Two. The leading bits said so. One nine three starts one one zero, which is class C, which is a fixed slash twenty-four. The address carried its own boundary.

00:09:02.486 --> 00:09:11.436
Three. Because no prefix length is given, and nothing in the address decides between slash eight, slash sixteen and slash twenty-seven.

00:09:15.199 --> 00:09:17.539
Section two. The mask.

00:09:17.589 --> 00:09:19.929
A boundary, wearing a costume.

00:09:19.979 --> 00:09:28.929
The second way to deliver n is to write it as a thirty-two-bit number. It looks like an address. It is not one — it is a fence with a serial number.

00:09:32.749 --> 00:09:40.019
Method two is for computers, and this is where the number from the top corner of your page finally arrives.

00:09:40.069 --> 00:09:44.939
Take the sentence "the fence is after bit twenty-six".

00:09:44.989 --> 00:09:50.339
And write it as a thirty-two-bit number: twenty-six ones, then six zeros.

00:09:50.389 --> 00:09:58.109
The ones cover the network part exactly. The zeros cover the host part exactly. That is the whole design.

00:09:58.159 --> 00:10:05.159
Now read those four octets in decimal. Two five five. Two five five. Two five five. One nine two.

00:10:05.209 --> 00:10:10.679
And there it is. The number you wrote down in minute one.

00:10:10.729 --> 00:10:16.989
Two five five dot two five five dot two five five dot one nine two is slash twenty-six.

00:10:17.039 --> 00:10:23.349
Not a related fact. Not a consequence. The same fact, in a costume a machine can use.

00:10:23.399 --> 00:10:32.349
It looks like an address because it is written like one. It never behaves like one, and it never names anything.

00:10:33.966 --> 00:10:37.546
A mask is not a magic number. It is a boundary.

00:10:37.596 --> 00:10:46.546
Nothing more mysterious than a fence, drawn on a row of thirty-two bits, and written down in a format a router can consume in one instruction.

00:10:46.686 --> 00:10:52.376
Where the ones stop is where the network part stops.

00:10:52.426 --> 00:10:58.576
Say that out loud once. It is the sentence the rest of this arc is built on.

00:10:58.626 --> 00:11:03.496
And it follows that the mask and the slash carry identical information.

00:11:03.546 --> 00:11:12.496
Slash twenty-six and two five five dot two five five dot two five five dot one nine two are interchangeable. Converting between them is a lookup, not a calculation — and by the end of this section you will do it in your head.

00:11:18.946 --> 00:11:27.896
If you ever catch yourself treating a mask as an address — asking which host it is, or what network it is on — stop. It is a fence.

00:11:31.203 --> 00:11:35.623
And here is what that does to everything you learned last session.

00:11:35.673 --> 00:11:44.623
Class A was slash eight. As a mask: two five five dot zero dot zero dot zero. Eight ones, then twenty-four zeros. One frozen fence.

00:11:46.613 --> 00:11:53.793
Class B was slash sixteen. Two five five dot two five five dot zero dot zero. Sixteen ones. A second frozen fence.

00:11:53.843 --> 00:12:02.763
And class C was slash twenty-four. Twenty-four ones. The third — and there were no others.

00:12:02.813 --> 00:12:10.943
So classful addressing was never a different system. It was classless addressing with three legal values of n and no choice.

00:12:10.993 --> 00:12:19.943
That is the entire mask handout, in one line: classful offered you three masks. Classless offers you thirty-three and asks you to pick.

00:12:24.376 --> 00:12:31.736
Forty-two seconds, and one claim: a mask octet can only ever be one of nine numbers.

00:12:31.786 --> 00:12:38.766
Start with what a mask is not. Two five five dot two five five dot fourteen dot zero is not a mask.

00:12:38.816 --> 00:12:47.766
Not because fourteen is too small. Because of its shape. Ones, then zeros — never mixed, never interleaved. Fourteen is zero zero zero zero one one one zero, and the zeros are on the wrong side.

00:12:54.306 --> 00:13:03.256
Now build the legal ones. No ones at all is zero. One single one — and it goes on the left, because that is the only place ones may start.

00:13:03.546 --> 00:13:08.196
One zero zero zero zero zero zero zero. A hundred and twenty-eight.

00:13:08.246 --> 00:13:15.636
That is why the smallest non-zero mask octet is a hundred and twenty-eight, and not one.

00:13:15.686 --> 00:13:24.636
Add another. A hundred and twenty-eight plus sixty-four is one ninety-two. Plus thirty-two, two twenty-four. Plus sixteen, two forty.

00:13:26.236 --> 00:13:33.306
You are not memorising a table. You are adding place values, always from the left.

00:13:33.356 --> 00:13:42.306
Keep going and you run out. Zero, one twenty-eight, one ninety-two, two twenty-four, two forty, two forty-eight, two fifty-two, two fifty-four, two fifty-five.

00:13:42.906 --> 00:13:50.386
Zero to eight ones is nine possibilities. There is no tenth shape, so there can be no tenth number.

00:13:50.436 --> 00:13:59.386
And each rung tells you how far past the byte boundary the slash reaches. Four ones in the third octet is slash twenty. Six ones in the fourth is slash thirty.

00:14:01.196 --> 00:14:09.196
If a byte of a mask is not on this ladder, the mask is wrong. That is a one-second exam check, and it is free.

00:14:09.246 --> 00:14:18.196
Watch the five candidates. Two of them are masks. Three are not — and notice the third one, two five five dot zero dot two five five dot zero.

00:14:19.336 --> 00:14:26.706
Every octet is on the ladder, and it is still not a mask, because the ones restart after a zero.

00:14:26.756 --> 00:14:35.706
And the payoff. Slash twenty: twenty divided by eight is two, remainder four. Two full octets, then rung four — two forty.

00:14:36.466 --> 00:14:45.416
Two five five dot two five five dot two forty dot zero. One division, one lookup, and no arithmetic at all.

00:14:47.236 --> 00:14:52.206
Now the same ladder, standing still, so you can copy it.

00:14:52.256 --> 00:15:00.246
The two ends first. Zero ones is zero — an octet entirely host. Eight ones is two fifty-five — an octet entirely network.

00:15:00.296 --> 00:15:02.496
Everything else lives between them.

00:15:02.546 --> 00:15:11.496
Ones fill from the left, always. So the values run a hundred and twenty-eight, then one ninety-two, then two twenty-four, then two forty, and on down to two fifty-five.

00:15:14.596 --> 00:15:21.936
Another way to say it: each value is two fifty-six minus a power of two, because each new one halves what is left.

00:15:21.986 --> 00:15:29.676
There is no tenth value. Nine shapes, nine numbers, and nothing else can ever appear in a mask octet.

00:15:29.726 --> 00:15:38.676
Chant it. Two fifty-five, two fifty-four, two fifty-two, two forty-eight, two forty, two twenty-four, one ninety-two, one twenty-eight, zero.

00:15:41.226 --> 00:15:50.176
Downwards is easier to say. Upwards is easier to derive. Do both, out loud, twice a day for three days, and it is yours for the term.

00:15:51.836 --> 00:16:00.786
And this is not really memorisation. It is addition: a hundred and twenty-eight plus sixty-four plus thirty-two plus sixteen.

00:16:02.236 --> 00:16:11.186
Forget the table and you can rebuild it in ten seconds. That is why the bits matter more than the list.

00:16:13.269 --> 00:16:18.689
The ladder gives you something better than speed. It gives you a lie detector.

00:16:18.739 --> 00:16:25.389
A technician hands you two five five dot two five five dot two fifty dot zero and calls it a mask.

00:16:25.439 --> 00:16:33.999
Two fifty is not on the ladder. Reject it. No arithmetic required, no binary written.

00:16:34.049 --> 00:16:39.379
And the reason, if they ask: two fifty is one one one one one zero one zero.

00:16:39.429 --> 00:16:48.259
The ones are broken apart by a zero. A mask is a run of ones and then a run of zeros, with nothing interleaved.

00:16:48.309 --> 00:16:57.089
The rule is about shape, not value. Fifteen is zero zero zero zero one one one one — perfectly legal digits, illegal shape.

00:16:57.139 --> 00:17:02.249
The ones are all there. They are on the wrong side.

00:17:02.299 --> 00:17:07.519
And the rule runs across all thirty-two bits, not just inside one octet.

00:17:07.569 --> 00:17:16.519
Two five five dot zero dot two five five dot zero fails: every octet is on the ladder, and the run of ones still restarts after a zero. One unbroken run. That is the test.

00:17:23.430 --> 00:17:28.490
So here is the conversion. It is one division and one lookup.

00:17:28.540 --> 00:17:32.960
Slash twenty-six. Twenty-six divided by eight is three, remainder two.

00:17:33.010 --> 00:17:41.960
Three whole octets of ones — two five five, two five five, two five five. Then two more ones in the fourth octet.

00:17:43.570 --> 00:17:52.520
The ladder says two ones is one ninety-two. And everything after the fence is zero, but here the fence is inside the last octet, so there is nothing left to write.

00:17:54.280 --> 00:17:59.820
Two five five dot two five five dot two five five dot one nine two.

00:17:59.870 --> 00:18:05.600
And no thirty-two-bit binary was written. One division, one lookup, and the zeros.

00:18:05.650 --> 00:18:10.840
Do it this way every single time. The long way is four minutes you will not be given.

00:18:10.890 --> 00:18:19.840
Try slash twenty-one while the slide is up. Twenty-one divided by eight is two, remainder five. Two full octets, then five ones — two forty-eight. Two five five dot two five five dot two forty-eight dot zero.

00:18:28.758 --> 00:18:34.128
And backwards, which is the same two moves in the opposite order.

00:18:34.178 --> 00:18:43.128
Two five five dot two five five dot two forty dot zero. Count the full octets: two of them. That is sixteen bits before you reach anything interesting.

00:18:45.498 --> 00:18:50.608
The ladder says two forty is four ones. Sixteen plus four is twenty.

00:18:50.658 --> 00:18:56.848
Two five five dot two five five dot two forty dot zero is slash twenty.

00:18:56.898 --> 00:19:01.568
The trailing zero octet contributes nothing — and it is also your check.

00:19:01.618 --> 00:19:10.568
If a zero octet is followed by a non-zero one, you are not looking at a mask at all. Full octets give you the multiple of eight; the ladder gives you the remainder. That is the whole algorithm, and it runs in your head.

00:19:18.969 --> 00:19:25.089
Three questions. One: write slash twenty-seven as a dotted-decimal mask.

00:19:25.139 --> 00:19:31.629
Two: write two five five dot two five five dot two forty-eight dot zero in slash notation.

00:19:31.679 --> 00:19:39.879
Three: a technician gives you two five five dot two five five dot two fifty dot zero. What do you say?

00:19:39.929 --> 00:19:46.579
Ninety seconds, on paper, alone. Say the ladder out loud if it helps.

00:19:46.629 --> 00:19:55.579
One. Twenty-seven divided by eight is three remainder three, and three ones is two twenty-four. Two five five dot two five five dot two five five dot two twenty-four.

00:19:58.569 --> 00:20:04.119
Two. Two forty-eight is five ones, plus two full octets: slash twenty-one.

00:20:04.169 --> 00:20:12.629
Three. That is not a mask. Two fifty is one one one one one zero one zero, and the ones are not contiguous.

00:20:12.679 --> 00:20:21.629
Question three is the one the exam likes, because it looks like a conversion and is actually a shape check.

00:20:22.017 --> 00:20:26.147
Checkpoint two. Stop the video.

00:20:26.197 --> 00:20:33.397
One. Write slash twenty-nine as a dotted-decimal mask, showing the division and the ladder lookup.

00:20:33.447 --> 00:20:40.897
Two. Why can a mask octet never be a hundred, or sixty-three, or two hundred?

00:20:40.947 --> 00:20:49.897
Three. Is two five five dot two five five dot zero dot two five five a valid mask? Give the reason, not just the verdict.

00:20:50.067 --> 00:20:50.997
Answers.

00:20:51.047 --> 00:20:59.997
One. Twenty-nine divided by eight is three, remainder five. Three full octets of ones, then five ones — the ladder says two forty-eight. Two five five dot two five five dot two five five dot two forty-eight.

00:21:06.657 --> 00:21:15.607
Two. Because every one of those needs a one to the right of a zero. Ones fill from the left, so only the nine ladder values can occur.

00:21:16.657 --> 00:21:25.607
Three. No. Each octet is on the ladder, but the run of ones is broken — sixteen ones, eight zeros, then eight ones. The ones must be contiguous across all thirty-two bits.

00:21:31.316 --> 00:21:33.386
Section three. AND.

00:21:33.436 --> 00:21:38.306
So far the mask only restates n. Fine — but then why bother?

00:21:38.356 --> 00:21:47.306
Why does every router on Earth store the boundary as thirty-two bits instead of one small integer? Because of what comes next.

00:21:49.180 --> 00:21:52.960
Two rules, and you already know both of them.

00:21:53.010 --> 00:21:58.210
One AND anything is the anything. The address bit passes through untouched.

00:21:58.260 --> 00:22:02.470
Under the ones, the address is simply copied.

00:22:02.520 --> 00:22:06.980
Zero AND anything is zero. The address bit is erased.

00:22:07.030 --> 00:22:11.200
Under the zeros, whatever was there becomes nothing.

00:22:11.250 --> 00:22:14.500
Put those two together and look at what a mask is for.

00:22:14.550 --> 00:22:23.500
ANDing an address with its mask keeps the network part and erases the host part — in one operation, across all thirty-two bits at once.

00:22:25.220 --> 00:22:28.980
And that is the answer to the question I asked at the start of the section.

00:22:29.030 --> 00:22:37.730
AND is the cheapest instruction silicon owns. One operation per packet, in every router on the path, and no arithmetic anywhere.

00:22:37.780 --> 00:22:46.730
A router does this to every single packet it ever forwards. The design is not elegant by accident. It is elegant because it had to be free.

00:22:50.900 --> 00:22:59.720
Forty-two seconds, all thirty-two bits, and no shortcuts. This is Forouzan's arithmetic, done honestly.

00:22:59.770 --> 00:23:05.290
Two zero five dot sixteen dot thirty-seven dot thirty-nine, slash twenty-eight.

00:23:05.340 --> 00:23:09.540
Remember this address. It comes back next session carrying marks.

00:23:09.590 --> 00:23:15.580
Right now it is just thirty-two bits, written out, with nothing calculated.

00:23:15.630 --> 00:23:20.750
The mask, written from the slash. Twenty-eight ones, then four zeros.

00:23:20.800 --> 00:23:29.750
Twenty-eight ones fills the first three bytes — twenty-four — and four more of the fourth. The four bits left over are the host bits.

00:23:32.140 --> 00:23:41.090
Now the first twenty-four bits, all masked by ones. Two zero five stays two zero five. Sixteen stays sixteen. Thirty-seven stays thirty-seven.

00:23:42.930 --> 00:23:51.880
Nothing happens to them, and that is the point — it is exactly why you never compute the full-byte parts.

00:23:52.390 --> 00:23:58.870
And the fourth byte, bit by bit, left to right. Thirty-nine is zero zero one zero zero one one one.

00:23:58.920 --> 00:24:07.870
The first four mask bits are one, so zero, zero, one, zero come through unchanged. The last four are zero — and zero AND anything is zero.

00:24:11.510 --> 00:24:19.940
The four host bits collapse. Zero zero one zero, zero one one one becomes zero zero one zero, zero zero zero zero. Thirty-two.

00:24:19.990 --> 00:24:28.430
That collapse is the network address. Not a loss — a deliberate setting of every host bit to its lowest value.

00:24:28.480 --> 00:24:36.810
Two zero five dot sixteen dot thirty-seven dot thirty-two, slash twenty-eight. Four host bits, so sixteen addresses.

00:24:36.860 --> 00:24:45.810
The block runs from thirty-two to forty-seven, and our address — thirty-nine — sits inside it, sharing its first twenty-eight bits with every other address in the block.

00:24:48.720 --> 00:24:53.900
And there is the frame that matters. In an exam you AND one byte, never four.

00:24:53.950 --> 00:25:00.673
Find the byte the slash cuts. Everything else is copying.

00:25:00.723 --> 00:25:08.013
Now the same thing with the address we have been carrying all session, on paper, at exam speed.

00:25:08.063 --> 00:25:15.513
Slash twenty-seven. Three full octets of ones, so the first three octets are under two fifty-fives.

00:25:15.563 --> 00:25:23.913
One six seven stays one six seven. One nine nine stays one nine nine. One seven zero stays one seven zero.

00:25:23.963 --> 00:25:31.103
No thinking required. If you are writing binary here, you are wasting the clock.

00:25:31.153 --> 00:25:37.593
The fourth octet is the only one that moves. Eighty-two is zero one zero one zero zero one zero.

00:25:37.643 --> 00:25:43.683
The mask octet is two twenty-four, which is one one one zero zero zero zero zero.

00:25:43.733 --> 00:25:50.373
AND them: zero one zero zero zero zero zero zero. That is sixty-four.

00:25:50.423 --> 00:25:57.003
So the network address is one six seven dot one nine nine dot one seven zero dot sixty-four, slash twenty-seven.

00:25:57.053 --> 00:26:04.143
It is not this laptop's address any more. It is the name of the street the laptop lives on.

00:26:04.193 --> 00:26:13.143
Cover the slide and redo that fourth octet from scratch. If it takes more than twenty seconds, do it again tomorrow.

00:26:14.723 --> 00:26:21.873
Now what that answer actually is, because people compute it correctly and then misunderstand it.

00:26:21.923 --> 00:26:25.493
The network address is the address with every host bit set to zero.

00:26:25.543 --> 00:26:34.493
Which makes it the lowest address in the block — the first one. That is not a coincidence, it is the definition.

00:26:35.473 --> 00:26:43.403
It is not a machine. Nobody is assigned one six seven dot one nine nine dot one seven zero dot sixty-four slash twenty-seven.

00:26:43.453 --> 00:26:48.083
It names the block, and every host in that block shares it.

00:26:48.133 --> 00:26:52.623
Which is exactly what a router wants. Routers do not deliver to houses.

00:26:52.673 --> 00:26:59.033
They deliver to streets, and hand the packet to the last hop, which knows the houses.

00:26:59.083 --> 00:27:06.793
So the mask is how a router un-sees the house number — deliberately, cheaply, and identically for every packet.

00:27:06.843 --> 00:27:11.083
The host part is not lost. It is simply not the router's business.

00:27:11.133 --> 00:27:20.083
Hold on to "the router delivers to streets". In Session seventeen it becomes longest-prefix match, and that sentence is the whole of the intuition.

00:27:25.116 --> 00:27:29.656
Here is the whole idea as something you can grab with a mouse.

00:27:29.706 --> 00:27:37.036
It opens on our address at slash twenty-four — the comfortable one, where the fence sits on a dot.

00:27:37.086 --> 00:27:46.036
Three rows: the address in bits, the mask in bits, and the result. Everything lines up, and the network address is one six seven dot one nine nine dot one seven zero dot zero.

00:27:49.866 --> 00:27:56.186
Now slash twenty-six. Watch what moved: I am not editing a mask. I am moving a fence.

00:27:56.236 --> 00:28:05.186
The dotted mask followed — two five five dot two five five dot two five five dot one nine two. The network address followed. The block size followed. All three are consequences of one line on the screen.

00:28:10.636 --> 00:28:15.986
Slash twenty-seven, and there is the example we just did on paper. Sixty-four.

00:28:16.036 --> 00:28:23.536
Three bits into the last octet, thirty-two addresses in the block, and the range printed underneath.

00:28:23.586 --> 00:28:29.546
Now the uncomfortable one. One seven two dot sixteen dot one nine nine dot forty-four, slash twenty.

00:28:29.596 --> 00:28:37.686
Look at the third octet splitting mid-digit. There is no dot there, and the fence does not care.

00:28:37.736 --> 00:28:43.986
Here is the shortcut made visible. Three octets under two fifty-fives, copied straight down, greyed out.

00:28:44.036 --> 00:28:49.206
And one octet — seventy-seven AND one ninety-two — doing all of the work.

00:28:49.256 --> 00:28:57.886
And the one that stings. Ten dot five dot seventy-seven dot one thirty under slash twenty-five gives one twenty-eight.

00:28:57.936 --> 00:29:05.806
Drag to slash twenty-six and the network address does not move. Different fence, same answer — and the block halved underneath it.

00:29:05.856 --> 00:29:12.746
And the far end of the ladder: slash thirty. Four addresses, two of them unusable.

00:29:12.796 --> 00:29:21.746
Open it after the lecture. Type in your own address from your own machine and drag from slash eight to slash thirty. That is what it is for.

00:29:25.853 --> 00:29:30.083
Checkpoint three. Stop the video.

00:29:30.133 --> 00:29:36.883
One. State the two rules of AND, and say what each one does to an address bit.

00:29:36.933 --> 00:29:45.883
Two. Find the network address of one six seven dot one nine nine dot one seven zero dot eighty-two under slash twenty-four, and then under slash twenty-seven. Why do they differ?

00:29:49.243 --> 00:29:55.213
Three. Why is the network address always the lowest address in its block?

00:29:55.263 --> 00:29:56.203
Answers.

00:29:56.253 --> 00:30:05.203
One. One AND x is x, so the address bit survives. Zero AND x is zero, so the address bit is erased. Ones keep the network part; zeros erase the host part.

00:30:09.063 --> 00:30:18.013
Two. Slash twenty-four gives one six seven dot one nine nine dot one seven zero dot zero. Slash twenty-seven gives dot sixty-four. The fence moved three bits right, so three more bits of the last octet became network and were kept.

00:30:24.743 --> 00:30:33.693
Three. Because every host bit is set to zero, and zero is the smallest value those bits can hold. Nothing in the block can be lower.

00:30:37.753 --> 00:30:41.603
Section four. Convert one octet. Never four.

00:30:41.653 --> 00:30:47.503
The exam sets forty-second questions. The full thirty-two-bit route takes four minutes.

00:30:47.553 --> 00:30:55.137
The shortcut is not cheating — it is knowing what two fifty-five means.

00:30:55.187 --> 00:31:04.137
First practice. One nine two dot one six eight dot ten dot seventy-seven, with two five five dot two five five dot two five five dot one nine two.

00:31:04.957 --> 00:31:13.907
Before you write anything, ask the question that saves you three minutes: how many octets actually need converting?

00:31:14.377 --> 00:31:17.017
One. Only one.

00:31:17.067 --> 00:31:26.017
A two five five octet is eight ones, so the address copies through. One nine two stays one nine two. One six eight stays one six eight. Ten stays ten.

00:31:28.197 --> 00:31:30.897
Write them down and move on.

00:31:30.947 --> 00:31:39.587
A zero octet zeroes out. There are none here — but when there are, you write zero and you do not think about it.

00:31:39.637 --> 00:31:43.297
So the only work is seventy-seven AND one ninety-two.

00:31:43.347 --> 00:31:52.297
Seventy-seven is zero one zero zero one one zero one. Keep the top two bits: zero one zero zero zero zero zero zero. Sixty-four.

00:31:54.307 --> 00:32:01.047
Network: one nine two dot one six eight dot ten dot sixty-four, slash twenty-six.

00:32:01.097 --> 00:32:10.047
Three octets copied, one converted, one answer. Under thirty seconds once the ladder is automatic.

00:32:11.353 --> 00:32:16.403
Let me state the rule underneath that, because it generalises.

00:32:16.453 --> 00:32:22.283
Octets entirely left of the fence are copied. Their mask octet is two fifty-five.

00:32:22.333 --> 00:32:29.573
Copying is not a calculation, and treating it as one is exactly where the four minutes go.

00:32:29.623 --> 00:32:38.573
Octets entirely right of the fence become zero. Their mask octet is zero. Write zero. There is nothing to compute.

00:32:38.953 --> 00:32:43.823
And exactly one octet can be in between — the one containing bit n.

00:32:43.873 --> 00:32:49.553
That octet, and only that octet, gets written in binary and ANDed by hand.

00:32:49.603 --> 00:32:58.553
And if n is a multiple of eight, there is no in-between octet at all, and the whole question is copying. Those are your free marks; take them quickly.

00:33:02.287 --> 00:33:09.857
Second practice, and this one is an ambush. One seven two dot sixteen dot one nine nine dot forty-four, slash twenty.

00:33:09.907 --> 00:33:15.687
Before I show you anything: say the network address out loud.

00:33:15.737 --> 00:33:22.567
Most people say one seven two dot sixteen dot one nine nine dot zero. And it is wrong.

00:33:22.617 --> 00:33:29.687
Twenty is eight plus eight plus four. So the fence is four bits into the third octet — not the fourth.

00:33:29.737 --> 00:33:36.067
The third octet is the one in between. That is where the work is.

00:33:36.117 --> 00:33:45.067
One nine nine is one one zero zero zero one one one. The mask octet is two forty, which is one one one one zero zero zero zero.

00:33:46.397 --> 00:33:50.917
AND them: one one zero zero zero zero zero zero. One ninety-two.

00:33:50.967 --> 00:33:57.367
And the fourth octet is entirely right of the fence, so forty-four becomes zero.

00:33:57.417 --> 00:34:01.227
One seven two dot sixteen dot one nine two dot zero, slash twenty.

00:34:01.277 --> 00:34:09.347
The one nine nine was never fully yours. Only its top four bits were; the rest belonged to the host part.

00:34:09.397 --> 00:34:18.347
Decimal intuition dies at mid-octet boundaries. When n is not a multiple of eight, you drop to binary in the boundary octet. No exceptions.

00:34:22.505 --> 00:34:27.535
Four rows now, and they should come out like multiplication tables.

00:34:27.585 --> 00:34:36.535
Slash twenty-four. Two five five dot two five five dot two five five dot zero. Twenty-four ones, eight host bits, so two to the eight — two hundred and fifty-six addresses.

00:34:40.055 --> 00:34:48.415
The whole last octet is host. This is the comfortable one, and the only one your decimal intuition survives.

00:34:48.465 --> 00:34:57.415
Slash twenty-five. One more one — one twenty-eight. Seven host bits, so a hundred and twenty-eight addresses. Exactly half of a slash twenty-four.

00:34:58.645 --> 00:35:06.175
One bit borrowed, and the block halves. That is the trade, every time, with no exceptions.

00:35:06.225 --> 00:35:12.175
Slash twenty-six. One ninety-two. Six host bits: sixty-four addresses.

00:35:12.225 --> 00:35:20.355
And this is the mask from the top corner of your page — a quarter of a slash twenty-four, and a common small-office block.

00:35:20.405 --> 00:35:29.355
Slash twenty-seven. Two twenty-four. Five host bits: thirty-two addresses. Getting tight — and Forouzan's worked example lives here.

00:35:31.025 --> 00:35:37.525
Now read only the last column. Two fifty-six, one twenty-eight, sixty-four, thirty-two.

00:35:37.575 --> 00:35:46.065
Each step right adds one 1 to the mask and halves the block. One more network bit always costs exactly half the addresses.

00:35:46.115 --> 00:35:53.921
That halving column is next session's entire lecture, and the week after's too.

00:35:53.971 --> 00:36:02.921
One more drill, and it has a sting in it. Ten dot five dot seventy-seven dot one thirty, first under slash twenty-five, then under slash twenty-six.

00:36:05.471 --> 00:36:14.121
Under slash twenty-five the mask octet is one twenty-eight. One thirty is one zero zero zero zero zero one zero.

00:36:14.171 --> 00:36:23.121
Keep the top bit only: one zero zero zero zero zero zero zero. A hundred and twenty-eight. Network: ten dot five dot seventy-seven dot one twenty-eight.

00:36:26.111 --> 00:36:31.971
Under slash twenty-six the mask octet is one ninety-two. Keep the top two bits.

00:36:32.021 --> 00:36:40.971
One zero zero zero zero zero one zero becomes one zero zero zero zero zero zero zero — which is still a hundred and twenty-eight.

00:36:41.881 --> 00:36:47.001
The same answer, twice. Different boundaries, identical network address.

00:36:47.051 --> 00:36:50.001
The reason is in the top bit.

00:36:50.051 --> 00:36:56.651
One thirty sits in the upper half of the octet either way, and both masks keep the bit that says so.

00:36:56.701 --> 00:37:02.291
The mask decides how much street name there is. It does not move the house.

00:37:02.341 --> 00:37:11.291
But be careful: the network addresses match, and the blocks do not. Slash twenty-five holds a hundred and twenty-eight addresses; slash twenty-six holds sixty-four. Same first address, very different street.

00:37:18.718 --> 00:37:27.138
And here is where you turn all of that into a reflex. Ten questions, four options each, marked the moment you answer.

00:37:27.188 --> 00:37:34.268
It opens with a question and four candidate answers. Write slash twenty-six as a dotted-decimal mask.

00:37:34.318 --> 00:37:41.728
The ladder is on screen the whole time. It is meant to be in front of you until it is inside you.

00:37:41.778 --> 00:37:47.238
Correct, and marked green — with the reason underneath, not just a tick.

00:37:47.288 --> 00:37:56.238
Three full octets, then two ones, and two ones is one ninety-two. That reason line is the thing you are actually practising.

00:37:56.298 --> 00:38:02.838
Next question, and the counters move: asked, correct, and the streak.

00:38:02.888 --> 00:38:08.268
The streak is the number that matters. Anyone can get one right.

00:38:08.318 --> 00:38:13.978
And here is a wrong answer, marked red, with the specific mistake named.

00:38:14.028 --> 00:38:20.718
The streak resets to zero. That is deliberate, and it is the only harsh thing in the whole tool.

00:38:20.768 --> 00:38:26.278
The bank mixes in legality questions. Is two five five dot two five five dot fifteen dot zero a mask?

00:38:26.328 --> 00:38:34.788
No — fifteen is zero zero zero zero one one one one, and the ones are on the wrong side. Shape, not value.

00:38:34.838 --> 00:38:43.398
And block sizes, because you will need them next session. Slash twenty-six leaves six host bits, so sixty-four addresses.

00:38:43.448 --> 00:38:46.628
Three question types, one skill.

00:38:46.678 --> 00:38:51.948
And that is the target: ten in a row. Not ten correct — ten consecutive.

00:38:51.998 --> 00:39:00.948
Do that once before the next session and the arithmetic of Session eleven will feel like reading rather than solving.

00:39:02.019 --> 00:39:08.679
Checkpoint four, and this one is the exam rehearsal. Stop the video.

00:39:08.729 --> 00:39:17.679
One. Find the network address of two hundred dot ten dot five dot sixty-eight, slash twenty-six — converting exactly one octet.

00:39:23.759 --> 00:39:32.709
Two. Find the network address of one eighty dot eight dot seventeen dot nine, slash twenty-two. Which octet is the boundary octet?

00:39:37.019 --> 00:39:44.929
Three. Under slash twenty-six, how many addresses are in the block — and how many under slash twenty-seven?

00:39:44.979 --> 00:39:45.779
Answers.

00:39:45.829 --> 00:39:54.779
One. Sixty-eight is zero one zero zero zero one zero zero. The mask octet is one ninety-two, so keep the top two bits: zero one zero zero zero zero zero zero — sixty-four. Two hundred dot ten dot five dot sixty-four, slash twenty-six.

00:39:58.729 --> 00:40:07.679
Two. The third octet. Twenty-two is eight plus eight plus six, so the fence is six bits in. Seventeen is zero zero zero one zero zero zero one, the mask octet is two fifty-two, and the AND gives zero zero zero one zero zero zero zero — sixteen. One eighty dot eight dot sixteen dot zero, slash twenty-two.

00:40:20.219 --> 00:40:29.169
Three. Slash twenty-six leaves six host bits: sixty-four addresses. Slash twenty-seven leaves five: thirty-two. Every extra network bit halves the block.

00:40:35.697 --> 00:40:39.917
Five ways to lose marks on this topic.

00:40:39.967 --> 00:40:48.917
Wrong: one seven two dot sixteen dot one nine nine dot forty-four slash twenty is on network one seven two dot sixteen dot one nine nine dot zero.

00:40:50.987 --> 00:40:59.937
Right: one seven two dot sixteen dot one nine two dot zero. Twenty is not a multiple of eight, so the fence cuts the third octet.

00:41:00.927 --> 00:41:09.867
Wrong: two five five dot two five five dot two fifty dot zero is a mask; two fifty is close enough to two forty-eight.

00:41:09.917 --> 00:41:18.867
Right: it is not a mask at all. Two fifty is one one one one one zero one zero, and the ones are broken apart.

00:41:19.197 --> 00:41:23.867
Wrong: I will convert all four octets to binary, to be safe.

00:41:23.917 --> 00:41:32.867
Right: convert one. A two fifty-five octet copies through and a zero octet zeroes out. The full route takes four minutes you will not be given.

00:41:35.197 --> 00:41:44.147
Wrong: the network address of one six seven dot one nine nine dot one seven zero dot eighty-two is one six seven dot one nine nine dot one seven zero dot zero.

00:41:45.647 --> 00:41:54.597
Right: not without n. Under slash twenty-four it is dot zero; under slash twenty-seven it is dot sixty-four. An address without a prefix length defines nothing.

00:41:58.297 --> 00:42:02.367
And wrong: a mask is a special address the network owns.

00:42:02.417 --> 00:42:11.367
Right: a mask is a boundary. It names nothing, belongs to nobody, and exists so that AND can find the network part in one instruction.

00:42:14.847 --> 00:42:17.557
Now go back to the top corner of your page.

00:42:17.607 --> 00:42:25.777
Two five five dot two five five dot two five five dot one nine two. Untouched since minute one. Read it.

00:42:25.827 --> 00:42:31.277
Twenty-six ones, six zeros. So it is slash twenty-six in a costume.

00:42:31.327 --> 00:42:36.517
That much you could have done by minute twenty, and that is the easy half.

00:42:36.567 --> 00:42:38.347
What it hides is the host.

00:42:38.397 --> 00:42:43.957
AND any address with it and the last six bits vanish. What survives is the street name.

00:42:44.007 --> 00:42:52.217
The router does not care which house you are. It delivers to streets, and the mask is how it un-sees the house number.

00:42:52.267 --> 00:42:59.657
And the second half of the question, the one nobody thinks to ask: why thirty-two bits instead of just writing twenty-six?

00:42:59.707 --> 00:43:06.787
Because AND is free and arithmetic is not. One instruction per packet, in every router on the path.

00:43:06.837 --> 00:43:10.197
The mask is a boundary, formatted for hardware.

00:43:10.247 --> 00:43:16.864
Cross the number out and write "street only" next to it.

00:43:16.914 --> 00:43:20.034
Four things you should be able to do now.

00:43:20.084 --> 00:43:29.034
Convert between slash and dotted mask in both directions, in your head. Divide by eight, look up the remainder on the ladder. One division, one lookup.

00:43:31.324 --> 00:43:40.274
Reject an invalid mask on sight, and say why. Nine values per octet, and one unbroken run of ones across all thirty-two bits.

00:43:41.934 --> 00:43:50.884
Find a network address by converting exactly one octet. Copy the two fifty-fives, zero the zeros, and AND the single octet the fence cuts.

00:43:52.994 --> 00:44:01.944
And survive a mid-octet boundary without guessing. When n is not a multiple of eight, you drop to binary in the boundary octet — always.

00:44:02.384 --> 00:44:11.334
Before next session: re-read the "extracting information" part of eighteen point four, and get ten consecutive correct on the drill.

00:44:13.778 --> 00:44:15.348
That is Session ten.

00:44:15.398 --> 00:44:21.778
A mask is not a magic number. It is a boundary — where the ones stop is where the network part stops.

00:44:21.828 --> 00:44:26.548
Nine values in a mask octet, one unbroken run of ones, and no tenth possibility.

00:44:26.598 --> 00:44:34.438
Convert one octet, never four. And when n is not a multiple of eight, drop to binary and do not guess.

00:44:34.488 --> 00:44:41.468
If this hour felt repetitive, it worked. Everything in the next six sessions is this hour, applied.

00:44:41.518 --> 00:44:50.468
Before the next class: the ladder, chanted until it is annoying. Ten in a row on the drill. And Forouzan eighteen point four on extracting information.

00:44:52.698 --> 00:44:59.938
Next session: one line from an ISP, four facts hidden inside it, and sixty seconds to extract all four.

00:44:59.988 --> 00:45:08.468
Remember two zero five dot sixteen dot thirty-seven dot thirty-nine, slash twenty-eight. It comes back carrying marks.

00:45:08.518 --> 00:45:13.388
I will see you there.
