0% found this document useful (0 votes)
5 views28 pages

05 Tcpip3 Slides

The document discusses the transport layer of TCP/IP, focusing on the roles of Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). TCP provides a reliable, connection-oriented service, while UDP offers a connectionless and unreliable service, both utilizing IP for packet delivery. It also covers port numbers, their classifications, and the structure of TCP and UDP packet headers, emphasizing the importance of these elements in establishing connections and ensuring data integrity.

Uploaded by

alemislami0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views28 pages

05 Tcpip3 Slides

The document discusses the transport layer of TCP/IP, focusing on the roles of Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). TCP provides a reliable, connection-oriented service, while UDP offers a connectionless and unreliable service, both utilizing IP for packet delivery. It also covers port numbers, their classifications, and the structure of TCP and UDP packet headers, emphasizing the importance of these elements in establishing connections and ensuring data integrity.

Uploaded by

alemislami0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

TCP / IP, part 3

Introduction
In TCP/IP, the transport layer consists of two different
protocols.
⋅ Transmission control protocol (TCP).
⋅ User datagram protocol (UDP).
Basic idea:
⋅ User processes (applications) interact with the TCP/IP
protocol suite by sending/receiving TCP or UDP data.
⋅ Both TCP and UDP in turn use the IP layer for delivery of
packets.
TCP and UDP
TCP User process UDP User process

TCP UDP

IP

Datalink and Physical


Role of TCP
Provides a connection-oriented, reliable, full-duplex, byte-
stream service.
⋅ Underlying IP layer is unreliable and provides
connectionless delivery service.
⋅ TCP provides end-to-end reliability using
⋅ Checksums
⋅ Positive acknowledgements
⋅ Timeouts
⋅ End-to-end flow control.
Role of TCP
TCP also handles
⋅ Establishment and termination of connections between
processes.
⋅ Sequencing of data, needed since data might reach the
destination in any arbitrary order.
Role of UDP

UDP provides a connectionless and unreliable datagram


service.
⋅ Very similar to IP in this respect
⋅ Provides two features that are not there in IP:
⋅ A checksum to verify the integrity of the UDP packet
⋅ Port numbers to identify the processes at the two ends.
Port Numbers

⋅ Multiple user processes on a machine may use TCP or UDP


at the same time.

⋅ There is need for a mechanism to uniquely identify the
data packets associated with each process.
Port Numbers

Process 1 Port 100


Packet
Process 2 Port 200 (destination port 200)

Process 3 Port 300

Host
Port Numbers

⋅ Both TCP and UDP use 16-bit integer port numbers


⋅ Different applications are identified by different port
numbers.
⋅ Port numbers are stored in the headers of TCP or UDP
packets.
User process User process

Port address:16 bits


TCP UDP (2 Bytes)

IP Internet address: 32 bits


(4 Bytes)

Datalink and Physical Physical address: 48 bits


(6 Bytes)
Port Numbers
Client-server scenario
⋅ A client can connect to the server by knowing the 32-bit
IP address of the server.
⋅ To identify a particular process running on the server ,
the client mult also know the corresponding port number
of the process.
Well-known port numbers
⋅ Predefined and publicly known.
⋅ Example: FTP uses post 21, SMTP uses port 25.
Port Numbers
Well-known port numbers are stored in a particular file on the
host machine.
⋅ Linux: /etc/services
⋅ Windows: C:\WINDOWS\System32\drivers\etc\services
⋅ Each line has the format:
<service name> <port number>/<protocol> [aliases…] [#<comment>]
Services file, which contains information about the known
services on your network.
Few lines of the file are shown next
echo 7/tcp
echo 7/udp
systat 11/tcp users
daytime 13/tcp
daytime 13/udp
ftp-data 20/tcp
ftp 21/tcp
telnet 23/tcp
smtp 25/tcp mail
time 37/tcp timeserver
Ephemeral Port Numbers
Example:
⋅ A client process sends a message to a server process
located on some host at port 1534.
⋅ How will the server know where to respond?
⋅ Client process requests an unused port number from
the TCP/UDP module on its local host
⋅ These are temporary port numbers, called ephemeral
port numbers
⋅ Sent along with the TCP or UDP header.
Types of Port Numbers

⋅ Port numbers from 0 to 1023 (0 to 210 − 1) are called


well-known or system ports and are reserved.
⋅ Ports 1024 to 49151 (210 to 214 + 215 − 1) are called
registered ports. They are assigned by IANA for specific
service upon application by a requesting entity.
⋅ Ports 49152 to 65535 (215 + 214 to 216 − 1) are called
dynamic or private or ephemeral ports . They cannot be
registered with IANA.
Connection Establishment
A hierarchical addressing scheme is used to define a
connection path between two hosts.
⋅ IP address
⋅ Identifies the communicating hosts.
⋅ Protocol identifier
⋅ Identifies the transport later protocol being used (TCP,
UDP or anything else).
⋅ Port number
⋅ Identifies the communicating processes in the two
hosts.
Association
A set of five values that describe a unique process-to-process
connection is called an association
⋅ the protocol (TCP or UDP)
⋅ local host IP address (32-bit value)
⋅ local port number (16-bit value)
⋅ remote host IP address (32-bit value)
⋅ remote port number (16-bit value)
Example of an association:
{TCP, 144.16.192.5, 1785, 144.16.202.57, 21}
Format of TCP packet header

0 15 16 31
Source Port Destination Port
Sequence Number
Acknowledgment Number Header of
U A P R S F TCP
HLEN Reserved R C S S Y I Window
(4 bit) (6 bit) G K H T N N Datagram
Checksum Urgent Pointer
Options Padding

Data of
Data TCP Packet
(Payload)
TCP Header Fields
Source port (16 bits)
⋅ Identifies the process at the source.
Destination port (16 bits)
⋅ Identifies the process at the destination.
Sequence number (32 bits)
⋅ Used for reliable delivery of message
⋅ Each byte of message is assigned a 32-bit number that is
incremented sequentially. Specifies the number assigned to the
first byte of data in the encapsulated TCP message segment.
TCP Header Fields
Acknowledgment Number (32 bits)
⋅ Used by remote host to acknowledge receipt of data.
⋅ Contains the number of the next byte expected to be
received.
HLEN (Header Length) a.k.a. Data Offset field (4 bits)
⋅ Specifies the header length in number of 32-bit words.
⋅ This information is needed because the Options field has
variable length, so the header length is variable too.
Reserved field (6 bits) must be zero. This is for future use.
TCP Header Fields
Flags (6 bits) - There are six flags.
URG—Indicates that the urgent pointer is in use.
ACK—Indicates that acknowledgement number is valid.
PSH—(push) Indicates that data should be passed to the
application as soon as possible, end of message.
RST—Resets the connection. It is also used to reject a
connection attempt
SYN—Synchronizes sequence numbers to initiate a connection.
FIN—Means that the sender of the flag has finished sending
data.
⋅ A connection request is sent by making SYN=1 and ACK=0.
⋅ A connection is confirmed by sending SYN=1 and ACK=1.
⋅ When the sender has no more data, FIN=1 is sent to
release the connection.
TCP Header Fields

Window (16 bits)


• Specifies how many bytes may be sent beyond the
byte acknowledged.
• This number, called window advertisement can
increase or decrease as needed
• A value of zero closes the window altogether.
TCP Header Fields (contd.)
Checksum (16 bits)
⋅ Applies to the entire segment and a pseudo-header.
⋅ The pseudo-header contains the following IP header
fields:
⋅ Source IP address, destination IP address, protocol,
segment length.
⋅ TCP protects itself from misdelivery by IP (delivered to
wrong host)
⋅ Same algorithm as used in IP.
Urgent pointer field (16 bits) points to the first urgent
data byte in the packet.

Options field (variable length) specifies various TCP


options.

Data field (variable length) contains upper-layer information.


Format of UDP Packet

0 15 16 31
Source Port Destination Port
Length Checksum

Data
UDP header fields
Source port 16 bit
⋅ Identifies the process at the local end
Destination port 16 bit
⋅ Identifies the process at the remote end
Length 16 bit
⋅ Specifies the size of the datagram in bytes (UDP header
plus data)
Checksum 16 bit
⋅ Computed in the same way as TCP. Filled with zeros if not
used. Optional in IPv4, mandatory in IPv6.
Berkeley Socket Interface
How to develop a network application?
⋅ The best way is to use some standard and well-accepted
protocol.
⋅ At the data fink layer level, use Ethernet
⋅ At the network layer level, use IP.
⋅ At the transport layer level, use TCP.
⋅ At the application layer level, use a standard API like the
Berkeley Socket Interface

You might also like