Data Communication Data and Signals Behrouz A. Forouzan 1Data Communication - Data and Signals.
NET 221D:COMPUTER NETWORKS FUNDAMENTALS Lecture : Transport Layer: Behrouz A. Forouzan” Data...
-
Upload
jodie-nash -
Category
Documents
-
view
277 -
download
3
Transcript of NET 221D:COMPUTER NETWORKS FUNDAMENTALS Lecture : Transport Layer: Behrouz A. Forouzan” Data...
Behrouz A. Forouzan” Data communications and Networking
NET 221D:COMPUTER NETWORKS FUNDAMENTALS
Lecture : Transport Layer:
1
Behrouz A. Forouzan” Data communications and Networking
2
Transport Layer
The transport layer in the TCP/IP suite is located between the application layer and the network layer.
It provides services to the application layer and receives services from the network layer.
The transport layer acts as a liaison between a client program and a server program, a process-to-process connection.
Behrouz A. Forouzan” Data communications and Networking
3
Transport Layer The transport layer is responsible for process-to-process
delivery. A process is an application program running on a host.
The transport layer is responsible for: Service point or Port addressing Segmentation and reassembly
A message is divided into transmittable segments each segment containing a sequence number.
Connection Control Connection oriented or connectionless.
Flow control Error control
Behrouz A. Forouzan” Data communications and Networking
4
Process to Process Communication The first duty of a transport-layer protocol is to
provide process-to-process or (end to end delivery) communication.
A process is an application-layer entity (running program) that uses the services of the transport layer.
Type of data deliveries Data Link Layer: Node to Node delivery Network Layer: Host to host delivery Transport Layer: Process to process delivery
Behrouz A. Forouzan” Data communications and Networking
5
Process to Process Communication Network layer
Communication at the computer level (host-to-host communication).
Deliver the message only to the destination computer. Transport layer:
Message handed to the correct process on the host computer. shows the domains of a network
6
Client-Server Communication
Most common way to achieve process-to-process communication, is through the client-server paradigm.
A process on the local host, called a client, needs services from a process usually on the remote host, called a server.
A remote computer/server can run several server programs at the same time, just as several local computers/clients can run one or more client programs at the same time.
For communication, we must define The local host: Defined using IP address Local process: Defined using identifiers called port numbers Remote host:: Defined using IP address Remote Process: Defined using identifiers called port numbers In the TCP/IP protocol suite, the port numbers are integers
between 0 and 65,535 (16 bits).Computer networks / Andrew S. Tanenbaum-- 5th ed
Behrouz A. Forouzan” Data communications and Networking
7
IP addresses versus port numbers
Behrouz A. Forouzan” Data communications and Networking
8
Port Addressing
Ephemeral port number Defined by the client program. Ephemeral (Short Lived) is used to describe these port
numbers because the life of a client is normally short. Server port number
The server process must also define itself with a port number.
Port number cannot be chosen randomly. If the computer at the server site runs a server process
and assigns a random number as the port number, the process at the client site that wants to access that server and use its services will not know the port number.
TCP/IP has uses universal port numbers for servers; these are called well-known port numbers.
Behrouz A. Forouzan” Data communications and Networking
9
Socket address
A transport-layer protocol in the TCP suite at both ends needs the following to establish connection IP address port number
The combination of an IP address and a port number is called a socket address. The client socket address defines the client process
uniquely. The server socket address defines the server
process uniquely.
10
Encapsulation De-Capsulation/Multiplexing De-multiplexing
Behrouz A. Forouzan” Data communications and Networking
To send a message from one process to another, the transport-layer protocol encapsulates and de-capsulates messages.
Multiplexing (many to one) Whenever an entity accepts items from more than one source. The transport layer at the source performs multiplexing
De-multiplexing (one to many). Whenever an entity delivers items to more than one source. The transport layer at the destination performs de-multiplexing.
11
Flow Control
Behrouz A. Forouzan” Data communications and Networking
If the items are produced faster than they can be consumed, the consumer can be overwhelmed and may need to discard some items.
Pushing: sender delivers items whenever they are produced without a ⎯prior request from the consumer.
Pulling: producer delivers the items after the consumer has requested them
Two cases of flow control at the transport layer: From the sending transport layer to the sending application layer and From the receiving transport layer to the sending transport layer
Behrouz A. Forouzan” Data communications and Networking
12
Congestion control refers to the mechanisms and techniques that control the congestion and keep the load below the capacity.
Congestion in a network may occur if the load on the network—the number of packets sent to the network—is greater than the capacity of the network—the number of packets a network can handle.
Congestion in a network or internetwork occurs because routers and switches have queues—
buffers that hold the packets before and after processing. A router, for example, has an input queue and an output queue for each interface.
If a router cannot process the packets at the same rate at which they arrive, the queues become overloaded and congestion occurs.
Congestion at the transport layer is actually the result of congestion at the network layer, which manifests itself at the transport layer.
Congestion at the transport layer can be implemented if there is no congestion control at the network layer.
Congestion control
Behrouz A. Forouzan” Data communications and Networking
13
Error Control Network layer (IP) is unreliable. Transport layer should be reliable if the application
requires reliability. Reliability can be achieved by adding error control
services to the transport layer. Error control at the transport layer is responsible for
Detecting and discarding corrupted packets. Keeping track of lost and discarded packets and resending
them. Recognizing duplicate packets and discarding them. Buffering out-of-order packets until the missing packets
arrive. Error control, unlike flow control, involves only the
sending and receiving transport layers. We assume that the message chunks exchanged between
the application and transport layers are error free.
Behrouz A. Forouzan” Data communications and Networking
14
Transport Layer Protocol
The transport layer in the TCP/IP suite is located between the application layer and the network layer. It provides services to the application layer and receives
services from the network layer. Following are the transport protocols in the
Internet/TCP/IP Protocol Suite. UDP (User data gram protocol) Unreliable connectionless transport-layer protocol used for its
simplicity and efficiency in applications where error control can be provided by the application-layer process.
TCP (Transmission Control protocol) Reliable connection-oriented protocol that can be used in any
application where reliability is important. SCTP
Combines the features of TCP and UDP.
Behrouz A. Forouzan” Data communications and Networking
15
UDP User Datagram Protocol (UDP)
Connectionless, unreliable transport protocol. It does not add anything to the services of IP except for providing
process-to-process communication instead of host-to-host communication.
UDP is a very simple protocol using a minimum of overhead. UDP packets called user datagrams,
Fixed-size header of 8 bytes made of four fields, each of 2 bytes (16 bits).
The first two fields define the source and destination port numbers.
Behrouz A. Forouzan” Data communications and Networking
16
UDP Packets-User datagram The third field defines the total length of the
user datagram, header plus data. The 16 bits can define a total length of 0 to
65,535 bytes. The total length needs to be less because a
UDP user datagram is stored in an IP datagram with the total length of 65,535 bytes.
The last field can carry the optional checksum
Behrouz A. Forouzan” Data communications and Networking
17
UDP Services
Process-to-Process Communication Using socket addresses, a combination of IP addresses
and port numbers. Connectionless Services
Independent datagram, No relationship between the different user datagrams even if they are coming from the same source process and going to the same destination program, Datagrams are not numbered.
There is no connection establishment and no connection termination. Each user datagram can travel on a different path.
Flow Control There is no flow control, and hence no window
mechanism.
Behrouz A. Forouzan” Data communications and Networking
18
UDP Services Error Control
No error control mechanism in UDP except for the checksum.
Sender does not know if a message has been lost or duplicated.
When the receiver detects an error through the checksum, the user datagram is silently discarded.
Checksum UDP checksum calculation includes three sections.
A pseudo-header The UDP header And the data coming from the application layer.
Behrouz A. Forouzan” Data communications and Networking
19
UDP-Checksum
Checksum includes the pseudo-header to ensure that the datagram is not delivered to the wrong host in case the IP address is corrupted.
The protocol field is added to ensure that the packet belongs to UDP, and not to TCP.
The value of the protocol field for UDP is 17.
If this value is changed during transmission, the checksum calculation at the receiver will detect it and UDP drops the packet.
Behrouz A. Forouzan” Data communications and Networking
20
UDP Services Congestion Control
No congestion control UDP does not create additional traffic in an error-prone
network. Therefore, in some cases, lack of error control in UDP can be considered an advantage when congestion is a big issue.
Encapsulation and Decapsulation To send a message from one process to another, the UDP
protocol encapsulates and decapsulates messages.
Multiplexing and Demultiplexing In a host running a TCP/IP protocol suite, there is only one
UDP but possibly several processes that may want to use the services of UDP. To handle this situation, UDP multiplexes and demultiplexes.
Behrouz A. Forouzan” Data communications and Networking
21
Transmission control protocol (TCP) Transmission Control Protocol (TCP)
A connection-oriented, reliable protocol.
TCP explicitly defines connection establishment, data transfer, and connection teardown phases to provide connection oriented service.
TCP uses checksum (for error detection), retransmission of lost or corrupted packets, cumulative and selective acknowledgments, and timers.
Behrouz A. Forouzan” Data communications and Networking
22
TCP Services Process-to-Process Communication
Provides process-to-process communication using port numbers Stream Delivery Service
In TCP the sending process delivers data as a stream of bytes and allows the receiving process to obtain data as a stream of bytes.
In TCP two processes seem to be connected by an imaginary “tube” that carries their bytes across the Internet.
Behrouz A. Forouzan” Data communications and Networking
23
TCP Services
Full-Duplex Communication 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 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: The two TCP’s establish a logical connection between them. Data are exchanged in both directions. The connection is terminated. 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.
Behrouz A. Forouzan” Data communications and Networking
24
TCP Packets/Segments
A packet in TCP is called a segment. Format
Behrouz A. Forouzan” Data communications and Networking
25
Format Header: The segment consists of a header of 20 to 60 bytes,
followed by data from the application program. 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.
Sequence number. This 32-bit field defines the number assigned to the first byte of data contained in this segment.
Acknowledgment number. This 32-bit field defines the byte number that the receiver of the segment is expecting to receive from the other party.
Header length. This 4-bit field indicates the number of 4-byte words in the TCP header.
Behrouz A. Forouzan” Data communications and Networking
26
Format
Window size. This field defines the window size of the sending TCP in bytes.
Checksum. This 16-bit field contains the checksum. The calculation of the checksum for TCP follows the
same procedure as the one described for UDP. The use of the checksum in the UDP datagram is
optional, whereas the use of the checksum for TCP is mandatory.
The pseudoheader serves the same purpose as in UDP. For the TCP pseudoheader, the value for the protocol field is
6.
Behrouz A. Forouzan” Data communications and Networking
27
Format
Urgent pointer. This 16-bit field, which is valid only if the urgent flag is set, is used when the segment contains urgent data.
28
Encapsulation
Frameheader
IPheader
Application-layer dataTCPheader
Data-link layer payload
IP payload
TCP payload
Behrouz A. Forouzan” Data communications and Networking
29
TCP Connection
TCP is connection-oriented. It establishes a virtual path between the source and destination. All of the segments belonging to a message are then sent over
this virtual path. You may wonder how TCP, which uses the services of IP, a
connectionless protocol, can be connection-oriented. The point is that a TCP connection is virtual, not physical. TCP operates at a higher level. TCP uses the services of IP to
deliver individual segments to the receiver, but it controls the connection itself. If a segment is lost or corrupted, it is retransmitted.
A SYN segment cannot carry data, but it consumes one sequence number. A SYN + ACK segment cannot carry data, but does consume one sequence
number. An ACK segment, if carrying no data, consumes no sequence number
.
TCP/IP Protocol Suite
30
Connection establishment using three way handshake Figure 15.9
Behrouz A. Forouzan” Data communications and Networking
31
Data Transfer
Behrouz A. Forouzan” Data communications and Networking
32
Connection termination using three-way handshake
The FIN segment consumes one sequence number if it does not carry data.The FIN + ACK segment consumes one sequence number if it does not carry data.
Behrouz A. Forouzan” Data communications and Networking
33
Congestion Control In the Internet, TCP plays the main role in controlling
congestion, as well as the main role in reliable transport. TCP uses the following techniques for congestion control
A congestion window TCP congestion window size is the number of bytes the sender may
have in the network at any time. Congestion policy that avoid congestion and detect and alleviate
congestion after it has occurred. The congestion window is maintained in addition to the flow
control window, which specifies the number of bytes that the receiver can buffer.
Both windows are tracked in parallel, and the number of bytes that may be sent is the smaller of the two windows.
Thus, the effective window is the smaller of what the sender thinks is all right and what the receiver thinks is all right.
TCP will stop sending data if either the congestion or the flow control window is temporarily full.
Behrouz A. Forouzan” Data communications and Networking
34
Congestion Control
Congestion Window The use of flow control strategy at the transport layer guarantees
that the receive window is never overflowed with the received bytes (no end congestion).
Intermediate buffers, buffers in the routers can become congested.
TCP needs to define policies that accelerate the data transmission when there is no congestion and decelerate the transmission when congestion is detected.
To control the number of segments to transmit, TCP uses a variable called a congestion window, cwnd, whose size is controlled by the congestion situation in the network.
The size of the window is the minimum of the cwnd variable and the rwnd variable.
Actual window size = minimum (rwnd, cwnd)
Behrouz A. Forouzan” Data communications and Networking
35
Congestion Policy
Congestion Policies TCP’s general policy for handling congestion is
based on three algorithms: slow start, congestion avoidance, and fast recovery.
Slow Start Algorithm In the slow start algorithm, the size of the
congestion window increases exponentially until it reaches a threshold.
Congestion Avoidance Algorithm In the congestion avoidance algorithm the size of
the congestion window increases additively until congestion is detected.
Behrouz A. Forouzan” Data communications and Networking
36
Slow Start Algorithm When a connection is established, the
sender initializes the congestion window to a small initial value of at most four segments
The sender then sends the initial window.
The packets will take a round-trip time to be acknowledged.
For each segment that is acknowledged before the retransmission timer goes off, the sender adds one segment’s worth of bytes to the congestion window.
As that segment has been acknowledged, there is now one less segment in the network.
The upshot is that every acknowledged segment allows two more segments to be sent.
The congestion window is doubling every round trip time.
This algorithm is called slow start
Behrouz A. Forouzan” Data communications and Networking
37
Congestion avoidance algorithm/Additive Increase
If we continue with the slow-start algorithm, the size of the congestion window increases exponentially.
To avoid congestion before it happens, we must slow down this exponential growth.
TCP defines another algorithm called congestion avoidance, which increases the cwnd additively instead of exponentially.
In the congestion-avoidance algorithm, the size of the congestion window increases additively until congestion is detected.