Module 6.0: Transport Layer Protocols

22
K. Salah 1 Module 6.0: Transport Layer Protocols UDP & TCP Chapter 23 & 24

description

Module 6.0: Transport Layer Protocols. UDP & TCP. Chapter 23 & 24. Port Numbers. TCP connection : is identified by a pair of two endpoints {tcp,client IP address, 64,295}  {tcp,server IP address, 23} {tcp,client IP address, 64,295} is called a TCP socket. Web Ports. - PowerPoint PPT Presentation

Transcript of Module 6.0: Transport Layer Protocols

Page 1: Module 6.0:   Transport Layer Protocols

K. Salah 1

Module 6.0: Transport Layer Protocols

UDP

&

TCP

Chapter 23 & 24

Page 2: Module 6.0:   Transport Layer Protocols

K. Salah 2

Page 3: Module 6.0:   Transport Layer Protocols

K. Salah 3

Port Numbers

•TCP connection: is identified by a pair of two endpoints

• {tcp,client IP address, 64,295} {tcp,server IP address, 23}

• {tcp,client IP address, 64,295} is called a TCP socket.

Page 4: Module 6.0:   Transport Layer Protocols

K. Salah 4

Web Ports

Two clients, using the same destination port number (80) to communicate with the same Web server application. What kind of server is this?

Page 5: Module 6.0:   Transport Layer Protocols

K. Salah 5

Multiplexing and Demultiplexing

• Multiplexing– At the sender site, there may be several processes that need to send

packets. However, there is only one transport-layer protocol [UDP or TCP].– Protocol accepts messages from different process, differentiated by their

assigned port number. After adding the header, the transport layer passes the packet to network layer.

• Demultiplexing– At receiver site, the transport layer receives datagrams from network

layer. – After error checking and dropping of the header, the transport layer

delivers each message to the appropriate process based on the port number.

Page 6: Module 6.0:   Transport Layer Protocols

K. Salah 6

Port Ranges

• Port numbers are divided into three ranges:– Well-known ports: 0 to 1023.– Registered ports: Ports ranging from 1024 to

49151 are not assigned or controlled by IANA. They can only be registered with IANA to prevent duplication.

– Dynamic ports: Ports ranging from 49152 to 65535 are neither controlled nor registered. They can be used by any process. These are the ephemeral ports.

Page 7: Module 6.0:   Transport Layer Protocols

K. Salah 7

Well-known ports used by UDPWell-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)

Page 8: Module 6.0:   Transport Layer Protocols

K. Salah 8

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 Remote Procedure Call

Well-known ports used by TCPWell-known ports used by TCP

Page 9: Module 6.0:   Transport Layer Protocols

K. Salah 9

Error control

• If data link layer is reliable and has flow and error control, do we need this at the transport layer ?– Reliability at the data link layer is between two nodes– We need reliability between two ends.– Because the network layer in the Internet is unreliable (best-effort

delivery), we need to implement reliability at the transport layer.– To understand that error control at the data link layer does not

guarantee error control at the transport layer.

Page 10: Module 6.0:   Transport Layer Protocols

K. Salah 10

IP

• IP is unreliable

• IP is connectionless

• So is UDP?

• So why need UDP?

Page 11: Module 6.0:   Transport Layer Protocols

K. Salah 11

UDP

• UDP is a 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.

• It performs very limited error checking.– UDP is a very small protocol with a minimum of overhead. – If a process wants to send a small message and does not

care much about reliability, it can use UDP– Sending a small message using UDP takes much less

interaction between the sender and receiver than using TCP.

– UDP is a convenient protocol for multimedia and multicasting applications.

– UDP is a connectionless, unreliable protocol that has no flow and error control. It uses port numbers to multiplex data from the application layer.

Page 12: Module 6.0:   Transport Layer Protocols

K. Salah 12

User datagram format

• UDP packets, called user datagrams, have a fixed-size header of 8 bytes.– Source port number: Port number used by process running source host;

16 bits [0 to 65535]– Destination port number: Port number used by process running

destination host; 16 bits– Length: 16-bit field; Total length of user datagram header plus data.– Checksum:

Used to detect errors over the entire user datagram (header plus data)

is 1’s complement of the 1’s complement sum of all the 16-bit words in the packet ( headers + data).

Its optional to do checksum. If not done, put the entries as all 0s.

Page 13: Module 6.0:   Transport Layer Protocols

K. Salah 13

– 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 as FTP

– A process with internal flow and error control mechanisms. For Trivial File Transport Protocol (TFTP) includes flow and error control. It can easily use UDP.

– A suitable transport protocol for multicasting. Multicasting capabilities are embedded in the UDP software but not in 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.

Applications

Page 14: Module 6.0:   Transport Layer Protocols

K. Salah 14

Transmission Control Protocol (TCP)

• Reliable protocol

• Stream connection-oriented and reliable transport protocol.

• Adds connection-oriented and reliability features to the services of IP

• Stream Delivery Service– TCP, unlike UDP, is a stream-oriented protocol– UDP adds its own header to 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 allows the sending process to deliver data as a stream of bytes and 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.

Page 15: Module 6.0:   Transport Layer Protocols

K. Salah 15

TCP Segment

Hello dear friend. I am sending a letter …

Hello dear friend. I am sending a letter ..............

Hello dear friend.

I am sending a letter …

Buffer

Segment 1

Segment 2

Page 16: Module 6.0:   Transport Layer Protocols

K. Salah 16

TCP Segments

Segments are not necessarily the same size.There are two buffers, the sending buffer and the receiving buffer, for each direction. TCP is full-duplex

Page 17: Module 6.0:   Transport Layer Protocols

K. Salah 17

Numbering Bytes

• Byte number: – When TCP receives bytes of data from the process and stores them in

the sending buffer; it numbers them. – Numbering does not necessarily start from 0; it starts with a

randomly generated number between 0 to 232 – 1.– If random number happens to be 1057 and total data to be sent are

6000 bytes, the bytes are numbered from 1057 to 7056.

• Sequence number– TCP assigns a sequence number to each segment that is being sent– Sequence number of each segment is the number of the first byte

carried in that segment.

• Acknowledgement number– Sequence number in each direction shows the number of first byte

carried by the segment.– Each party also uses an acknowledgement number to confirm the

bytes it has received. However, the acknowledgement number defines the number of the next byte that the party expects to receive.

– Acknowledgement number is cumulative, which means that the receiver takes the number of the last byte it has received, safe and sound, adds 1 to it, and announces this sum as the acknowledgement number.

Page 18: Module 6.0:   Transport Layer Protocols

K. Salah 18

Example Example

Imagine a TCP connection is transferring a file of 6000 bytes. The first byte is numbered 10010. What are the sequence numbers for each segment if data are sent in five segments with the first four segments carrying 1000 bytes and the last segment carrying 2000 bytes?

SolutionSolutionThe following shows the sequence number for each segment: Segment 1 ==> sequence number: 10,010 (range: 10,010 to 11,009) Segment 2 ==> sequence number: 11,010 (range: 11,010 to 12,009) Segment 3 ==> sequence number: 12,010 (range: 12,010 to 13,009) Segment 4 ==> sequence number: 13,010 (range: 13,010 to 14,009) Segment 5 ==> sequence number: 14,010 (range: 14,010 to 16,009)

Page 19: Module 6.0:   Transport Layer Protocols

K. Salah 19

TCP Header

Page 20: Module 6.0:   Transport Layer Protocols

K. Salah 20

Header Fields

• Sequence number, Acknowledgement number, and Window size are used for implementing sliding window flow and error control.

• Checksum is 1’s complement of the 1’s complement sum of all the 16-bit words in the TCP packet (TCP pseudoheader + TCP header + data segment). TCP psuedoheader is locally computed at source and destination. At destination, it is computed by IP layer.

• HLEN or Offset is the size of TCP header measured in 32-bit multiples.

• Urgent pointer specifies a position within the data stream (sequence number + 1). Example is hitting ESC key to abort a hung-up telnet session.

• Options and Padding. This is only 32-bit field. A common option is the MSS (Maximum Segment Size) that restricts the size of TCP segment and is negotiated at the start of TCP connection. Usually MSS = (MTU – fixed TCP&IP headers) to avoid further fragmentation. Padding is filling with zeros to allow 32-bit boundary.

Page 21: Module 6.0:   Transport Layer Protocols

K. Salah 21

TCP Pseudoheader

• To double check that TCP segment got received by correct destination. Data may get delivered to wrong IP address.

• Violation of layering boundaries.

• Used also for UDP

Page 22: Module 6.0:   Transport Layer Protocols

K. Salah 22

Control Field

• URG data contained is urgent is should be processed by receiver ASAP. Used to send out of band signals to receiver by jumping the sender and receiver queues.

• ACK indicates the Acknowledgment number is valid.

• PSH sends whatever accumulated data to server applications ASAP. Situations include: one query, end of message, in interactive processes when hitting <CR>, in FTP when sending last segment of a file.

• RST tells the receiver to release connection and its resources. This happens under abnormal conditions, e.g., the sender is having errors/timeouts/disconnect communicating with receiver.

• SYN indicates opening a connection.

• FIN indicates closing a connection