0% found this document useful (0 votes)
12 views10 pages

Lec-66 TCP Connection Establishment and Connection Termination Transport Layer - en

The document discusses TCP connection establishment through a three-way handshake method, where a client and server communicate to reserve resources for data transmission. It explains the roles of source and destination port numbers, sequence numbers, and flags in establishing a reliable connection. The process ensures that data is transmitted without loss, emphasizing TCP's reliability in client-server communication.

Uploaded by

gekertxertb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views10 pages

Lec-66 TCP Connection Establishment and Connection Termination Transport Layer - en

The document discusses TCP connection establishment through a three-way handshake method, where a client and server communicate to reserve resources for data transmission. It explains the roles of source and destination port numbers, sequence numbers, and flags in establishing a reliable connection. The process ensures that data is transmitted without loss, emphasizing TCP's reliability in client-server communication.

Uploaded by

gekertxertb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 10

WEBVTT

Kind: captions
Language: en

00:00:00.059 --> 00:00:04.057


- Hello friends, welcome to Gate Smashers. The topic is TCP connection
establishment

00:00:04.090 --> 00:00:09.079


- like we saw in the video, whenever we send data through TCP

00:00:10.004 --> 00:00:16.088


- first TCP establishes the connection. We generally call this connection
establishment as three-way hand shaking method

00:00:17.009 --> 00:00:22.010


- we will discuss about 3-way hand shaking method properly in this video, that how
TCP

00:00:22.049 --> 00:00:26.022


- establishes connection. And what values it sends

00:00:26.071 --> 00:00:31.006


- between the sender and receiver. So firstly here we're talking about TCP

00:00:31.033 --> 00:00:36.082


- In TCP, firstly what is the connection establishment

00:00:37.013 --> 00:00:42.023


- if A is establishing connection with B, A is sending it's information to B

00:00:42.048 --> 00:00:50.030


- and it's telling B to reserve some things, means to fix some things like buffer,
CPU

00:00:50.046 --> 00:00:55.048


- bandwidth. Reserve them because after that A will send message to B

00:00:55.065 --> 00:01:04.071


- and B will also send some information to A, it will send information to make
connection, and will tell A to reserve buffer

00:01:04.094 --> 00:01:09.021


- CPU, bandwidth, so that connection establishes properly

00:01:09.029 --> 00:01:15.082


- it just like telephone network. TCP always works like telephone network, like we
talk to someone

00:01:16.006 --> 00:01:20.032


- there is first dial-up. Dial-up is what? It is a connection establishment phase

00:01:20.049 --> 00:01:24.077


- such that once the connection is established, after that my packets

00:01:24.085 --> 00:01:28.090


- means the data is properly sent by two way communication

00:01:29.017 --> 00:01:35.013


- that is called as reliability also. Reliability means there shouldn't be loss of
my packets

00:01:35.025 --> 00:01:40.043


- there shouldn't be data loss. In case there is data loss, then re-transmission
should be there

00:01:40.073 --> 00:01:46.021


- so that's why wherever we need reliability, there we will use TCP only

00:01:46.035 --> 00:01:51.068


- so that's why TCP is majorly used protocol because whenever we need the
reliability

00:01:51.083 --> 00:01:57.089


- whenever we need the 100% guarantee to reach the packet, then definitely we have
to use the TCP

00:01:58.008 --> 00:02:02.007


- so we're talking about TCP connection, here I have a client machine

00:02:02.031 --> 00:02:09.022


- and a server machine. Generally we use TCP at the time of client server
communication, where client machine

00:02:09.030 --> 00:02:17.041


- like my laptop it can work as a client machine, and if I am accessing a service
or web server like Google

00:02:17.049 --> 00:02:19.100


- Google is working like a server

00:02:20.058 --> 00:02:26.016


- and my machine is working like a client. Means, from my machine to some other
machine

00:02:26.050 --> 00:02:34.064


- data is being transmitted. And the 2nd important point that we discussed is that
TCP works in full duplex. Full duplex means

00:02:35.020 --> 00:02:40.058


- client is sending data to the server, and server can also send data to the
client. That is called a

00:02:40.089 --> 00:02:47.026


- full duplex mode. Means if A and B are communicating with each other, then the
communication will be in two way

00:02:48.061 --> 00:02:55.019


- now, here I have two machines client and server. So what is the first point, let
say, from my system

00:02:55.041 --> 00:03:03.028


- I have opened a web browser. I opened the browser, after opening the browser
operating system will assign a port number to me

00:03:03.060 --> 00:03:08.033


- but these port number always aren't from the well known port numbers
00:03:08.046 --> 00:03:14.100
- some ports are registered with IANA. The port number that I'll get

00:03:15.017 --> 00:03:21.014


- that port number is nearly about 50000 to 65000 range

00:03:21.025 --> 00:03:24.031


- and that port number is assigned by operating system

00:03:24.069 --> 00:03:32.087


- now I am transmitting a message from my port number, that is the first message to
establish the connection

00:03:32.097 --> 00:03:37.025


- means it's not transmitting the data, this is not the data. We will transmit the
data afterwards

00:03:37.033 --> 00:03:44.049


- the first packet/segment we're sending, this segment is for connection
establishment

00:03:44.093 --> 00:03:49.037


- so here my machine is active open phase. Active open means,

00:03:49.057 --> 00:03:53.088


- I'm ready, I'm ready to make the connection. First, the client should be ready.

00:03:54.009 --> 00:03:57.071


- Because the servers are running 24×7.

00:03:58.014 --> 00:04:03.064


- Google won't tell you ever to make connection with it. I've to make the
connection first

00:04:03.088 --> 00:04:05.095


- So my machine is active

00:04:06.073 --> 00:04:13.064


- packet will be sent from my machine. The diagram which you can see here, this
diagram is actually a header

00:04:13.076 --> 00:04:19.033


- I discussed about TCP header in last video that what are the values, what are the
uses

00:04:19.049 --> 00:04:23.037


- you can check that video again, it will become properly clear by that

00:04:23.061 --> 00:04:30.089


- otherwise you can pay attention here properly, I'll tell you what are the values
and what are their particular use

00:04:31.011 --> 00:04:36.025


- so first of all I've written here source port number. Source port number of my
machine is A

00:04:36.038 --> 00:04:41.019


- and destination port number is 80. Because whenever we access the web pages
00:04:41.037 --> 00:04:46.087
- web pages are always accessed on 80 number port. So we can write the port number
like 80

00:04:47.009 --> 00:04:50.040


- important point here is sequence number, means

00:04:50.081 --> 00:04:55.084


- as the client sends the message, it will always use a sequence number, means

00:04:56.014 --> 00:05:02.079


- this sequence number is used by it, it's a number, it's always a randomly
generated number, it's never from 0

00:05:03.006 --> 00:05:08.046


- if all the machine starts from 0, then all the machines will use it's sequence
number 0

00:05:08.074 --> 00:05:16.065


- so that's why we use random sequence number here, value of which can be from 0 to
2³² -1

00:05:16.074 --> 00:05:23.025


- which is a very huge number. So here a sender/client sent 9000

00:05:23.043 --> 00:05:29.052


- I generated a simple number randomly and sent it. Along with that, Sync flag

00:05:30.084 --> 00:05:36.045


- made the sync flag value 1. Sync flag means, I want to synchronise with the
server

00:05:36.063 --> 00:05:42.078


- means I want to make a connection with the server. So I made the sync flag 1

00:05:42.090 --> 00:05:48.038


- this is what, a flag width, value of which is of 1 bit. It's value can be either
0 or 1

00:05:48.044 --> 00:05:51.012


- so I'm sending it after activating

00:05:52.002 --> 00:05:57.032


- along with that, window size, window size means 12000, 12000 is what? It is a
byte

00:05:57.059 --> 00:06:03.075


- Means client is sending the size of it's window, that the size of my window is

00:06:04.002 --> 00:06:10.025


- 12000 byte. This is a very important point here that why we use window size? For
flow control

00:06:10.052 --> 00:06:17.012


- and the sender/client sent the size of it's window, means, the size of it's
buffer

00:06:17.026 --> 00:06:23.055


- that my buffer can accept maximum 12000 byte
00:06:23.089 --> 00:06:31.013
- that is the client's receiving end. Means, client told it's receiving capacity by
itself

00:06:31.040 --> 00:06:35.034


- it advertised it itself that don't send me data more than this

00:06:36.001 --> 00:06:40.091


- other than that, options and padding. The last option we've in options and
padding

00:06:41.015 --> 00:06:46.005


- in that it told MSS. MSS means, Maximum Segment Size

00:06:46.013 --> 00:06:51.033


- maximum segment size is 1200 byte. Now what is a maximum segment size?

00:06:51.061 --> 00:06:59.069


- whenever we use a connection, then at data link layer, means, whenever my
connection will go down from TCP to network layer

00:06:59.099 --> 00:07:04.027


- and then to data link layer. So at data link layer we generally use Ethernet.

00:07:04.055 --> 00:07:11.061


- and maximum segments in Ethernet, means, size of one packet should be less than
1500 byte

00:07:12.070 --> 00:07:15.096


- if you mentioned your window size as 12000 byte

00:07:16.046 --> 00:07:23.020


- it is simple, like I have said that I can accept data of maximum 12000 byte

00:07:23.094 --> 00:07:28.024


- then it may be possible that server sends only one segment of 12000 byte

00:07:28.090 --> 00:07:37.053


- but my network doesn't support only one packet of 12000 byte

00:07:37.061 --> 00:07:46.051


- it can support small packets, together which makes 12000, but it is not necessary
that my only one packet is of 12000 byte

00:07:46.066 --> 00:07:50.100


- that means my maximum capacity is of 12000 byte

00:07:51.041 --> 00:07:58.025


- but size of one packet is 1200, so send me 10 packets of 1200

00:07:58.046 --> 00:08:07.001


- so that my window will be full. In this way client is telling the server
indirectly that it should be of 1200 byte

00:08:07.018 --> 00:08:14.048


- if one packet is of 1200 byte and if you will send 10 packet from that type then
my window will be full
00:08:14.056 --> 00:08:17.096
- my window means my buffer will be full

00:08:19.032 --> 00:08:27.044


- now this message/full information is sent by client to the server. Server is on
passive open mode. Means,

00:08:27.058 --> 00:08:30.061


- server is running 24×7. It's open

00:08:30.073 --> 00:08:34.053


- but it is in passive mode, because client has just sent a request

00:08:34.090 --> 00:08:40.070


- server will store this all information at its own end, and then it will generate
a packet

00:08:41.006 --> 00:08:43.069


- it will also generate a acknowledgement

00:08:44.010 --> 00:08:49.020


- that's why we call this, when first information is sent, we call it sync

00:08:49.029 --> 00:08:52.072


- because we're trying to just synchronise with the server

00:08:52.087 --> 00:08:56.027


- but the server is sending us sync+acknowledgement

00:08:56.046 --> 00:09:02.039


- because it's full duplex. Server will also send it's information to the client,
dad this is my capacity

00:09:02.057 --> 00:09:07.013


- this is the size of my MSS + acknowledgement, that your packet has been received

00:09:07.026 --> 00:09:12.036


- I am sending you the acknowledgement also and my information along with that

00:09:12.044 --> 00:09:20.065


- now the server which was in passive mode will come in active mode. But before
coming in active mode it sent it's information

00:09:20.084 --> 00:09:27.021


- that ok my port number is 80, and this is your port number, and sequence number
is 3000, means

00:09:27.073 --> 00:09:35.041


- now the server which is sending data is using sequence number 3000

00:09:35.048 --> 00:09:41.032


- means now whenever the server will send data, it will send after 3000

00:09:41.042 --> 00:09:47.046


- so that client gets to know that my data will now start coming from 3000

00:09:47.053 --> 00:09:53.091


- means, these all are bytes. Because it is a byte streaming protocol. Every byte
here is counted as a number
00:09:54.042 --> 00:10:01.064
- so the server also told it's sequence number, it is also a randomly generated
sequence number and acknowledgement

00:10:02.053 --> 00:10:07.022


- we've already discussed acknowledgement. It is always x+1, means

00:10:07.037 --> 00:10:10.038


- if client has sent 9000

00:10:10.078 --> 00:10:16.034


- then receiver/server will send 9000+1, that is 9001

00:10:16.046 --> 00:10:21.057


- which is the next expected byte, because this 9000

00:10:21.076 --> 00:10:27.005


- this number 9000 has been used. It won't be used again for the data

00:10:27.022 --> 00:10:32.013


- because we have used 1 byte just to synchronise

00:10:32.049 --> 00:10:37.027


- now, the service sending that I have received your 9000

00:10:37.051 --> 00:10:42.020


- now start me sending from 9001

00:10:42.057 --> 00:10:46.028


- along with that it made the acknowledgement flag to 1, means

00:10:46.052 --> 00:10:49.030


- now my packet is also doing acknowledgement

00:10:49.059 --> 00:10:50.095


- this is the acknowledgement

00:10:51.029 --> 00:10:58.044


- I'm acknowledging that I have received your 9000, now start me sending from 9001

00:10:58.073 --> 00:11:03.071


- along with that, sync, sync means, server also wants to receive some data

00:11:03.098 --> 00:11:07.050


- Server also wants to get some data share some data

00:11:07.066 --> 00:11:12.047


- it's working in full duplex mode, so server also made it's sync flag to 1

00:11:12.071 --> 00:11:18.052


- along with that it also advertised it's window size. Means, it's buffer

00:11:18.061 --> 00:11:23.035


- can accept maximum 18000 byte

00:11:24.031 --> 00:11:28.009


- but MSS, MSS is again important, because
00:11:28.029 --> 00:11:37.004
- the network at it's end, that network/buffer accept maximum of 18000 byte

00:11:37.033 --> 00:11:43.065


- but in that network the size of one packet should be, it mentioned it as 600 byte

00:11:43.077 --> 00:11:50.042


- so that means simply calculate, that 18000÷600, so which is

00:11:51.034 --> 00:11:51.534


- 30

00:11:52.041 --> 00:12:02.063


- means server is telling the client that you can send me up to a maximum of 18000
byte, not more than that otherwise there won't be flow control

00:12:02.079 --> 00:12:07.025


- for flow control server said that 18000 byte should be maximum

00:12:07.039 --> 00:12:10.059


- but don't send one packet of 18000 byte

00:12:10.093 --> 00:12:18.007


- you can send maximum 30 packets of 600 byte, then my window will be full

00:12:18.018 --> 00:12:25.057


- it did it's advertisement and also told it's maximum segment size i.e.600 byte

00:12:26.001 --> 00:12:30.052


- this packet will be received by the client. So it is two way

00:12:30.064 --> 00:12:37.094


- but this is a three way communication. Now the client will again send the data
and sequence number used here is

00:12:38.044 --> 00:12:41.007


- 9001. 9001 means,

00:12:42.002 --> 00:12:49.006


- I would like to tell you a point here, you can find this in many books or in some
online material you can find 9000 here

00:12:49.037 --> 00:12:56.011


- because the sequence number we're writing here, we already wasted a sequence
number here

00:12:56.031 --> 00:13:02.002


- means it is not a kind of waste, but we have used one sequence number just to
make the connection

00:13:02.065 --> 00:13:07.093


- we used that sequence number. So you can also write 9000 here

00:13:08.020 --> 00:13:16.015


- but I am not writing 9000 here because the server is expecting 9001

00:13:16.038 --> 00:13:23.008


- then why should I write 9000. When I was expecting 9001 then definitely I will
write 9001
00:13:23.054 --> 00:13:29.025
- but important point here is, this 9001 sequence number isn't wasted

00:13:29.059 --> 00:13:35.030


- when you will start transmitting data after that, this number can be re-used

00:13:35.083 --> 00:13:40.009


- you can use this sequence number again for data transfer

00:13:40.021 --> 00:13:43.058


- but you can't use this, it's already utilised

00:13:43.078 --> 00:13:48.063


- so that's why I have written 9001 here, because when server is expecting 9001

00:13:48.082 --> 00:13:52.095


- then why should I write 9000. So it sent 9001

00:13:53.056 --> 00:13:58.034


- along with that there's acknowledgement. Server sent it's sequence number 3001

00:13:58.062 --> 00:14:03.028


- 3000, sorry. So the client is sending 3001 here

00:14:03.042 --> 00:14:12.017


- means your 3000 sequence number has been accepted. Now, start transmitting data
from 3001

00:14:12.089 --> 00:14:16.053


- that is a next expected byte. Along with that ACK

00:14:17.005 --> 00:14:21.021


- it made acknowledgement flag to 1 because it is again a acknowledgement

00:14:21.036 --> 00:14:28.073


- it is acknowledgement what is received from the server. So if you see this in
generic form, first is synchronise

00:14:29.094 --> 00:14:34.089


- packet is sent then after, synchronise+acknowledgement, both the things

00:14:35.008 --> 00:14:39.032


- synchronisation is already there and plus acknowledgement is also there

00:14:39.049 --> 00:14:42.045


- and in 3rd we only sent acknowledgement

00:14:42.064 --> 00:14:47.062


- that the data which was sent by the server is properly acknowledged/saved

00:14:47.088 --> 00:14:50.051


- accept acknowledgement from my side

00:14:50.073 --> 00:14:54.010


- now the data can be transferred further

00:14:54.036 --> 00:15:01.014


- after that the data will start transferring. So this is the three way handshaking
method

00:15:01.044 --> 00:15:06.008


- so this is all about the three way handshaking connection establishment by TCP

00:15:06.020 --> 00:15:08.081


- so if you liked the video, please share it with your friends

00:15:09.003 --> 00:15:10.098


- and please subscribe my channel, thank you.

You might also like