Session 4 Transport Layer Updated
Session 4 Transport Layer Updated
1
Session Objectives
2
22
Session Topics
• Transport Layer
• Position of Transport Layer
• Transport Layer Duties
• IP Addresses Vs Port Numbers
• Multiplexing & Demultiplexing
• Connection Establishment
• Connection Termination
• User Datagram Protocol (UDP)
• User Datagram Format
• Transmission Control Protocol (TCP)
• Well-known ports used by TCP
• TCP Segments
• TCP Segment Format
• State Transition Diagram.
• TCP Sliding Windows 3
33
Transport Layer
4
44
Transport Layer
• Using this method, the computer sending the data connects directly to
the computer it is sending the data to, and stay connected for the
duration of the transfer.
• With this protocol, the two computers can guarantee that the data has
arrived safely and correctly, and then they disconnect the connection.
5
55
Transport Layer
• You have a conversation and when it is over, you both hang up,
releasing the connection.
6
66
Transport Layer
• The transport layer is responsible for delivery of a message from one
process to another.
• It receives services from the network layer and provides services to the
application layer.
7
77
Position of Transport Layer
8
8
Transport Layer Duties
9
99
Process-to-Process Delivery
11
11
IP Addresses and Port
Numbers
12
12
IP Addresses and Port Numbers
• As you know every computer or device on the Internet must have a
unique number assigned to it called the IP address.
13
13
13
IP Addresses and Port Numbers
• You can have a total of 65,535 TCP Ports and another 65,535 UDP
ports.
14
14
14
IP Addresses and Port Numbers
• If it uses the TCP protocol to send and receive the data then it will
connect and bind itself to a TCP port.
• If it uses the UDP protocol to send and receive data, it will use a UDP
port.
• Once an application binds itself to a particular port, that port can not be
used by any other application.
16
16
IANA Ranges
17
17
17
IANA Ranges
• Registered ports.
• The ports ranging from 1024 to 49,151 are not assigned or controlled by IANA.
They can only be registered with IANA to prevent duplication.
• Dynamic ports.
• The ports ranging from 49,152 to 65,535 are neither controlled nor registered.
They can be used by any process.
18
18
18
Socket Address
19
19
Multiplexing &
Demultiplexing
20
20
Client-Server Model
21
21
Client-Server Relationship
22
22
Client-Server Iterative Server
23
23
Connection Oriented Concurrent
Server
24
24
Types of Sockets
UDP Sockets
• They are connectionless in nature
• The packets are not guaranteed to be in sequence or error free
25
25
TCP Socket – Function Calls
26
26
Socket Interface for Connectionless
Iterative Server
27
27
User Datagram Protocol (UDP)
• UDP is a connectionless, unreliable protocol that has no flow and error
control. It uses port numbers to multiplex data from the application
layer.
• Using this protocol, the computer sending the data, packetizes the
information into small packets and releases it into the network with the
hopes that it will get to the right place.
28
28
28
User Datagram Protocol (UDP)
• What this means is that UDP does not connect directly to the
receiving computer like TCP does, but rather sends the data out and
relies on the devices in between the sending computer and the
receiving computer to get the data where it is supposed to go
properly.
29
29
29
User Datagram Protocol (UDP)
• A comparison you can use for this method is the plain Postal Service.
• You place your mail in the mailbox and hope the Postal Service will
get it to the proper location.
• Most of the time they do, but sometimes it gets lost along the way.
30
30
30
Well-known Ports Used by UDP
Port Protocol Description
7 Echo Echoes a received datagram back to the sender
9 Discard Discards any datagram that is received
11 Users Active users
13 Daytime Returns the date and the time
17 Quote Returns a quote of the day
19 Chargen Returns a string of characters
53 Nameserver Domain Name Service
67 Bootps Server port to download bootstrap information
68 Bootpc Client port to download bootstrap information
69 TFTP Trivial File Transfer Protocol
111 RPC Remote Procedure Call
123 NTP Network Time Protocol
161 SNMP Simple Network Management Protocol
162 SNMP Simple Network Management Protocol (trap)
31
31
User Datagram Format
32
32
User Datagram Format
• The calculation of checksum and its inclusion in the user datagram are
optional.
33
33
33
Transmission Control Protocol (TCP)
• The unit of data transfer between two devices using TCP software is
called a segment.
36
36
Sending & Receiving Buffers
37
37
TCP Segments
38
38
TCP Segments
• The bytes of data being transferred in each connection are numbered
by TCP. The numbering starts with a randomly generated number.
39
39
39
TCP Segment Format
❑ 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. The length of the header can be between 20 and 60 bytes.
Therefore, the value of this field is always between 5 (5 × 4 = 20) and 15 (15
× 4 = 60).
❑ Control. This field defines 6 different control bits or flags. One or more of
these bits can be set at a time. 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
❑ 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.
However, the use of the checksum in the UDP datagram is optional, whereas
the use of the checksum for TCP is mandatory.
❑ Urgent pointer. This 16-bit field, which is valid only if the urgent flag is
set, is used when the segment contains urgent data. It defines a value 40 that
must be added to the sequence number to obtain the number of the last
Control Field
The PSH flags instruct the operating system to send (for the sending side) and
receive (for the receiving side) the data immediately.
41
41
Connection Establishment
• Three protocol scenarios for establishing a connection using a three-
way handshake
• CR denotes CONNECTION REQUEST
42
42
Connection Release
43
43
Connection Release
• Four protocol scenarios for releasing a connection
• (a)Normal case of a three-way handshake
• (b) final ACK lost
44
44
Connection Release
• (c) Response lost
• (d) Response lost and subsequent DRs lost
6-14, c,d
45
45
Summary
• The transport layer is responsible for the process to process delivery
of the entire message.
46
46
46
References
• Behrouz A. Forouzan, Data Communication and Networking, 2nd
edition, Tata McGraw-Hill, 2000
• http://www.opengroup.org/onlinepubs/.html
• http://www.e-zest.net/socket_programming-India.html
47
47
47