I N THE N AME OF G OD C OMPUTER N ETWORKS C HAPTER 6: T HE T RANSPORT L AYER Dr. Shahriar Bijani Shahed University May 2014
References: Computer Networks A. S. Tanenbaum and D. J. Wetherall, Computer Networks (5th Edition), Pearson Education, the book slides, 2011. B. A. Forouzan, Introduction to the Transport Layer, TCP/IP Protocol Suite, 5th Edition, McGraw Hill, lecture slides, 2012. 2
T HE OSI M ODEL TCP/IP 3 PHYSICAL DATA LINK NETWORK TRANSPORT SESSION PRESENTATION APPLICATION
T HE T RANSPORT LAYER DUTIES Packetizing Sender side: breaks application messages into segments, passes them to network layer Transport layer at the receiving host deliver data to the receiving process Connection control Connection-oriented Connectionless Addressing Port numbers to identify which network application Reliability Flow control Error Control
PROCESS-TO-PROCESS DELIVERY The transport layer is responsible for process- to-process delivery: the delivery of a packet, part of a message, from one process to another. Two processes communicate in a client/server relationship,The transport layer is responsible for process- to-process delivery: the delivery of a packet, part of a message, from one process to another. Two processes communicate in a client/server relationship, In Client/Server communication, four entities must be defined: Sending Node Local Host IP Local Process Port number Receiving Node Remote host IP Remote Process ID Port number
P ROCESSES COMMUNICATING ACROSS NETWORK Process is an instance of a program in execution. Processes on two hosts communicate with each other by sending and receiving messages The process receives messages from, and sends messages into the network through its socket A socket is the interface between the application layer and the transport layer within a host. Sockets are the programming interface used to build network applications over the internet. Programmers can select which transport layer protocol (UDP or TCP) to be used by the application and select few transport-layer parameters (maximum buffer size, Maximum segment size, starting sequence number of segment).
T RANSPORT S ERVICE Upper Layer Services Transport Service Primitives Berkeley Sockets
S ERVICES P ROVIDED TO THE U PPER L AYERS The network, transport, and application layers
T RANSPORT S ERVICE P RIMITIVES (1) The primitives for a simple transport service
T RANSPORT S ERVICE P RIMITIVES (2) Nesting of TPDUs, packets, and frames.
B ERKELEY S OCKETS (1) A state diagram for a simple connection management scheme. Transitions labeled in italics are caused by packet arrivals. The solid lines show the client’s state sequence. The dashed lines show the server’s state sequence.
B ERKELEY S OCKETS (2) The socket primitives for TCP
E XAMPLE OF S OCKET P ROGRAMMING : A N I NTERNET F ILE S ERVER (1)... Client code using sockets
E XAMPLE OF S OCKET P ROGRAMMING : A N I NTERNET F ILE S ERVER (2)... Client code using sockets
E XAMPLE OF S OCKET P ROGRAMMING : A N I NTERNET F ILE S ERVER (3)... Client code using sockets
E XAMPLE OF S OCKET P ROGRAMMING : A N I NTERNET F ILE S ERVER (4)... Server code
E XAMPLE OF S OCKET P ROGRAMMING : A N I NTERNET F ILE S ERVER (5)... Server code...
E XAMPLE OF S OCKET P ROGRAMMING : A N I NTERNET F ILE S ERVER (6)... Server code
E LEMENTS OF T RANSPORT P ROTOCOLS (1) Addressing Connection establishment Connection release Error control and flow control Multiplexing Crash recovery
E LEMENTS OF T RANSPORT P ROTOCOLS (2) (a) Environment of the data link layer. (b) Environment of the transport layer.
A DDRESSING TSAPs (Transport Service Access Points)= port number NSAPs (Network Service Access Points)
A DDRESSING How a user process in host 1 establishes a connection with a mail server in host 2 via a process server.
Port numbers Transport layer at the receiving host delivers data to the socket There should be a unique identifier for each socket. Socket identifier is called socket address Socket address = IP address & Port number
Error control Why we need error control at the transport layer?
C ONNECTION E STABLISHMENT Establishing a connection sounds easy, but it is actually surprisingly tricky. At first glance, it would seem sufficient for one transport entity to just send a CONNECTION REQUEST TPDU to the destination and wait for a CONNECTION ACCEPTED reply. The problem occurs when the network can lose, store, and duplicate packets. This behavior causes serious complications. Restrict packet lifetime Equipping each host with a time-of-day clock. Three-way handshake
C ONNECTION E STABLISHMENT Techniques for restricting packet lifetime Restricted network design. Putting a hop counter in each packet. Timestamping each packet.
C ONNECTION E STABLISHMENT (2) (a) TPDUs may not enter the forbidden region. (b) The resynchronization problem.
C ONNECTION E STABLISHMENT Three protocol scenarios for establishing a connection using a three-way handshake. CR denotes CONNECTION REQUEST. Normal operation.
C ONNECTION E STABLISHMENT Three protocol scenarios for establishing a connection using a three-way handshake. CR denotes CONNECTION REQUEST. Old duplicate CONNECTION REQUEST appearing out of no-where.
C ONNECTION E STABLISHMENT Three protocol scenarios for establishing a connection using a three-way handshake. CR denotes CONNECTION REQUEST. Duplicate CONNECTION REQUEST and duplicate ACK
C ONNECTION R ELEASE Sudden disconnection with loss of data
C ONNECTION R ELEASE Four protocol scenarios for releasing a connection. (a) Normal case of three-way handshake
C ONNECTION R ELEASE (4) Four protocol scenarios for releasing a connection. (b) Final ACK lost.
C ONNECTION R ELEASE (5) Four protocol scenarios for releasing a connection. (c) Response lost
C ONNECTION R ELEASE (6) Four protocol scenarios for releasing a connection. (d) Response lost and subsequent DRs lost.
M ULTIPLEXING (a) Multiplexing. (b) Inverse multiplexing.
44 M ULTIPLEXING / DEMULTIPLEXING segment - unit of data exchanged between transport layer entities Demultiplexing: delivering received segments to correct app layer processes application transport network M P2 application transport network receiver H t H n segment M application transport network P1 MMM P3 P4 segment header application-layer data How hosts handle more than one session simultaneously sender A sender B
45 M ULTIPLEXING / DEMULTIPLEXING multiplexing/demultiplexing in the Internet: based on sender, receiver port numbers, IP addresses source, dest port #s in each segment recall: well-known port numbers for specific applications gathering data from multiple app processes, enveloping data with header (later used for demultiplexing) source port #dest port # 32 bits application data (message) other header fields TCP/UDP segment format Multiplexing:
46 M ULTIPLEXING / DEMULTIPLEXING : EXAMPLES host A server B source port: x dest. port: 23 source port:23 dest. port: x port use: simple telnet app (Note how port 23 at server must be shared whereas port x at host can be reserved) Web client host A Web server B Web client host C Source IP: C Dest IP: B source port: x dest. port: 80 Source IP: C Dest IP: B source port: y dest. port: 80 port use: Web server Source IP: A Dest IP: B source port: x dest. port: 80 Q: how does the server know which packets go with which process?
U SER D ATAGRAM P ROTOCOL (UDP) Connectionless No handshaking between UDP sender, receiver Each UDP segment handled independently of others A server application that uses UDP serves only ONE request at a time. All other requests are stored in a queue waiting for service. Unreliable protocol has no flow and error control A UDP segment can be lost, arrive out of order, duplicated, or corrupted Checksum field checks error in the entire UDP segment. It is Optional UDP doe not do anything to recover from an error it simply discard the segment Application accepts full responsibility for errors It uses port numbers to multiplex/demultiplex data from/to the application layer. Advantages: Simple, minimum overhead, no connection delay Services provided by UDP: Process-to-Process delivery Error checking (however, if there is an error UDP does NOT do anything to recover from error. It will just discard the message
UDP A PPLICATIONS Used for applications that can tolerate small amount of packet loss: Multimedia applications, Internet telephony, real-time-video conferencing Domain Name System messages Audio Routing Protocols
User datagram format Header size = 8 bytes Minimum UDP process data size 0 bytes Maximum UDP process data size= 65535 – 20 (network layer headers) - 8 (UDP headres)= 65507 bytes
T RANSMISSION C ONTROL P ROTOCOL (TCP) Transmission Control Protocol properties: Connection-oriented (establishment & termination) Reliable Full-duplex
C ONNECTION -O RIENTED Connection oriented means that a virtual connection is established before any data is transferred. Connection ensures that the receiving process is available and ready before the data is sent Three-way handshaking connection establishment procedure because TCP is full-duplex both side must initialize communication and get approval from the other side before any data transfer, Virtual connection since TCP protocol will make sure that segments are given to the receiver application in the same order as they were sent by the sender even if they travel through different physical paths A server application that uses TCP can handle many client requests at the same time each has its own connection.
Connection establishment and termination Connection establishment Connection release Combined into one step
Stream delivery TCP establishes a virtual connection TCP will deliver segments to the applications in order and without error, lost, or duplicates
F ULL D UPLEX Data segments can flow in both directions at the same time. Each TCP connection has its own sending and receiving buffers.
F LOW CONTROL AND R ELIABILITY Flow control (process-to-process): TCP makes sure that the sender does not cause the receiver buffer to overflow By defining the amount of data that can be sent before receiving an acknowledgement from the receiver (sliding – window protocols) Error control (process-to-process): entire message arrives at the receiving transport layer without error, loss, duplication and in the same order they were sent Error detection is done using checksum and correction by retransmission Implemented by a sliding window ARQ Every transmission of data is acknowledged by the receiver. Acknowledgements are cumulative. If the sender does not receive ACK within a specified amount of time, the sender retransmits the data. Accepts out of order but does Not send negative acknowledgements, if a segment is not acknowledged before time-out, it is considered to be either corrupted or lost and the sender will retransmit the segment only when it times-out
TCP A PPLICATIONS Following applications require reliable data transfer through TCP: WWW using HTTP Electronic mail using SMTP Telnet File transfer using FTP
TCP segment format Minimum header length is 20 bytes and the maximum is 60 bytes when there are options