Mod5 - CN - Final Notes - Converted-4
Mod5 - CN - Final Notes - Converted-4
TRANSPORT LAYER
client. ●
The first two fields define the source and destination port numbers. The third field defines the total length
of the user datagram, header plus data.
●
4. When it arrives, the client is unblocked and the connection is established. Data can now be exchanged using
“SEND” and “RECEIVE” primitives.
●
5. When a connection is no longer needed, it must be released to free up table space within the 2 transport
entries, which is done with “DISCONNECT” primitive by sending “DISCONNECTION REQUEST” TPDU.
●
This disconnection can b done either by asymmetric variant (connection is released, depending on other one) or
by symmetric variant (connection is released, independent of other one).
UDP Services
●
Source port (16 bits) : It defines the port number of the application ●
Process-to-Process Communication
program in the sender host – UDP provides process-to-process communication using socket addresses, a
combination of IP addresses and port numbers
●
Destination port (16 bits): it defines the port number of the
application program in the receiver host
●
Connectionless Services
– UDP provides a connectionless service. This means that each user datagram sent
●
UDP length : Specifies the length of entire UDP packet. It includes by UDP is an independent datagram.
length of header information and data – There is no relationship between the different user datagrams even if they are
●
UDP checksum : Used for error control. coming from the same source process and going to the same destination program.
– The user datagrams are not numbered. There is no connection establishment and
– A checksum is used to verify that end to end data has not been corrupted.
no connection termination. This means that each user datagram can travel on a
different path.
●
Flow Control
– UDP is a very simple protocol. There is no flow control, and hence no window
mechanism. The receiver may overflow with incoming messages.
●
Congestion Control User Datagram Protocol (UDP) is used in many applications, including:
– Since UDP is a connectionless protocol, it does not provide congestion control. ●
Voice over Internet Protocol (VoIP) : UDP is used in VoIP applications because
– UDP assumes that the packets sent are small and sporadic and cannot create congestion in the
network. This assumption may or may not be true today, when UDP is used for interactive real-
it's better to hear what someone said relatively soon than wait for a clear
time transfer of audio and video. transmission. Eg: voice call and video call over internet
●
Error Control ●
Online gaming : UDP is used in online gaming because it's better to experience
– There is no error control mechanism in UDP except for the checksum. some video or sound issues for a few moments than wait for a clear transmission
– This means that the sender does not know if a message has been lost or duplicated. and risk losing the game.
– When the receiver detects an error through the checksum, the user datagram is silently discarded ●
Domain Name Systems (DNS) : UDP is used in DNS because DNS servers need
●
Multiplexing and Demultiplexing to be fast and efficient. When a user enters a URL in their web browser, the DNS
– In a host running a TCP/IP protocol suite, there is only one UDP but possibly several processes protocol uses UDP to fetch websites for users quickly.
that may want to use the services of UDP.
●
Real-time multimedia streaming : UDP is used in real-time multimedia streaming
– To handle this situation, UDP multiplexes and demultiplexes.
because speed and simplicity are more important than reliability. Eg: live
●
Encapsulation and Decapsulation streaming of sports
– To send a message from one process to another, the UDP protocol encapsulates and decapsulates
messages. UDP is often used in applications where speed and simplicity are more important
than reliability
Advantages of UDP
Disadvantages of UDP
●
Speed: UDP is faster than TCP because it does not have the overhead of
establishing a connection and ensuring reliable data delivery. ●
No reliability: UDP does not guarantee delivery of packets or order of delivery,
which can lead to missing or duplicate data.
●
Lower latency: Since there is no connection establishment, there is lower ●
No congestion control: UDP does not have congestion control, which means that it
latency and faster response time. can send packets at a rate that can cause network congestion.
●
Simplicity: UDP has a simpler protocol design than TCP, making it ●
Limited use cases: UDP is not suitable for applications that require reliable data
easier to implement and manage. delivery, such as email or file transfers, and is better suited for applications that can
tolerate some data loss, such as video streaming or online gaming.
●
Broadcast support: UDP supports broadcasting to multiple recipients,
making it useful for applications such as video streaming and online ●
No guaranteed ordering of packets while delivering.
gaming. ●
Not suitable for critical data : Not ideal for transferring important data where
accuracy and completeness matters, such as financial transactions
●
UDP uses smaller packet sizes than TCP, which can reduce network ●
Vulnerable to attacks: UDP is vulnerable to denial-of-service attacks , where an
congestion and improve overall network performance. attacker can flood a network with UDP packets, overwhelming the network and
User Datagram Protocol (UDP) is more efficient in terms of both latency causing it to crash.
and bandwidth.
TCP Services
●
Process-to-Process Communication
TRANSMISSION CONTROL PROTOCOL (TCP) – As with UDP, TCP provides process-to-process communication using port numbers
●
Stream Delivery Service
●
TCP is a connection-oriented, reliable protocol. – TCP is a stream-oriented protocol. It allows the sending process to deliver data as a stream of bytes and
allows the receiving process to obtain data as a stream of bytes.
●
TCP explicitly defines connection establishment, data transfer, and – TCP creates an environment in which the two processes seem to be connected by an imaginary “tube” that
carries their bytes across the Internet.
connection teardown phases to provide a connection-oriented – The sending process produces (writes to) the stream and the receiving process consumes (reads from) it.
service.
●
TCP uses checksum (for error detection), retransmission of lost or
corrupted packets, cumulative and selective acknowledgments, and
timers.
●
TCP is the most common transport-layer protocol in the Internet. – Sending and Receiving Buffers : Because the sending and the receiving processes may not necessarily write
or read data at the same rate, TCP needs buffers for storage.
– There are two buffers, the sending buffer and the receiving buffer, one for each direction. One way to implement a buffer is to use a circular
array.
– Segments - At the transport layer, TCP groups a number of bytes together into a packet called a segment.
●
Full-Duplex Communication
– TCP offers full-duplex service, where data can flow in both directions at the same time. Each
TCP endpoint then has its own sending and receiving buffer, and segments move in both
TCP SEGMENT
directions. ●
A packet in TCP is called a segment
●
Multiplexing and Demultiplexing
– Like UDP, TCP performs multiplexing at the sender and demultiplexing at the receiver.
However, since TCP is a connection- oriented protocol, a connection needs to be established for
each pair of processes
●
Connection-Oriented Service
– TCP, unlike UDP, is a connection-oriented protocol. When a process at site A wants to send to
and receive data from another process at site B, the following three phases occur:
●
1. The two TCP’s establish a logical connection between them.
●
2. Data are exchanged in both directions.
●
3. The connection is terminated
– Note that this is a logical connection, not a physical connection
●
Reliable Service
●
TCP is a reliable transport protocol. It uses an acknowledgment mechanism to check
the safe and sound arrival of data.
●
Source port address- This is a 16-bit field that defines the port number of the
application program in the host that is sending the segment.
●
Destination port address - This is a 16-bit field that defines the port number of ●
Acknowledgment number - This 32-bit field defines the byte number that the
the application program in the host that is receiving the segment. receiver of the segment is expecting to receive from the other party.
– If the receiver of the segment has successfully received byte number x from the other
●
Sequence number - This 32-bit field defines the number assigned to the first party, it returns x + 1 as the acknowledgment number.
byte of data contained in this segment. During connection establishment each – When the above segment is received at the receiver side, it sends 10000+1=10001 as ack
party uses a random number generator to create an initial sequence number number.
(ISN).
– Now, the receiver will expect a segment with 10001 segment number.
– In transport layer, data is transmitted in the form of segments(collection of ●
Header length - This 4-bit field indicates the number of 4-byte words in the TCP
bytes).
header. The length of the header can be between 20 and 60 bytes. HLEN ranges
– Eg : let segment be [9001-10000]. segment number of this segment is from 5 to 15 in binary notation.
number assigned to the first byte of that segment.ie, 9001. ●
Reserved bits : For future purpose
●
Window size - This field defines the window size of the sending TCP in bytes.
Note that the length of this field is 16 bits
●
Control - This field defines 6 different control bits or flags TCP CONNECTION
●
In TCP, connection-oriented transmission requires three phases:
– Connection establishment, data transfer, and connection termination
1. Connection Establishment
• TCP transmits data in full-duplex mode. When two TCPs in two machines are connected,
they are able to send segments to each other simultaneously
eg : SYN flag is set to 1 means, it wishes to establish a connection.
– ACK flag is set to 1 means, It wishes to send an ACK.
●
Three-Way Handshaking
– PSH set to 1 means sending data to receiver. – The connection establishment in TCP is called three-way handshaking
– URG set to 1 means segment contains some urgent data. So, that segment need to be handled urgently. – The process starts with the server. The server program tells its TCP that it is ready to
– RST set to 1 means if there is any issue in the connection made, then connection will be reset accept a connection. This request is called a passive open.
●
Checksum - This 16-bit field contains the checksum. The calculation of the checksum for – Now the server TCP is ready to accept a connection from any machine in the world.
TCP follows the same procedure as the one described for UDP.
●
Urgent pointer - This 16-bit field, which is valid only if the urgent flag is set, is used when
– The client program issues a request for an active open. A client that wishes to connect
the segment contains urgent data. to an open server tells its TCP to connect to a particular server. TCP can now start the
– It specifies the byte address of urgent data.
three-way handshaking process.
STEP 1 STEP 2
– The client sends the first segment (SYN segment) in which only the SYN flag is ●
The server sends the second segment, a SYN + ACK segment with two flag bits set as:
set. This segment is for synchronization of sequence Numbers. SYN and ACK. This segment has a dual purpose.
– The client chooses a random number as the first sequence number and sends
●
First, it is a SYN segment for communication in the other direction.
this number to the server. This sequence number is called the initial sequence ●
The server uses this segment to initialize a sequence number for numbering the bytes
number (ISN). sent from the server to the client.
– Note that the SYN segment is a control segment and carries no data. However, ●
The server also acknowledges the receipt of the SYN segment from the client by
it consumes one sequence number because it needs to be acknowledged. setting the ACK flag and displaying the next sequence number it expects to receive
from the client.
– A SYN segment cannot carry data, but it consumes one sequence number.
●
A SYN + ACK segment cannot carry data, but it does consume one sequence number.
STEP 3
●
The client sends the third segment. This is just an ACK segment.
●
It acknowledges the receipt of the second segment with the ACK flag and
acknowledgment number field.
●
Step 1 (SYN): In the first step, the client wants to establish a connection with a server, so it sends a segment with
SYN(Synchronize Sequence Number) which informs the server that the client is likely to start communication and
with what sequence number it starts segments with
●
Step 2 (SYN + ACK): Server responds to the client request with SYN-ACK signal bits set.
Acknowledgement(ACK) signifies the response of the segment it received and SYN signifies with what sequence
number it is likely to start the segments with.
●
Step 3 (ACK): In the final part, client acknowledges the response of the server and they both establish a reliable
connection with which they will start the actual data transfer
2. Data Transfer
– After connection is established, bidirectional data transfer can take place.
– The client and server can send data and acknowledgments in both directions.
●
Pushing Data
– The sending TCP uses a buffer to store the stream of data coming from the sending 3. Connection Termination
application program. The sending TCP can select the segment size.
– The receiving TCP also buffers the data when they arrive and delivers them to the application ●
Either of the two parties involved in exchanging
program when the application program is ready or when it is convenient for the receiving
TCP. data (client or server) can close the connection,
– This type of flexibility increases the efficiency of TCP. although it is usually initiated by the client.
●
Urgent Data
– There are occasions in which an application program needs to send urgent bytes, some bytes
that need to be treated in a special way by the application at the other end.
– The solution is to send a segment with the URG bit set.
– The sending application program tells the sending TCP that the piece of data is urgent.
– The sending TCP creates a segment and inserts the urgent data at the beginning of the
segment. The rest of the segment can contain normal data from the buffer.
●
To avoid congestion before it happens, it is necessary to slow down the exponential
growth.
●
The congestion avoidance algo works with additive increase instead of exponential
growth.
●
After cwnd exceeds the ssthresh size, the TCP Congestion control mechanism enters
the congestion avoidance phase
●
In this phase, Sender increases the congestion window size linearly to avoid the
congestion.
●
On receiving each acknowledgement, sender increments the congestion window size
by 1 and the technique is known as Additive increase.
●
This phase continues until the congestion window size becomes equal to the receiver
window size.
3. Congestion Detection Phase Case-02: Detection On Receiving 3 Duplicate Acknowledgements-
• If congestions occurs, it is required to decrease the congestion window size. • If three ACKs are received, there is a weaker possibility of congestion; a segment may
• There are 2 cases: have been dropped, but some segments after that may have arrived safely since three
ACKs are received.
– In both cases, the threshold size can be dropped to half of the previous window • This is called fast transmission and fast recovery.
size.
• Sender receives 3 duplicate acknowledgements for a segment.
• Case-01: Detection On Time Out • This case suggests the weaker possibility of congestion in the network.
• In this, the timer time-out expires even before receiving acknowledgment for a • There are chances that a segment has been dropped but few segments sent later
segment. may have reached.
• In this case, sender sets the slow start threshold to half of the current congestion
window size. • In this case, sender reacts by-
• Each time a timeout occurs, the source sets Congestion Window to half of its • Setting the slow start threshold to half of the current congestion window size.
previous value. • Decreasing the congestion window size to slow start threshold.
• Resuming the congestion avoidance phase.
56
FILE TRANSFER PROTOCOL
●
It is an application layer protocol
●
Used for transferring a file from one host to another
●
FTP uses the services of TCP
●
To transfer a file, FTP uses two TCP connections in parallel :
– 1. Control connection : for control information (commands and responses)
APPLICATION LAYER – 2. Data connection : Used for data transfer
●
Separation of commands and data transfer makes FTP more efficient.
●
FTP uses two well known TCP ports :
– 1. Port 21 is used for control connection.
– 2. Port 20 is used for data connection
FTP transfer files using any of the following modes:
●
Stream Mode: It is the default mode.
– In stream mode, the data is transferred from FTP to TCP in stream bytes. Here
TCP is the cause for fragmenting data into small segments. FTP Data Types
– The connection is automatically closed if the transforming data is in the stream
●
The data type of a file, which determines how the file is represented overall, is the first piece
of information that can be provided about it. The FTP standard specifies the following four
bytes. Otherwise, the sender will close the connection.
categories of data:
●
Block Mode: In block mode, the data is transferred from FTP to TCP in the form of – ASCII: Describes an ASCII text file in which each line is indicated by the previously mentioned type
blocks, and each block followed by a 3-byte header. of end-of-line marker.
– EBCDIC: For files that use IBM’s EBCDIC character set, this type is conceptually identical to ASCII.
– The first byte of the block contains the information about the block so it is – Image: This is the “black box” mode I described earlier; the file has no formal internal structure and is
known as the description block and the other two bytes contain the size of the transferred one byte at a time without any processing.
block. – Local: Files containing data in logical bytes with a bit count other than eight can be handled by this
data type.
●
Compressed Mode: This mode is used to transfer big files.
– As we know that, due to the size limit we can not transfer big files on the
internet, so the compressed mode is used to decrease the size of the file into
small and send it on the internet.
●
In the Internet, the domain name space (tree) is divided into 3 different sections
1) Generic domain
2) Country domain
3) Inverse domain
Inverse domain
●
It is used to map an address to a name.
2. Iterative resolution
●
If the client doesnt ask for a recursive answer, the mapping can be done
iteratively
●
If the server is the authority for the name, it sends an answer.
●
If it is not , it returns to the client, the IP address of the server that it thinks can
resolve the query.
●
The client is responsible for repeating the query to this second server.
●
If the newly addressed server can resolve the problem, it answers the query with
the IP address
●
Otherwise it returns the IP address of a new server to the client.
●
Now the client must repeat the query to the third server.
●
This process is called iterative resolution because the client repeats the same
query to multiple servers.
DNS messages
●
DNS allows you to interact with devices on the Internet without having to remember
long strings of numbers.
●
Changing of information between client and server is carried out by two types of
DNS messages:
– Query message
– Response message.
●
In the figure above, the client queries 4 servers before it gets
answer from mcgraw.com
2. Flags:
Dns message header format ●
QR (query/response): It is a 1-bit subfield. If its value is 0, the message is of request type and if its
value is 1, the message is of response type.
●
opcode: It is a 4-bit subfield that defines the type of query carried by a message. This field value is
repeated in the response. Following is the list of opcode values with a brief description:
DNS Attacks
1. DNS hijacking
●
DNS hijacking involves unauthorised redirection of DNS queries to malicious sites.
●
Attackers manipulate DNS records to redirect users to fraudulent websites, which can lead to data theft
or the spread of malware.
●
This can occur through various methods, such as compromising DNS servers or through man-in-the-
middle attacks where the attacker intercepts and alters DNS queries.
POP3 Vs IMAP
MIME – Multi purpose Internet Mail Extensions
●
Electronic mail has a simple structure.
●
It can sent messages only in NVT 7-bit ASCII format.
●
For eg: it can’t be used for languages that are not supported by 7-bit ASCII
characters(suchas French, German etc).
●
Also it can’t be used to send binary files/videos/audio data
●
MIME is a supplementary protocol that allows non-ASCII data to be sent ●
MIME headers can be added to the original email header section to define the
through email. transformation parameters.
●
MIME transforms non-ASCII data at the sender side to NVT ASCII data
and delivers them to the client MTA to be sent through the Internet.
●
The message at the receiver side is transformed back to the original data.
●
MIME can be defined as the set of software functions that transforms non
ASCII data to ASCII data and viceversa
SNMP – Simple Network Management Protocol
World Wide Web (WWW)
●
The World Wide Web (WWW), often called the Web, is a system of interconnected webpages and
information that you can access using the Internet.
●
Web pages are linked together using hyperlinks which are HTML-formatted and, also referred to as
hypertext, these are the fundamental units of the Internet and are accessed through Hypertext Transfer ●
www is a distributed client server service, in which a client using a
Protocol(HTTP).
browser that can access a service from a server.
●
HTTP specifies the communication of browsers and servers.
●
A Web browser is used to access web pages. Web browsers can be defined as programs which display
●
But, the service provided is distributed over many locations called
text, data, pictures, animation and video on the Internet. sites.
●
The below diagram indicates how the Web operates just like client-server architecture of the internet.
●
When users request web pages or other information, then the web browser of your system request to the
●
Each site hold one or more documents,ie, web pages
server for the information and then the web server provide requested services to web browser back and
finally the requested service is utilized by the user who made the request.
●
Each web page can contain a link to other pages in the same site or at
other sites.
●
The pages can be retrieved and viewed by using browsers