... 1
OSI Layer-4 provides host-to-host communication services such as connection 2
connection-oriented data stream support, reliability, flow control, and multiplexing 3
for applications. TCP and UDP most common protocols used in this layer 4
Let's take a look to the TCP versus UDP. TCP is suited for applications that require high reliability 5
and transmission time is relatively less critical. 6
UDP is suitable for applications that need fast, efficient transmission, such as games. 7
UDP's stateless nature is also useful for servers that answer small queries from huge numbers 8
of clients. Another difference is TCP rearranges data packets in the order specified.UDP has no inherent 9
order as all packets are independent of each other. 10
If ordering is required, it has to be managed by the application layer.The speed for TCP is slower 11
than UDP.UDP is faster because error recovery is not attempted 12
It is a "best effort" protocol. TCP does Flow Control. TCP requires three packets to set up a socket connection, 13
before any user data can be can be sent. 14
TCP handles reliability and congestion control. 15
UDP does not have an option for flow control 16
And lastly TCP is connection oriented – 17
once a connection is established, data can be sent bidirectional. UDP is a simpler, connectionless 18
protocol. 19
So in computer networking, port numbers are part of the addressing 20
information used to identify the senders and receivers of messages. 21
Port numbers allow different applications on the same computer to share network resources simultaneously. 22
Let's say that we have a client in here and let's say that this client want to use different applications 23
such as electronic mail html page like surfing on the web and by using the internet chat. 24
Maybe. if this guy wants to use this different application it should use different port numbers to reach 25
to these different applications. 26
So we have a comment that we can use on our laptops our PCs our Windows machines or something like that 27
on the command line. 28
If we type "netstat" we can see some statistics.netstat (network statistics) is a command-line network utility tool that 29
displays network connections for the Transmission Control Protocol (both incoming and outgoing), 30
routing tables, and a number of network interface. 31
As you can see here, here are the source IP addresses these are the source ports and these are the destination 32
ports that the user wants to reach. 33
For example in here this guy wants to reach the 80 port and the communication is established. 34
So The port numbers in the range from 0 to 1023 are the well-known ports or system ports. 35
... 36
They are used by system processes that provide widely used types of network services. 37
For example a well-known port is FTP, and FTP uses TCP protocol and port number of FTP 38
is 20. 39
For example :Telnet. 40
This is a remote access protocol and telnet uses TCP protocol and protocol number is twenty three 41
and DNS 42
That can use UDP or TCP and the port number is fifty three. In data communications networks, packet 43
segmentation 44
is the process of dividing a data packet into smaller units for transmission over the network. Packet 45
segmentation happens at layer four of the OSI model or the transport layer. 46
Segmentation may be required 47
When The data packet is larger than the maximum transmission unit supported by the network and when 48
the network is unreliable. 49
and it is desirable to divide the information into smaller segments to maximize the probability 50
that each one of them can be delivered correctly to the destination 51
So let's talk about the TCP And UDP details. 52
The client–server model is a distributed application structure that partitions tasks or workloads between 53
the providers of a resource or service, called servers, and service requesters, called clients. 54
For example if you try to open the networkel.comweb page your computer's web browser is the client 55
client program that requested services from the networkel.com server 56
which technically is called an HTTP server 57
So you could read the web page of networkel. 58
So in here you have. 59
we have some protocols that are using TCP protocol and they are FTP,file transfer protocol and telnet 60
and HTTP. 61
This is the protocol we use when we are surfing on the web. 62
As you know so, these clients are using some port numbers in this range. 63
As you can see and they're interacting with the server to get these services from them for example this 64
PC one wants to take an FTP service from the server. 65
So it's using the destination port of 20 of the server. 66
For example this PC, PC two wants to take an HTTP service from the server. 67
So it's using the destination port 80 while it's connecting the server. 68
A three-way handshake is a method used in a TCP/IP network to 69
create a connection between a local host and server. 70
It is a three-step method that requires both the client and server to exchange SYN and ACK (acknowledgment) 71
packets before actual data communication begins. 72
To establish a TCP session 73
we have SYN , SYN-ACK and ACK steps. 74
In the SYN step Client sends session request to server. In response, the server replies with a SYN-ACK. 75
Then Finally, the client sends an ACK back to the server 76
For example let's say that the client wants to 77
establish a TCP session with server. what client is doing first, it's sending a SYN packet 78
with a sequence number of 1000. 79
The server gets the syn packet and replies back with the syn and acknowledgement message and saying 80
that my sequence number of this message is 2000 and I'm acknowledging that you'll send me the sequence 81
number 1000 packet. 82
All right. 83
And increasing the number of the sequence by 1 as you can see. 84
Then this third step is the client is responding back with an ACK again and saying that this ACK has 85
a sequence number of one thousand one because my syn's sq. number was 1000. 86
And this is my next packet that I'm sending to you. 87
And this has a sequence number of 1001 and I am ACKing the packet that you sent me 88
with the sequence number of 2000 and the acknowledgement number is 2001. 89
All right , when we try to terminate a TCPsession 90
The steps we are using is the first fin then ack 91
plus fin after this. 92
The first is fin then ack then fin the receivers side. 93
Then this guy is sending and ack again. 94
The steps are fin - ack -fin -ack 95
This is by B. 96
These are by a. let's talk about the TCP re-order process right now . if you want to send a packet 97
from site a to site B 98
you have two different networks and they are IP Network 1 and IP Network 2. When packets are being 99
sent, Segments may split to different paths , 100
some of them may prefer IP Network 1 and some of them may go over IP Network 2. TCP reorders these 101
packets at the destination. 102
And this process is known as TCP reorder process. 103
This process is not available for UDP guys. 104
Please pay attention that. The TCP windowing is an option to increase the receive window size 105
allowed in Transmission Control Protocol above its maximum value. 106
The TCP window size, is simply an advertisement of how much data (in bytes) the receiving device 107
is willing to receive at any point in time. The receiving device can use this value to control 108
the flow of data, or as a flow control mechanism. as you can see in here. 109
There is a TCP session between PCand server , PCis sending a packet to this guy. 110
And this guy ACKs the first guy. 111
All right. 112
Then PC is sending the packet two and packet three and Server is responding back with acknowledgment 113
message again. 114
But in here this guy is sending four five and six to server but this time what is going on in here is the 115
acknowledgement number is seven, which means I couldn't get the sequence number seven because in here 116
please pay attention. 117
I am sending the sequence number one and the acknowledgement is two in here 118
I'm getting the sequence number three and ack is four but in here I am sending an 119
acknowledgement of seven which means I got the sequence number six. 120
Lastly . then the PC is sending the 7 8 9 again, again the seven and plus eight and nine. 121
Then the server is acknowledging with the 10 and that means everything is OK. 122
So let's take a look to the UDP protocol some now. UDP provides 123
As I told you you unreliable data transfer. 124
And as I told you again we don't have a reorder process .that's a connectionless protocol and loss of data may occur 125
and used for application that requires fast delivery and no delay. and UDP has a client server 126
model as well as TCP too. Protocols such as DNS, TFTP or SNMP are using the UDP protocol. 127
So for example if PC one wants to get the DNS server from this guy that sends the UDP packets and saying 128
that hey guy destination port is 53 that means I need that DNS service from you. 129
For example let's take a look to the this client which is PC 2 , this is as an SNMP client and SNMP 130
uses UDP also. 131
So this is sending UDP messages and with the destination port of one hundred and sixty one to get the 132
SNMP service from this server.