Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport...

30
Intermediate TCP/IP TCP Operation

Transcript of Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport...

Page 1: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

Intermediate TCP/IP

TCP Operation

Page 2: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

2

TCP/IP Transport Layer

The primary duties of the transport layer: Segmentation of upper-layer application data Establishment of end-to-end operations Transport of segments from one end host to another end host Flow control provided by sliding windows Reliability with sequence numbers and acknowledgments

Page 3: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

3

Layer 4 – TCP and UDP

TCPConnection-oriented Reliable Divides outgoing

messages into segments Reassembles messages

at the destination station

Re-sends anything not received

Reassembles messages from incoming segments

UDPConnectionless Unreliable Transmits messages

(called user datagrams) Provides no software

checking for message delivery (unreliable)

Does not reassemble incoming messages

Uses no acknowledgments

Provides no flow control

Page 4: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

4

TCP Segment FormatNumber of the

calling portNumber of the called port

Used to ensure correct

sequencing of the arriving dataNext

expected TCP octet Number of 32-bit

words in the header

set to zero

Control setup and termination of

session Number of octets sender is willing to

accept Indicates the end of the urgent data

Upper layer protocol data

Page 5: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

5

UDP Segment Format

• UDP is the connectionless transport protocol

• UDP uses no windowing and no acknowledgments

• Error processing and retransmission must be handled by other protocols (application layer)

• Protocols that use UDP include:TFTP SNMP DHCP DNS

Page 6: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

6

Session Maintanance - Flow Control and WindowingWindow size determines the amount of data that you can transmit before receiving an acknowledgment.

Expectational acknowledgment means that the acknowledgment number refers to the octet that is next expected.

Sliding window refers to the fact that the window size is negotiated dynamically during the TCP session.

If the source receives no acknowledgment, it knows to retransmit at a slower rate.

Page 7: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

TCP Operation

• IP provides best-effort delivery.• The transport layer (TCP) is responsible for reliability

and flow control from source to destination.• This is accomplished using:

Sliding windows (flow control) Sequencing numbers and acknowledgments (reliability) Synchronization (establish a virtual circuit)

Page 8: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

TCP or UDP Identification

• The IP Packet has a Protocol field that specifies whether the segment is TCP or UDP.

Connection-oriented

Connectionless

Connectionless

IP Header 0 15 16 31

4-bit Version

4-bit Header Length

8-bit Type Of Service (TOS)

16-bit Total Length (in bytes)

16-bit Identification

3-bit Flags

13-bit Fragment Offset

8 bit Time To Live

TTL

8-bit Protocol

16-bit Header Checksum

32-bit Source IP Address

32-bit Destination IP Address

Options (if any)

Data

Page 9: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

TCP Reliability

• TCP re-sends anything that is not received and supplies a virtual circuit between end-user applications.

• The advantage of TCP is that it provides guaranteed delivery of the segments.

Page 10: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

Synchronization: 3-Way Handshake

• For a connection to be established, the two end stations must synchronize on each other's initial TCP sequence numbers (ISNs).

• Sequence numbers are used to track the order of packets and to ensure that no packets are lost in transmission.

• The initial sequence number is the starting number used when a TCP connection is established.

• Exchanging beginning sequence numbers during the connection sequence ensures that lost data can be recovered.

0 15 16 31

16-bit Source Port Number

16-bit Destination Port Number

32-bit Sequence Number

32 bit Acknowledgement Number

4-bit Header Length

6-bit (Reserved)

URG

ACK

PSH

RST

SYN

FIN

16-bit Window Size

16-bit TCP Checksum

16-bit Urgent Pointer

Options (if any)

Data (if any)

TCP Header

Page 11: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

• Only part of the TCP headers are displayed.

Packet 1: source: 130.57.20.10 dest: 130.57.20.1TCP: ----- TCP header ----- TCP: Source port = 1026 TCP: Destination port = 524 TCP: Initial sequence number = 12952 TCP: Next expected Seq number= 12953 TCP: .... ..1. = SYN TCP: Window = 8192 TCP: Checksum = 1303 (correct) TCP: Maximum segment size = 1460 (TCP Option) Packet 2: source: 130.57.20.1 dest: 130.57.20.10

TCP: ----- TCP header ----- TCP: Source port = 524 TCP: Destination port = 1026 TCP: Initial sequence number = 2744080 TCP: Next expected Seq number= 2744081 TCP: Acknowledgment number = 12953 TCP: .... ..1. = SYN TCP: Window = 32768 TCP: Checksum = D3B7 (correct) TCP: Maximum segment size = 1460 (TCP Option)

Packet 3: source: 130.57.20.10 dest: 130.57.20.1

TCP: ----- TCP header -----

TCP: Source port = 1026

TCP: Destination port = 524

TCP: Sequence number = 12953

TCP: Next expected Seq number= 12953

TCP: Acknowledgment number = 2744081

TCP: ...1 .... = Acknowledgment

TCP: Window = 8760

TCP: Checksum = 493D (correct)

TCP: No TCP options

Page 12: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

TCP Three-Way Handshake

1. The client sends a SYN message to the server, indicating the client wishes to communicate with the server.

Continued…

Page 13: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

TCP Three-Way Handshake

2. The server responds to the client with an ACK message, and a SYN message. Here, the server places the client into the server’s

half-open queue, where it waits for the three-way handshake to complete.

Continued…

Page 14: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

TCP Three-Way Handshake

3. The client responds with an ACK message, completing the handshake. Now, the server moves the client from the

half-open queue, freeing resources for new incoming connections to the server.

Page 15: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

Simple Windowing (1)

• TCP is responsible for breaking data into segments.• With a window size of 1, each segment carries only one byte of data and must

be acknowledged before another segment is transmitted. This results in inefficient host use of bandwidth.

• The purpose of windowing is to improve flow control and reliability.• Unfortunately, with a window size of 1, you see a very inefficient use of

bandwidth.

0 15 16 31

16-bit Source Port Number

16-bit Destination Port Number

32-bit Sequence Number

32 bit Acknowledgement Number

4-bit Header Length

6-bit (Reserved)

URG

ACK

PSH

RST

SYN

FIN

16-bit Window Size

16-bit TCP Checksum

16-bit Urgent Pointer

Options (if any)

Data (if any)

TCP Header

Page 16: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

Simple Windowing (2)

• TCP uses a window size, number of bytes, that the receiver is willing to accept, and is usually controlled by the receiving process.

• TCP uses expectational acknowledgments The acknowledgment number refers to the next byte that the sender of the

acknowledgement expects to receive.• A larger window size allows more data to be transmitted pending

acknowledgment.• The sequence number being sent identifies the first byte of data in

that segment.

Page 17: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

Simple Windowing (3)

• TCP provides full-duplex service, which means data can be flowing in each direction, independent of the other direction.

• Window sizes, sequence numbers and acknowledgment numbers are independent of each other’s data flow.

• Receiver sends acceptable window size to sender during each segment transmission (flow control) If too much data being sent, acceptable window size is reduced If more data can be handled, acceptable window size is increased

• This is known as a Stop-and-Wait windowing protocol.

Page 18: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

Sequencing Numbers

• The data segments being transmitted must be reassembled once all the data is received.

• No guarantee that the data will arrive in the order it was transmitted• TCP applies sequence numbers to the data segments.• Sequencing numbers indicate to the destination device the correct

order in which to put the bytes when they are received.• These sequencing numbers also act as reference numbers so that the

receiver will know if it has received all of the data.• They also identify the missing data pieces to the sender so it can

retransmit the missing data.

Page 19: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

Positive Acknowledgment and Retransmission (PAR)

• PAR: The source sends a packet, starts a timer, and waits for an acknowledgment before sending the next packet.

• If the timer expires before the source receives an acknowledgment, the source retransmits the packet and starts the timer over again.

• TCP uses expectational acknowledgments in which the acknowledgment number refers to the next octet that is expected.

Page 20: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

UDP Operation

• UDP does not use windowing or acknowledgments so application layer protocols must provide error detection.

• The Source Port field is an optional field used only if information needs to return to the sending host.

Page 21: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

UDP Segments

Page 22: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

Port Numbers (TCP and UDP)

Page 23: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

23

Port NumbersPort nos. are used to keep track of different conversations that cross the network at the same time.

Port nos. allow for multiplexing of upper-layer conversations.

Port nos. are used as source and destination addresses in the TCP segment.

Port nos. below 1024 are considered well-known.

Port nos. above 1024 are dynamically assigned.

Registered port nos. are for vendor-specific applications (Most are above 1024)

Page 24: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

• Application software developers have agreed to use the well-known port numbers that are defined in RFC 1700.

• For example, any conversation bound for an Telnet application uses the standard port number 23.

0 15 16 31

16-bit Source Port Number

16-bit Destination Port Number

32-bit Sequence Number

32 bit Acknowledgement Number

4-bit Header Length

6-bit (Reserved)

URG

ACK

PSH

RST

SYN

FIN

16-bit Window Size

16-bit TCP Checksum

16-bit Urgent Pointer

Options (if any)

Data (if any)

TCP HeaderPort Numbers

Page 25: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

• Conversations that do not involve an application with a well-known port number are, instead, assigned port numbers that are randomly selected from within a specific range.

• These port numbers are used as source and destination addresses in the TCP segment.

• Some ports are reserved in both TCP and UDP, although applications might not be written to support them.

Standard Port Numbers

Page 26: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

Standard Port Numbers

• The Well-Known Ports are assigned by the IANA and on most systems can only be used by system (or root) processes or by programs executed by privileged users. Ports 0 – 1,023 http://www.iana.org/assignments/port-numbers

• The Registered Ports are listed by the IANA and on most systems can be used by ordinary user processes or programs executed by ordinary users. The IANA registers uses of these ports as a convenience to the community. Ports 1,024 – 49,151

• The Dynamic and/or Private Ports are those from 49,152 through 65,535

Page 27: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

• End systems use port numbers to select the proper application.

• Originating source port numbers, usually a value larger than 1023, are dynamically assigned by the source host.

TCP Header0 15 16 31

16-bit Source Port Number

16-bit Destination Port Number

32-bit Sequence Number

32 bit Acknowledgement Number

4-bit Header Length

6-bit (Reserved)

URG

ACK

PSH

RST

SYN

FIN

16-bit Window Size

16-bit TCP Checksum

16-bit Urgent Pointer

Options (if any)

Data (if any)

TCP Header

Port Numbers

Page 28: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

Notice the difference in how source and destination port numbers are used with clients and servers:

Client:• Destination Port = 23 (telnet)• Source Port = 1028 (dynamically assigned)

Server:• Destination Port = 1028 (source port of client)• Source Port = 23 (telnet)

0 15 16 31

16-bit Source Port Number

16-bit Destination Port Number

32-bit Sequence Number

32 bit Acknowledgement Number

4-bit Header Length

6-bit (Reserved)

URG

ACK

PSH

RST

SYN

FIN

16-bit Window Size

16-bit TCP Checksum

16-bit Urgent Pointer

Options (if any)

Data (if any)

TCP Header

Page 29: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

1031

Second http session from the between the same client and server. Same destination port, but different source port to uniquely identify this web session.

80801030

http to www.cisco.com

http to www.cisco.com

Dest. Port = 80 Send packets to web server application

Dest. Port = 80 Send packets to web server application

This example shows two separate browser windows to the same URL. TCP/IP uses source port numbers to know which information goes to which window.

Page 30: Intermediate TCP/IP TCP Operation. 2 TCP/IP Transport Layer The primary duties of the transport layer:  Segmentation of upper-layer application data.

What makes each connection unique?• Connection defined by the pair of numbers:

Source IP address, source port Destination IP address, destination port

• Different connections can use the same destination port on server host as long as the source ports or source IP addresses are different.