The transmission control protocol.
TCP provides a communication service at an intermediate level between an application program and the
Internet protocol.
It provides host to host connectivity at the transport layer of the Internet model.
Dhcp works with the Internet protocol IP, which defines how computers send packets of data to each
other.
Together, TCP and IP are basic rules defining the Internet.
TCP is a connection oriented protocol, which means a connection is established and maintained until
the application programs at each end have finished exchanging messages.
It determines how to fragment application data into packets that networks can deliver, sends packets
to, and accepts packets from the network layer, manages flow control and because it is meant to provide
error free data transmission handles retransmission of dropped or garbled packets, as well as acknowledgement
of all packets that arrive.
Let's see the connection oriented error free communication of TCP.
In an example, when a web server sends an HTML file to a client, it uses the Http protocol to do so.
The Http program layer asks the TCP layer to set up the connection and send the file.
The TCP stack divides the file into packets, numbers them, and then forwards them individually to
the IP layer for delivery.
Although each packet in the transmission will have the same source and destination IP addresses, packets
may be sent along multiple routes.
The TCP program layer in the client computer waits until all of the packets have arrived, then acknowledges
those it receives and asks for the retransmission on any.
It does not based on missing packet numbers, then assembles them into a file and delivers the file
to the receiving application.
The TCP three way handshake is the method used by TCP to set up a connection.
Tcp's.
Three way handshaking technique is often referred to as syn.
Syn ack ack.
Because there are three messages transmitted by TCP to negotiate and start a TCP session between two
computers.
This three way handshake process is also designed so that both ends can initiate a negotiate separate
TCP socket connections at the same time.
That means the connection is full duplex.
Oh, you know what?
We have to take a break at this point and talk about TCP flags.
There are one bit flags in TCP headers which are called TCP flags.
TCP flags are used within TCP packet transfers to indicate a particular connection state or provide
additional information.
Ignoring e.c.e.
And ns flags.
For now, there are basically six TCP flags.
The sin or synchronization flag is used as a first step in establishing a three way handshake between
two hosts.
Only the first packet from both a sender and the receiver should have this flag set.
The ACC flag, which stands for acknowledgement, is used to acknowledge the successful receipt of a
packet.
The rest flag, which stands for reset, gets sent from receiver to the sender when a packet is sent
to a particular host that was not expecting it.
The fin flag, which stands for finished, means there is no more data from the sender.
Therefore, it is used in the last packet sent from the sender.
The flag, which stands for push, is somewhat similar to the ERG flag and tells a receiver to process
these packets as they are received instead of buffering them.
The ERG flag is used to notify the receiver to process the urgent packets before processing all other
packets.
So every legitimate TCP connection begins with a TCP three way handshake, which is used to exchange
sequence numbers so that lost packets can be retransmitted and packets can be placed in the proper order.
If Machine A wants to initiate a connection to machine B, it will start by sending a TCP packet with
a syn control bit set.
This packet will include an initial sequence number, which I'll call here is an A because it comes
from machine A.
Which is 32 bits long and typically generated in a pseudo random fashion by the TCP software on machine.
A.
The act number, another 32 bits and the TCP header is typically set to zero because it is ignored in
this initial sin.
Some operating system variants may make this act number non zero, but either way it's ignored by the
destination machine.
So if the destination port is open, that is there is something listening on that port.
It must respond with a syn-ack packet back, a packet that has both the syn and ack control bits set
at the same time.
This packet will have a sequence number of ESN, be a pseudo random number assigned by Machine B for
this connection.
The Syn-ack packet will have an acknowledgement number of ESN, a plus one indicating that machine B
has acknowledged the syn packet from Machine A.
To complete the three way handshake machine.
A responds with an Ack packet which has a sequence number of is n a plus one.
It's the next packet, so the sequence number has to change from the value in the original sin packet.
The acknowledgement number field is set to isnb plus one, thereby acknowledging the syn-ack packet.
Right.
So we have now exchanged sequence numbers.
All packets going from A to B will have increasing sequence numbers starting at esna plus one going
up my value of one for each byte of data transmitted in the payloads of A to B packets.
Likewise, all responses back from B will have sequence numbers starting at is n, B plus one and going
up for each byte of data from B to A.
In essence, we have two streams of sequence numbers in this series of packets, one from A to B originally
based on Esna and the other from B to A originally based on Is B.
Perfect.