Ec3401-Networks and Security -664240324-n&s Unit 3
Ec3401-Networks and Security -664240324-n&s Unit 3
Ec3401-Networks and Security -664240324-n&s Unit 3
Transport Layer Protocols – UDP and TCP Connection and State Transition Diagram - Congestion
Control and Avoidance (DEC bit, RED)- QoS - Application Layer Paradigms – Client – Server
Programming – Domain Name System – World Wide Web, HTTP, Electronic Mail.
The transport layer is located between the application layer and the network layer. It provides a
process-to-process communication between two application layers, one at the local host and the other
at the remote host.
A transport-layer protocol, like a network-layer protocol, can provide two types of services:
connectionless and connection-oriented
Connectionless Service:
In a connectionless service, the source process (application program) needs to divide its
message into chunks of data of the size acceptable by the transport layer and deliver them to
the transport layer one by one.
The transport layer treats each chunk as a single unit without any relation between the chunks.
When a chunk arrives from the application layer, the transport layer encapsulates it in a packet
and sends it.
Since there is no dependency between the packets at the transport layer, the packets may arrive
out of order at the destination and will be delivered out of order to the server process
The situation would be worse if one of the packets were lost. Since there is no numbering on the
packets, the receiving transport layer has no idea that one of the messages has been lost. It just
delivers two chunks of data to the server process.
Connection-Oriented Service:
In a connection-oriented service, the client and the server first need to establish a logical
connection between them. The data exchange can only happen after the connection
establishment. After data exchange, the connection needs to be torn down.
USER DATAGRAM PROTOCOL
The User Datagram Protocol (UDP) is a connectionless, unreliable transport protocol.
Example:
The following is the content of a UDP header in hexadecimal format. CB84000D001C001C
a. What is the source port number?
b. What is the destination port number?
c. What is the total length of the user datagram?
d. What is the length of the data?
Solution
a. The source port number is the first four hexadecimal digits (CB84)16, which means
that the source port number is 52100.
b. The destination port number is the second four hexadecimal digits (000D)16, which
means that the destination port number is 13.
c. The third four hexadecimal digits (001C)16 define the length of the whole UDP packet
as 28 bytes.
d. The length of the data is the length of the whole packet minus the length of the
header, or 28 − 8 = 20 bytes.
UDP Services:
Process-to-Process Communication:
UDP provides process-to-process communication using socket addresses, a combination of IP
addresses and port numbers
Applications of UDP:
UDP is suitable for a process that requires simple request-response communication with
little concern for flow and error control.
UDP is a suitable transport protocol for multicasting.
UDP is used for management processes such as SNMP
UDP is used for some route updating protocols such as Routing Information Protocol
(RIP)
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
Multiplexing and Demultiplexing: TCP performs multiplexing at the sender and demultiplexing at
the receiver
Connection-Oriented Service TCP: 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.
Numbering System: Although the TCP software keeps track of the segments being transmitted or
received, there is no field for a segment number value in the segment header. Instead, there are
two fields, called the sequence number and the acknowledgment number. These two fields refer to
a byte number and not a segment number.
Byte Number: TCP numbers all data bytes that are transmitted in a connection. Numbering is
independent in each direction. When TCP receives bytes of data from a process, TCP stores them in
the sending buffer and numbers them. The numbering does not necessarily start from 0. Instead,
TCP chooses an arbitrary number between 0 and 232 − 1 for the number of the first byte.
Sequence Number: After the bytes have been numbered, TCP assigns a sequence number to each
segment that is being sent. The sequence number, in each direction, is defined as follows:
1. The sequence number of the first segment is the ISN (initial sequence number), which is a random
number.
2. The sequence number of any other segment is the sequence number of the previous segment
plus the number of bytes (real or imaginary) carried by the previous segment.
TCP Segment Format:
A packet in TCP is called a segment. The segment consists of a header of 20 to 60 bytes,
followed by data from the application program. The header is 20 bytes if there are no
options and up to 60 bytes if it contains options.
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 the application
program in the host that is receiving the segment.
Control. This field defines 6 different control bits or flags. These bits enable flow control,
connection establishment and termination, connection abortion, and the mode of data
transfer in TCP.
Window size. This field defines the window size of the sending TCP in bytes. The length of
this field is 16 bits, which means that the maximum size of the window is 65,535 bytes
Checksum. This 16-bit field contains the checksum
Urgent pointer. This 16-bit field, which is valid only if the urgent flag is set, is used when the
segment contains urgent data
TCP Connection:
TCP is connection-oriented. A connection-oriented transport protocol establishes a logical
path between the source and destination. All of the segments belonging to a message are
then sent over this logical path.
Using a single logical pathway for the entire message facilitates the acknowledgment
process as well as retransmission of damaged or lost frames
In TCP, connection-oriented transmission requires three phases: connection establishment,
data transfer, and connection termination
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.
The client sends the first segment, a SYN segment, in which only the SYN flag is set. This
segment is for synchronization of sequence numbers. This sequence number is called
the initial sequence number (ISN). This segment does not contain an acknowledgment
number
The SYN segment is a control segment and carries no data. However, it consumes one
sequence number because it needs to be acknowledged.
The server sends the second segment, a SYN + ACK segment with two flag bits set as:
SYN and ACK. This segment has a dual purpose. First, it is a SYN segment for
communication in the other direction. The server uses this segment to initialize a
sequence number for numbering the bytes sent from the server to the client.
The server also acknowledges the receipt of the SYN segment from the client by setting
the ACK flag and displaying the next sequence number it expects to receive from the
client. Because the segment contains an acknowledgment, it also needs to define the
receive window size, rwnd (to be used by the client)
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
Data Transfer
After connection is established, bidirectional data transfer can take place. The client
and server can send data and acknowledgments in both directions
In the diagram shown in figure the client sends 2,000 bytes of data in two segments.
The server then sends 2,000 bytes in one segment. The client sends one more
segment. The first three segments carry both data and acknowledgment, but the
last segment carries only an acknowledgment because there is no more data to be
sent
Connection Termination:
Either of the two parties involved in exchanging data (client or server) can close
the connection, although it is usually initiated by the client
Most implementations today allow two options for connection termination:
three-way handshaking and four-way handshaking with a half-close option.
Three-Way Handshaking:
In this situation, the client TCP, after receiving a close command from the client
process, sends the first segment, a FIN segment in which the FIN flag is set.
The server TCP, after receiving the FIN segment, informs its process of the
situation and sends the second segment, a FIN + ACK segment, to confirm the
receipt of the FIN segment
The client TCP sends the last segment, an ACK segment, to confirm the receipt
of the FIN segment from the TCP server. This segment contains the
acknowledgment number, which is one plus the sequence number received in
the FIN segment from the server. This segment cannot carry data and consumes
no sequence numbers.
The dotted black lines in the figure represent the transition that a server normally goes
through; the solid black lines show the transitions that a client normally goes through.
However, in some situations, a server transitions through a solid line or a client
transitions through a dotted line. The colored lines show special situations
The size of the congestion window is also increased by 1 because the arrival of the
acknowledgement is a good sign that there is no congestion in the network.
The size of the window is now 2. After sending two segments and receiving two individual
acknowledgments for them, the size of the congestion window now becomes 4, and so on.
The size of the congestion window in this algorithm is a function of the number of ACKs arrived
and can be determined as follows.
If an ACK arrives, cwnd = cwnd + 1.
A slow start cannot continue indefinitely. There must be a threshold to stop this phase. The
sender keeps track of a variable named ssthresh (slow-start threshold). When the size of the
window in bytes reaches this threshold, slow start stops and the next phase starts
DEC bit
It is first mechanism was developed for use on the Digital Network Architecture (DNA), a
connectionless network with a connection-oriented transport protocol.
The idea is to more evenly split the responsibility for congestion control between the routers
and the end nodes.
Each router monitors the load it is experiencing and explicitly notifies the end nodes when
congestion is about to occur. This notification is implemented by setting a binary congestion bit
in the packets that flow through the router, hence the name DECbit.
The destination host then copies this congestion bit into the ACK it sends back to the source.
Finally, the source adjusts its sending rate so as to avoid congestion.
A single congestion bit is added to the packet header. A router sets this bit in a packet if its
average queue length is greater than or equal to 1 at the time the packet arrives.
This average queue length is measured over a time interval that spans the last busy+idle cycle,
plus the current busy cycle.
Figure shows the queue length at a router as a function of time. Essentially, the router
calculates the area under the curve and divides this value by the time interval to compute the
average queue length.
Using a queue length of 1 as the trigger for setting the congestion bit is a trade-off between
significant queuing (and hence higher throughput) and increased idle time (and hence lower
delay). In other words, a queue length of 1 seems to optimize the power function.
The system processes packets in each queue in a round-robin fashion with the number of
packets selected from each queue based on the corresponding weight.
For example, if the weights are 3, 2, and 1, three packets are processed from the first queue,
two from the second queue, and one from the third queue.
In weighted fair queuing, each class may receive a small amount of time in each time period. In
other words, a fraction of time is devoted to serve each class of packets, but the fraction
depends on the priority of the class
Client Server Programming:
In a client-server paradigm, communication at the application layer is between two running
application programs called processes: a client and a server.
A client is a running program that initializes the communication by sending a request; a server is
another application program that waits for a request from a client.
The server handles the request received from a client, prepares a result, and sends the result back
to the client.
Socket Interface:
Socket is supposed to behave like a terminal or a file. It is an abstraction.
It is an object that is created and used by the application program.
The client thinks that the socket is the entity that receives the request and gives the
response; the server thinks that the socket is the one that has a request and needs the
response.
If we create two sockets, one at each end, and define the source and destination
addresses correctly, we can use the available instructions to send and receive data
The controller receives input from the keyboard or the mouse and uses the client
programs to access the document.
After the document has been accessed, the controller uses one of the interpreters to
display the document on the screen.
Web Documents
The documents in the WWW can be grouped into three broad categories: static,
dynamic, and active.
Static Documents
Static documents are fixed-content documents that are created and stored in a server.
The client can get a copy of the document only.
When a client accesses the document, a copy of the document is sent. The user can then
use a browser to see the document.
Static documents are prepared using one of several languages: HyperText Markup
Language (HTML), Extensible Markup Language (XML), Extensible Style Language (XSL),
and Extensible Hypertext Markup Language (XHTML).
Dynamic Documents
A dynamic document is created by a web server whenever a browser requests the
document. When a request arrives, the web server runs an application program or a
script that creates the dynamic document.
The server returns the result of the program or script as a response to the browser that
requested the document.
Because a fresh document is created for each request, the contents of a dynamic
document may vary from one request to another.
A very simple example of a dynamic document is the retrieval of the time and date from
a server.
ELECTRONIC MAIL
Electronic mail (or e-mail) allows users to exchange messages.
In an application such as HTTP or FTP, the server program is running all the time, waiting
for a request from a client.
When the request arrives, the server provides the service. There is a request and there
is a response.
First, e-mail is considered a one-way transaction. When Alice sends an email to Bob, she
may expect a response, but this is not a mandate.
Bob may or may not respond. If he does respond, it is another one-way transaction.
Second, it is neither feasible nor logical for Bob to run a server program and wait until
someone sends an e-mail to him. Bob may turn off his computer when he is not using it.
Architecture:
The sender and the receiver of the e-mail, Alice and Bob respectively, are connected
via a LAN or a WAN to two mail servers.
The administrator has created one mailbox for each user where the received
messages are stored.
A mailbox is part of a server hard drive, a special file with permission restrictions.
Only the owner of the mailbox has access to it. The administrator has also created a
queue (spool) to store messages waiting to be sent.
A simple e-mail from Alice to Bob takes nine different steps. Alice and Bob use three
different agents: a user agent (UA), a message transfer agent (MTA), and a message
access agent (MAA).
The local part defines the name of a special file, called the user mailbox, where all
the mail received for a user is stored for retrieval by the message access agent.
The second part of the address is the domain name. An organization usually selects
one or more hosts to receive and send e-mail; they are sometimes called mail
servers or exchangers.
The domain name assigned to each mail exchanger either comes from the DNS
database or is a logical name
CONNECT WITH US
WEBSITE: www.eduengineering.net
TELEGRAM: @eduengineering
-
INSTAGRAM: @eduengineering