Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 56

System Programming and Computer Control

CT047-3-2-SPCC

Process-to-Process Delivery:
UDP and TCP
Level-2

Prepared by: KL First Prepared on: 9-09-07 Last Modified on:


Quality checked by: xxx
Copyright 2007 Asia Pacific Institute of Information Technology
Topic & Structure of the lesson

• Process to Process Delivery

• User Datagram Protocol (UDP)

• Transmission Control Protocol (TCP)

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Learning Outcomes

• At the end of this session you should be


able to:-
– Understand rationale for the existence of the
transport layer – the need for process-to-
process delivery.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Key Terms you must be able to use

If you have mastered this topic, you should be able to use the following terms
correctly in your assignments and exams:-
– Client – Port number
– Client-server paradigm – Process-to-process delivery
– Connection establishment – Receiver window
– Connection termination
– Retransmission timer
– Connectionless service
– Connection-oriented service – Round-trip time (RTT)
– Ephemeral port number – Segment
– Finite state machine – Sender window
– Flow control – Sequence number
– Keep-alive timer – Server
– Persistence timer – Silly windows syndrome

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Key Terms you must be able to use

If you have mastered this topic, you should be able to use the following terms
correctly in your assignments and exams:-

– Sliding window – Transmission Control


– Socket address Protocol (TCP)
– State transition diagram – User datagram
– TCP timer – User Datagram Protocol
– Three-way handshake (UDP)
– Time-waited timer – Well-known port numbers

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Position of transport layer

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Transport Layer

• The transport layer is the core of the Internet


model. It is the fourth layer in the model. This
layer receives services from the network
layer and provides services to the application
layer.
• Function of transport layer (Duties)
– Packetizing
– Connection control
– Addressing
– Providing reliability
CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Transport layer duties

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Packetizing

• The transport layer creates packets out of the


message received from the application layer.
• Packetizing divides a long message into
smaller ones and encapsulated into the data
field of the transport-layer packet and
headers are added.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Connection control

There are two categories:


Connection-oriented Delivery
• Create virtual connection between sender and
receiver
• The packets are numbered consecutively and
communication can take place in both directions.
Connectionless Delivery
• Treats each packet independently without
connection between them.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Addressing

• The packet carrying the request must specify


to which server program the request must be
delivered.
• The request packet must also specify the
client program that sent the packet.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Providing reliability

• A transport layer can provide reliability for the


application program that uses its service.
– Flow Control
• Performed end to end
– Error Control
• The entire message arrives at the receiving transport
layer without error (damage, loss, or duplication). Error
correction is usually achieved through retrasmission.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Process-to-Process Delivery

• Node-to-node delivery is responsible for


delivery of frames between two neighboring
nodes over link.
• Host-to-host delivery is responsible for
delivery of datagram between two hosts.
• Process-to-process delivery communication
takes place between two processes
(application programs).

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Note

Note:

The transport layer is responsible for


process-to-process delivery.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Types of data deliveries

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Process-to-Process Delivery

1. Client-Server Paradigm
2. Addressing
3. Multiplexing and Demultiplexing
4. Connectionless/Connection-Oriented
5. Reliable/Unreliable

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
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.
• Operating system today support both multiuser and
multiprogramming environments. A remote
computer can run several server programs at the
same time, just as local computers can run one or
more client programs at the same time.
– Local host
– Local process
– Remote host
– Remote process

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Addressing

• A transport-layer address, called a port


number, to choose among multiple processes
running on the destination host.
• The destination port number is needed for
delivery; the source port number is needed
for the reply.
• Ephemeral port number are 16-bit integers
between 1024 and 65,535.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Port numbers

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Addressing

• The Internet has decided to use universal port


numbers for servers; these are called well-
known port numbers.
• The IP addresses and port numbers play
different roles in selecting the final destination
of data.
• The destination IP address defines the host
among the different hosts in the world. After the
host has been selected, the port number
defines one of the processes on this particular
host.
CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
IP addresses versus port numbers

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Address – IANA Ranges

• The IANA (Internet Assigned Number


Authority) has divided the port numbers into
three ranges:
– Well-known ports. The port ranging from 0 to 1023
are assigned and controlled by IANA.
– Registered ports. The ports ranging 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.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
IANA ranges

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Socket address

The combination of an IP address and a port number is called a socket


address.
A transport-layer protocol needs a pair of socket addresses: the client
socket address and the server socket address.
The UDP and TCP header contains the port numbers.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Multiplexing and demultiplexing

• The addressing mechanism allows multiplexing and


demultiplexing by the transport layer.
• Multiplexing: At the sender site, there may be
several processes that need to send packets. The
protocol accepts message from different processes.
After adding the header, the transport layer passes
the packet to the network layer.
• Demultiplexing: At the receiver site, the transport
layer delivers each message to the appropriate
process based on the port number.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Multiplexing and demultiplexing

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Connectionless vs Connection-Oriented

• A transport-layer protocol can either be


connectionless or connection-oriented.
Connectionless Service
• The packets are sent from one party to another with
no need for connection establishment or connection
release.
• The packets are not numbered; they may be
delayed, or arrive out of sequence.
• There is no acknowledgment either. Example UDP.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Connection Oriented Service

• A connection is first established between the sender and


the receiver. Data are transferred. At the end, the
connection is released. Example: TCP is a connection-
oriented protocol.
Connection Establishment
1. Host A sends a packet to announce its wish for connection and
includes its initialization information about traffic from A to B.
2. Host B send a packet to acknowledge (confirm) the request of A.
3. Host B sends a packet that includes its initialization information
about traffic from B to A.
4. Host A sends a packet to acknowledge (confirm) the request of B.
This connection establishment implies four steps. However,
since steps 2 and 3 can occur at the same time, they can be
combined into one step.
CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Connection establishment

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Connection Termination

• Connection in one direction is terminated, the other party can


continue sending data in the other direction. Therefore, four
actions needed to close the connections in both directions:
1. Host A sends a packet announcing its wish for connection termination.
2. Host B sends a segment acknowledging (confirming) the request of A.
After this, the connection is closed in one direction, but not in the other.
Host B can continue sending data to A.
3. When host B has finished sending its own data, it sends a segment to
indicate that it wants to close the connection.
4. Host A acknowledges (confirms) the request of B.
The four-step connection termination cannot be reduced to
three steps because the two parties may not wish to terminate
at the same time. In other words, connection termination is
asymmetric.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Connection Termination

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Reliable vs Unreliable

• The transport-layer service can be reliable or


unreliable.
• If the application-layer program needs reliability, we
use a reliable transport-layer protocol by
implementing flow and error control at the transport
layer.
• This mean a slower and more complex service.
• UDP is connectionless and unreliable
• TCP is connection-oriented and reliable.
• These two can respond to the demands of the
application-layer programs.
CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Error control

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
User Datagram Protocol (UDP)
1. Port Numbers
2. User Datagram
3. Applications

UDP does not add anything to the services of IP except for providing process-to-
process communication instead of host-to-host communication. Also, it performs
very limited error checking.
UDP is very simple protocol with a minimum of overhead.
UDP is a convenient protocol for multimedia and multicasting applications.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Note

Note:

UDP is a connectionless, unreliable


protocol that has no flow and error
control. It uses port numbers to
multiplex data from the application
layer.
CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
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)
CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
User Datagram Format

• Source port number. This is the port number used by the


process running on the source host.
• Destination port number. This is the port number used by the
process running on the destination host.
• Length. This is a 16-bit field that defines the total length of
the user datagram, header plus data.
• Checksum. This field is used to detect errors over the entire
user datagram (header plus data). This ensures that those
fields have not been changed from the source to the
destination. The calculation of the checksum and its
inclusion in a user datagram are option. If the checksum is
not calculated, the field is filled with 0s.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
User datagram format

UDP Packets, called user datagrams, have a fixed-size header of 8 bytes.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Note

Note:

The calculation of checksum and its


inclusion in the user datagram are
optional.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Application of UDP

• UDP is suitable for a process that requires simple


request-response communication with little concern
for flow and error control. It is not usually used for a
process that needs to send bulk data, such FTP.
• Internal flow and error control mechanisms.
• Multicasting capabilities are embedded in the UDP
software but not in the TCP software.
• UDP is used for some route updating protocols such
as Routing Information Protocol (RIP)
• UDP is used in conjunction with the Real Time
Transport Protocol (RTP) to provide a transport-
layer mechanism for real-time data.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Note

Note:

UDP is a convenient transport-layer


protocol for applications that provide
flow and error control. It is also used
by multimedia applications.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Transmission Control Protocol (TCP)

TCP is called a stream connection-oriented


and reliable transport protocol.
Port Numbers
Services
Sequence Numbers
Segments
Connection
Transition Diagram
Flow and Error Control
Silly Window Syndrome

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Port Numbers

• Like UDP, TCP uses port numbers as


tranport-layer addresses.
• If an application can use both UDP and TCP,
the same port number is assigned to this
application.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Well-known ports used by TCP
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
  20 FTP, Data File Transfer Protocol (data connection)
  21 FTP, Control File Transfer Protocol (control connection)
  23 TELNET Terminal Network
  25 SMTP Simple Mail Transfer Protocol
  53 DNS Domain Name Server
  67 BOOTP Bootstrap Protocol
  79 Finger Finger
  80 HTTP Hypertext Transfer Protocol
111 RPC
CT047-3-2 Systems Programming and Computer Control
Remote Procedure Call
Process to Process to delivery UDP and TCP
Stream delivery

• TCP, is steam-oriented protocol. In UDP, a process (an


application program) sends a chunk of bytes to UDP for
delivery. UDP adds its own header to this chunk of data,
which is now called a user datagram, and delivers it to IP for
transmission. The process may deliver several chunks of
data to the UDP, but UDP treats each chunk independently
without seeing any connection between them.

• TCP, on the other hand, allows the sending process to


deliver data as a stream of bytes and the receiving process
to obtain data as a stream of bytes. TCP creates an
environment in which the two processes seem to be
connected by an imaginary. “tube” that carries their data
across the Internet.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Stream delivery

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Sending and receiving buffers

• The sending and the receiving processes


may not produce and consume data at the
same speed. TCP needs buffers for storage.
• There are two buffers, the sending buffer and
the receiving buffer, for each direction.
• One way to implement a buffer is to use a
circular array of 1-byte locations.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Sending and receiving buffers

At the sending site, the buffer has three types of locations. The white section contains
empty locations that can be filled by the sending process.
The blue area hold bytes that have been sent but not yet acknowledged.
The bytes in blue locations area acknowledged, the location is recycled and available
for use by the sending process.
After both processes have no data left to send and the buffers are empty, the two
TCPs destroy their buffers.
CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
TCP segments

• TCP groups a number of bytes together into a


packet called a segment.
• TCP adds a header to each segment and delivers
the segment to the IP layer for transmission.
• The segments are encapsulated in an IP datagram
and transmitted.
• The segments are not necessarily the same size. In
reality segments carry hundreds, if not thousands,
of bytes.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
TCP segments

There is no field for a segment number value. Instead, there are two field called
the sequence number and the acknowledgment number. These two fields refer
to the byte number, not the segment number.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Note

Note:

The bytes of data being transferred in


each connection are numbered by TCP.
The numbering starts with a randomly
generated number.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Note

Note:

The value of the sequence number field


in a segment defines the number of the
first data byte contained in that
segment.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Note

Note:

The value of the acknowledgment field


in a segment defines the number of the
next byte a party expects to receive.
The acknowledgment number is
cumulative.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Header

• 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: receiving the segment.
• Sequence number: defines the number assigned to
the first byte of data contained in this segment
(range 232). To ensure connectivity, each byte to be
transmitted is numbered. The sequence number
tells the destination which bytes in this sequence
comprises the first byte in the segment.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Header

• Acknowledgment number: This 32-bit field defines the byte


number that the sender of the segment is expecting to
receive from the other party. If the byte numbered x has
been successful received, x+1 is the acknowledgment
number.
• 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 can be between 5 (5x4 = 20) and 15 (15x4 =60).
• Reserved: This field defines 6 different control bits or flags
which can be set at a time. These bits enable flow control,
connection establishment and termination, and the mode of
data transfer in TCP.

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP
Question and Answer Session

Q&A

CT047-3-2 Systems Programming and Computer Control Process to Process to delivery UDP and TCP 56

You might also like