1
1

00:00:00,300  -->  00:00:02,620
<v ->Data Transfer Over Networks.</v>
2

2

00:00:02,620  -->  00:00:04,700
So, when we transfer data over our networks,
3

3

00:00:04,700  -->  00:00:08,100
we have to find a way to tell the data where it's going to go.
4

4

00:00:08,100  -->  00:00:11,320
Now, we use IP addresses to get data to the right system.
5

5

00:00:11,320  -->  00:00:12,920
But how does it know what application
6

6

00:00:12,920  -->  00:00:15,310
is listening on that particular system?
7

7

00:00:15,310  -->  00:00:17,490
Well, that's where a port comes in.
8

8

00:00:17,490  -->  00:00:19,040
I like to think about it this way,
9

9

00:00:19,040  -->  00:00:20,580
if I give you my street address,
10

10

00:00:20,580  -->  00:00:22,260
that's like my IP address.
11

11

00:00:22,260  -->  00:00:25,050
You can find my exact house within my neighborhood.
12

12

00:00:25,050  -->  00:00:27,210
But, how are you going to find my bedroom,
13

13

00:00:27,210  -->  00:00:29,260
my home office, or my living room.
14

14

00:00:29,260  -->  00:00:31,750
Each of those rooms is going to serve a different function,
15

15

00:00:31,750  -->  00:00:34,310
like sleeping, working, or relaxing.
16

16

00:00:34,310  -->  00:00:36,850
Well, this is where a port is going to come in.
17

17

00:00:36,850  -->  00:00:39,120
A Port is a logical opening in a computer
18

18

00:00:39,120  -->  00:00:41,230
that represents a service or application
19

19

00:00:41,230  -->  00:00:43,490
that's listening and waiting for traffic.
20

20

00:00:43,490  -->  00:00:45,250
So, in my house example,
21

21

00:00:45,250  -->  00:00:48,350
maybe I gave you my address as 123 Main Street,
22

22

00:00:48,350  -->  00:00:49,730
room number two.
23

23

00:00:49,730  -->  00:00:52,770
This tells you to go to the house and enter the second room,
24

24

00:00:52,770  -->  00:00:56,030
which is my home office where I might be working at.
25

25

00:00:56,030  -->  00:00:58,690
Now, in computer networks, our ports are going to be numbered
26

26

00:00:58,690  -->  00:01:02,910
from zero all the way up to 65,535.
27

27

00:01:02,910  -->  00:01:04,700
That is a lot of ports.
28

28

00:01:04,700  -->  00:01:07,370
So, even though you only have one IP on your machine,
29

29

00:01:07,370  -->  00:01:10,370
you can have over 65,000 different openings
30

30

00:01:10,370  -->  00:01:12,170
for you to be able to run different services
31

31

00:01:12,170  -->  00:01:13,870
and applications on.
32

32

00:01:13,870  -->  00:01:16,530
Now, that large number of ports is actually broken up
33

33

00:01:16,530  -->  00:01:18,320
into two distinct groups.
34

34

00:01:18,320  -->  00:01:21,400
The first is called the Well-known and Reserved Ports.
35

35

00:01:21,400  -->  00:01:22,710
These are the ports that are numbered
36

36

00:01:22,710  -->  00:01:25,360
from zero through a 1023.
37

37

00:01:25,360  -->  00:01:27,710
These include things like the File Transfer Protocol
38

38

00:01:27,710  -->  00:01:30,620
on port 21, Web Browsing on port 80,
39

39

00:01:30,620  -->  00:01:33,480
or the Simple Mail Transfer Protocol on port 25,
40

40

00:01:33,480  -->  00:01:35,150
among other things.
41

41

00:01:35,150  -->  00:01:36,730
Ephemeral Ports, on the other hand,
42

42

00:01:36,730  -->  00:01:38,650
are short-lived temporary ports.
43

43

00:01:38,650  -->  00:01:41,060
And these are open for just a small period of time
44

44

00:01:41,060  -->  00:01:43,320
from a predefined range of ports.
45

45

00:01:43,320  -->  00:01:46,390
These ports can exist from Port 1024,
46

46

00:01:46,390  -->  00:01:50,100
all the way up to 65,535.
47

47

00:01:50,100  -->  00:01:52,450
For example, as I'm recording this lesson,
48

48

00:01:52,450  -->  00:01:55,720
I record the audio on a device which acts a file server,
49

49

00:01:55,720  -->  00:01:57,400
and it's going to pick a random port
50

50

00:01:57,400  -->  00:01:59,730
somewhere around port 60,000.
51

51

00:01:59,730  -->  00:02:02,430
Now, when I want to download the audio file from the device,
52

52

00:02:02,430  -->  00:02:04,440
I'm going to use a web browser on my computer
53

53

00:02:04,440  -->  00:02:07,280
to access it and download that audio file.
54

54

00:02:07,280  -->  00:02:09,930
When I do that, what happened is that I just opened up
55

55

00:02:09,930  -->  00:02:12,600
a port on the device for as long as it's needed
56

56

00:02:12,600  -->  00:02:14,280
in order to download that file
57

57

00:02:14,280  -->  00:02:16,160
and then the port is going to close up again,
58

58

00:02:16,160  -->  00:02:17,800
just that quickly.
59

59

00:02:17,800  -->  00:02:20,510
Now, data transfer occurs using these IP addresses
60

60

00:02:20,510  -->  00:02:21,370
in these ports.
61

61

00:02:21,370  -->  00:02:24,510
So, what does all this look like inside the real world?
62

62

00:02:24,510  -->  00:02:27,170
Well, as you can see here, I have a Client on the left
63

63

00:02:27,170  -->  00:02:28,730
and a Website on the right.
64

64

00:02:28,730  -->  00:02:33,730
The Client is at the address 192.168.1.24,
65

65

00:02:33,800  -->  00:02:38,800
and the Website is at 64.82.46.21.
66

66

00:02:39,190  -->  00:02:41,980
So, for the client to make a request to this website,
67

67

00:02:41,980  -->  00:02:43,940
it's going to come from the source IP,
68

68

00:02:43,940  -->  00:02:46,380
that 192 address, and a port,
69

69

00:02:46,380  -->  00:02:48,370
just some random high port that it's going to pick
70

70

00:02:48,370  -->  00:02:50,090
from the Ephemeral port range.
71

71

00:02:50,090  -->  00:02:54,750
Now, in this case, it shows port number 49,163,
72

72

00:02:54,750  -->  00:02:57,030
but it could have been any Ephemeral port.
73

73

00:02:57,030  -->  00:02:58,970
Now, we're going to take that data
74

74

00:02:58,970  -->  00:03:01,680
and we're going to send it to the destination of the website,
75

75

00:03:01,680  -->  00:03:03,710
which in this case is going to be the IP address
76

76

00:03:03,710  -->  00:03:07,140
of 64. something that you see here on the web server.
77

77

00:03:07,140  -->  00:03:09,700
This is going to act as our destination IP.
78

78

00:03:09,700  -->  00:03:12,330
And what port do you think it's going to go to?
79

79

00:03:12,330  -->  00:03:14,760
Well, it's going to use the default port for websites,
80

80

00:03:14,760  -->  00:03:16,140
which is Port 80.
81

81

00:03:16,140  -->  00:03:17,810
Now, the website, on the other hand
82

82

00:03:17,810  -->  00:03:19,310
is going to reverse this process.
83

83

00:03:19,310  -->  00:03:21,170
And it's going to go from its source IP
84

84

00:03:21,170  -->  00:03:23,580
and its own port 80 back to the client
85

85

00:03:23,580  -->  00:03:28,310
on its random high port, which was port 49,163.
86

86

00:03:28,310  -->  00:03:30,560
So, you can see how this communication happens
87

87

00:03:30,560  -->  00:03:31,940
to establish this session.
88

88

00:03:31,940  -->  00:03:34,080
And then, they can communicate back and forth
89

89

00:03:34,080  -->  00:03:37,750
between the two servers and the client over these two ports.
90

90

00:03:37,750  -->  00:03:39,900
Whenever we're done transmitting this website,
91

91

00:03:39,900  -->  00:03:42,520
that random high port that was opened on your client,
92

92

00:03:42,520  -->  00:03:44,940
it's going to get closed and another random high port
93

93

00:03:44,940  -->  00:03:47,520
will be opened the next time you need to communicate.
94

94

00:03:47,520  -->  00:03:49,410
But back on the web server,
95

95

00:03:49,410  -->  00:03:52,560
port 80 is going to sit there and always remain open
96

96

00:03:52,560  -->  00:03:54,700
ready to serve requests from anybody
97

97

00:03:54,700  -->  00:03:57,140
who wants to communicate with that website.
98

98

00:03:57,140  -->  00:03:59,960
So, when we send the information across the network,
99

99

00:03:59,960  -->  00:04:02,730
we're doing this as an IPv4 packet.
100

100

00:04:02,730  -->  00:04:06,200
Now, IP version four packets consist of a source address,
101

101

00:04:06,200  -->  00:04:08,010
that's the IP address of the sender,
102

102

00:04:08,010  -->  00:04:11,100
a destination address, the IP address of the receiver,
103

103

00:04:11,100  -->  00:04:14,340
the IP flags, which is going to allow the packet fragmentation
104

104

00:04:14,340  -->  00:04:15,740
other special things to occur,
105

105

00:04:15,740  -->  00:04:18,210
and the protocol, which is whether we're going to communicate
106

106

00:04:18,210  -->  00:04:20,730
using TCP or UDP.
107

107

00:04:20,730  -->  00:04:23,450
All of those things are going to make up this packet header
108

108

00:04:23,450  -->  00:04:25,700
and you can see it shown here on the screen.
109

109

00:04:25,700  -->  00:04:27,730
Now, many times students asked me
110

110

00:04:27,730  -->  00:04:30,510
if they have to memorize this packet header for the exam.
111

111

00:04:30,510  -->  00:04:33,660
Well, the answer is no, no, no, no, no, no.
112

112

00:04:33,660  -->  00:04:35,140
You don't have to worry about it,
113

113

00:04:35,140  -->  00:04:37,500
because no one is going to ask you to draw out
114

114

00:04:37,500  -->  00:04:39,750
or diagram a packet for the exam.
115

115

00:04:39,750  -->  00:04:42,540
That said, I do want you to understand that your header
116

116

00:04:42,540  -->  00:04:45,010
contains a couple of key pieces of information.
117

117

00:04:45,010  -->  00:04:47,290
Things like your source and destination IP,
118

118

00:04:47,290  -->  00:04:49,220
as well as the ports and the protocols
119

119

00:04:49,220  -->  00:04:50,550
and things of that nature.
120

120

00:04:50,550  -->  00:04:53,680
This tells your packet where it needs to get routed to.
121

121

00:04:53,680  -->  00:04:56,810
Now, back when we talked about TCP and UDP,
122

122

00:04:56,810  -->  00:05:00,330
we talked about the fact that TCP had a lot more overhead.
123

123

00:05:00,330  -->  00:05:01,940
But, what does that really look like
124

124

00:05:01,940  -->  00:05:03,480
inside of these packets?
125

125

00:05:03,480  -->  00:05:05,610
Well, that's what I have here on the screen.
126

126

00:05:05,610  -->  00:05:08,000
On the top, you can see the TCP header,
127

127

00:05:08,000  -->  00:05:09,600
which is 20 bytes in length.
128

128

00:05:09,600  -->  00:05:11,510
And you can see some things that it contains,
129

129

00:05:11,510  -->  00:05:13,900
like the Source Port and the Destination Port,
130

130

00:05:13,900  -->  00:05:16,070
the Sequence Number, the Acknowledgement Number,
131

131

00:05:16,070  -->  00:05:18,030
and then a bunch of other flags.
132

132

00:05:18,030  -->  00:05:20,130
All of that with the Checksum and the Pointers,
133

133

00:05:20,130  -->  00:05:22,130
it all adds this overall length,
134

134

00:05:22,130  -->  00:05:24,760
making it a pretty bulky protocol.
135

135

00:05:24,760  -->  00:05:28,350
Now, we can compare this TCP header with a UDP header
136

136

00:05:28,350  -->  00:05:29,930
that's shown here on the bottom.
137

137

00:05:29,930  -->  00:05:31,870
It only has four pieces of information.
138

138

00:05:31,870  -->  00:05:34,370
It has a Source Port, a Destination Port,
139

139

00:05:34,370  -->  00:05:36,510
the length of the packet and the Checksum.
140

140

00:05:36,510  -->  00:05:39,010
That's it, and it's only eight bytes long.
141

141

00:05:39,010  -->  00:05:40,950
So, you can see there's a lot less data there
142

142

00:05:40,950  -->  00:05:43,380
in that UDP header because there's less
143

143

00:05:43,380  -->  00:05:44,410
that needs to be contained.
144

144

00:05:44,410  -->  00:05:46,500
And so, it allows us to have a faster,
145

145

00:05:46,500  -->  00:05:48,090
more efficient protocol.
146

146

00:05:48,090  -->  00:05:50,040
Again, you don't need to memorize these headers
147

147

00:05:50,040  -->  00:05:50,873
for the exam.
148

148

00:05:50,873  -->  00:05:53,240
But you should remember that TCP is bulkier
149

149

00:05:53,240  -->  00:05:54,660
with its 20-byte header
150

150

00:05:54,660  -->  00:05:57,010
than UDP is with its 8-byte header.
151

151

00:05:57,010  -->  00:06:00,000
Because of this additional overhead in the TCP protocol,
152

152

00:06:00,000  -->  00:06:02,373
UDP is considered much faster.
