1
00:00:00,020 --> 00:00:01,850
The transmission control protocol.

2
00:00:01,880 --> 00:00:08,480
TCP provides a communication service at an intermediate level between an application program and the

3
00:00:08,480 --> 00:00:09,740
Internet protocol.

4
00:00:10,040 --> 00:00:15,200
It provides host to host connectivity at the transport layer of the Internet model.

5
00:00:15,950 --> 00:00:22,940
Dhcp works with the Internet protocol IP, which defines how computers send packets of data to each

6
00:00:22,940 --> 00:00:23,510
other.

7
00:00:23,810 --> 00:00:29,630
Together, TCP and IP are basic rules defining the Internet.

8
00:00:30,750 --> 00:00:37,800
TCP is a connection oriented protocol, which means a connection is established and maintained until

9
00:00:37,800 --> 00:00:41,880
the application programs at each end have finished exchanging messages.

10
00:00:43,070 --> 00:00:49,790
It determines how to fragment application data into packets that networks can deliver, sends packets

11
00:00:49,790 --> 00:00:58,010
to, and accepts packets from the network layer, manages flow control and because it is meant to provide

12
00:00:58,010 --> 00:01:04,760
error free data transmission handles retransmission of dropped or garbled packets, as well as acknowledgement

13
00:01:04,760 --> 00:01:06,620
of all packets that arrive.

14
00:01:07,400 --> 00:01:10,970
Let's see the connection oriented error free communication of TCP.

15
00:01:11,030 --> 00:01:18,740
In an example, when a web server sends an HTML file to a client, it uses the Http protocol to do so.

16
00:01:19,070 --> 00:01:25,460
The Http program layer asks the TCP layer to set up the connection and send the file.

17
00:01:25,790 --> 00:01:32,750
The TCP stack divides the file into packets, numbers them, and then forwards them individually to

18
00:01:32,750 --> 00:01:34,290
the IP layer for delivery.

19
00:01:34,310 --> 00:01:39,860
Although each packet in the transmission will have the same source and destination IP addresses, packets

20
00:01:39,860 --> 00:01:42,320
may be sent along multiple routes.

21
00:01:43,130 --> 00:01:49,760
The TCP program layer in the client computer waits until all of the packets have arrived, then acknowledges

22
00:01:49,760 --> 00:01:53,710
those it receives and asks for the retransmission on any.

23
00:01:53,720 --> 00:02:00,920
It does not based on missing packet numbers, then assembles them into a file and delivers the file

24
00:02:00,950 --> 00:02:02,690
to the receiving application.

25
00:02:03,330 --> 00:02:08,400
The TCP three way handshake is the method used by TCP to set up a connection.

26
00:02:08,639 --> 00:02:09,479
Tcp's.

27
00:02:09,479 --> 00:02:13,500
Three way handshaking technique is often referred to as syn.

28
00:02:13,530 --> 00:02:15,060
Syn ack ack.

29
00:02:15,600 --> 00:02:22,200
Because there are three messages transmitted by TCP to negotiate and start a TCP session between two

30
00:02:22,200 --> 00:02:23,100
computers.

31
00:02:23,810 --> 00:02:30,590
This three way handshake process is also designed so that both ends can initiate a negotiate separate

32
00:02:30,620 --> 00:02:33,500
TCP socket connections at the same time.

33
00:02:33,800 --> 00:02:37,580
That means the connection is full duplex.

34
00:02:37,710 --> 00:02:38,420
Oh, you know what?

35
00:02:38,420 --> 00:02:42,410
We have to take a break at this point and talk about TCP flags.

36
00:02:43,530 --> 00:02:48,420
There are one bit flags in TCP headers which are called TCP flags.

37
00:02:48,450 --> 00:02:55,770
TCP flags are used within TCP packet transfers to indicate a particular connection state or provide

38
00:02:55,770 --> 00:02:57,330
additional information.

39
00:02:58,260 --> 00:02:59,700
Ignoring e.c.e.

40
00:03:01,170 --> 00:03:02,430
And ns flags.

41
00:03:02,430 --> 00:03:06,360
For now, there are basically six TCP flags.

42
00:03:07,440 --> 00:03:14,190
The sin or synchronization flag is used as a first step in establishing a three way handshake between

43
00:03:14,190 --> 00:03:15,150
two hosts.

44
00:03:15,180 --> 00:03:20,310
Only the first packet from both a sender and the receiver should have this flag set.

45
00:03:21,610 --> 00:03:27,490
The ACC flag, which stands for acknowledgement, is used to acknowledge the successful receipt of a

46
00:03:27,490 --> 00:03:28,120
packet.

47
00:03:28,890 --> 00:03:35,280
The rest flag, which stands for reset, gets sent from receiver to the sender when a packet is sent

48
00:03:35,280 --> 00:03:38,100
to a particular host that was not expecting it.

49
00:03:38,940 --> 00:03:44,520
The fin flag, which stands for finished, means there is no more data from the sender.

50
00:03:44,550 --> 00:03:48,270
Therefore, it is used in the last packet sent from the sender.

51
00:03:49,570 --> 00:03:56,950
The flag, which stands for push, is somewhat similar to the ERG flag and tells a receiver to process

52
00:03:56,950 --> 00:04:00,520
these packets as they are received instead of buffering them.

53
00:04:01,650 --> 00:04:08,820
The ERG flag is used to notify the receiver to process the urgent packets before processing all other

54
00:04:08,820 --> 00:04:09,630
packets.

55
00:04:10,420 --> 00:04:17,170
So every legitimate TCP connection begins with a TCP three way handshake, which is used to exchange

56
00:04:17,170 --> 00:04:23,350
sequence numbers so that lost packets can be retransmitted and packets can be placed in the proper order.

57
00:04:24,430 --> 00:04:31,960
If Machine A wants to initiate a connection to machine B, it will start by sending a TCP packet with

58
00:04:31,960 --> 00:04:33,700
a syn control bit set.

59
00:04:34,920 --> 00:04:42,810
This packet will include an initial sequence number, which I'll call here is an A because it comes

60
00:04:42,810 --> 00:04:43,950
from machine A.

61
00:04:44,900 --> 00:04:52,340
Which is 32 bits long and typically generated in a pseudo random fashion by the TCP software on machine.

62
00:04:52,370 --> 00:04:52,520
A.

63
00:04:53,380 --> 00:05:01,660
The act number, another 32 bits and the TCP header is typically set to zero because it is ignored in

64
00:05:01,660 --> 00:05:02,830
this initial sin.

65
00:05:02,970 --> 00:05:09,370
Some operating system variants may make this act number non zero, but either way it's ignored by the

66
00:05:09,370 --> 00:05:10,510
destination machine.

67
00:05:11,690 --> 00:05:17,270
So if the destination port is open, that is there is something listening on that port.

68
00:05:17,570 --> 00:05:25,610
It must respond with a syn-ack packet back, a packet that has both the syn and ack control bits set

69
00:05:25,610 --> 00:05:27,110
at the same time.

70
00:05:28,640 --> 00:05:35,960
This packet will have a sequence number of ESN, be a pseudo random number assigned by Machine B for

71
00:05:35,960 --> 00:05:37,010
this connection.

72
00:05:39,040 --> 00:05:46,330
The Syn-ack packet will have an acknowledgement number of ESN, a plus one indicating that machine B

73
00:05:46,360 --> 00:05:49,060
has acknowledged the syn packet from Machine A.

74
00:05:50,120 --> 00:05:52,790
To complete the three way handshake machine.

75
00:05:52,820 --> 00:05:59,020
A responds with an Ack packet which has a sequence number of is n a plus one.

76
00:05:59,030 --> 00:06:05,150
It's the next packet, so the sequence number has to change from the value in the original sin packet.

77
00:06:06,440 --> 00:06:13,160
The acknowledgement number field is set to isnb plus one, thereby acknowledging the syn-ack packet.

78
00:06:13,190 --> 00:06:13,710
Right.

79
00:06:15,170 --> 00:06:17,510
So we have now exchanged sequence numbers.

80
00:06:17,810 --> 00:06:25,610
All packets going from A to B will have increasing sequence numbers starting at esna plus one going

81
00:06:25,610 --> 00:06:31,730
up my value of one for each byte of data transmitted in the payloads of A to B packets.

82
00:06:32,810 --> 00:06:39,980
Likewise, all responses back from B will have sequence numbers starting at is n, B plus one and going

83
00:06:39,980 --> 00:06:42,230
up for each byte of data from B to A.

84
00:06:42,500 --> 00:06:49,880
In essence, we have two streams of sequence numbers in this series of packets, one from A to B originally

85
00:06:49,880 --> 00:06:56,870
based on Esna and the other from B to A originally based on Is B.

86
00:06:58,250 --> 00:06:58,940
Perfect.

