Академический Документы
Профессиональный Документы
Культура Документы
Lee
<Lesson 9-1>
UDP
y
TCP/IP protocol suite specifies two protocols for the transport layer:UDP and TCP
Application layer
SMTP FTP
TFTP
DNS
SNMP
BOOTP
Transport layer
TCP
IGMP ICMP
UDP IP
ARP RARP
Underlying LAN or WAN technology
Lee
<Lesson 9-2>
Domain of IP protocol
Internet
Lee
<Lesson 9-3>
Port 7 9 11 13 17 19 20 21 23 25 53 67 79 80 111
Protocol Echo Discard Users Daytime Quote Chargen FTP, Data FTP, Control TELNET SMTP DNS BOOTP Finger HTTP RPC
Description Echoes a received datagram back to the sender Discards any datagram that is received Active users Returns the date and the time Returns a quote of the day Returns a string of characters FTP, data connection FTP, control connection Terminal Network Simple Mail Transfer Protocol Domain Name Server Bootstrap protocol Finger Hypertext Transfer Protocol Remote Procedure Call 193.14.26.7
IP header 193.14.26.7 Port number selects the process Processes
23
23 193.14.26.7 23
TCP header
Socket address
<Lesson 9-4>
Seq. number: 32 bits tells the dest. Which byte in this sequence comprises the first byte in the segment. ACK number: defines the byte number that the source of the segment is expecting to receive from the other party. Header length (4bits): 20 to 60 bytes, value is 5 to 15. Reserved(6 bits): future use. Control: six control bits or flags. Windows size: defines the size of window in bytes. Checksum: 16 bits Urgent pointer: defines the number that must be added to the sequence number to obtain the number of the last urgent byte.
Flag URG ACK PSH RST SYN FIN Description The value of the urgent pointer field is valid The value of the acknowledge field is valid Push the data The connection must be reset Synchronize sequence numbers during connection Terminate the connection
Lee
<Lesson 9-5>
Max. segment size option: define the max size of data, determined by the destination, default is 536.
Lee
<Lesson 9-6>
Window scale factor: 16 bits means from 0 to 65535 bytes. For a high channel (fiber-optic). Need a big window size. New = defined x 2 window size factor
Length:10 00001010
Timestamp: 10-byte option.The timestamp field is filled by the source when segment leaves. The destination receives the segment and stores the timestamp value.When the destination sends an acknowledgement for the bytes, it enters the previously stored value in the echo reply field. The source checks the current time versus this value. The difference is the round-trip time.
Lee
<Lesson 9-7>
Pseudoheader
Header + options
Data
Lee
<Lesson 9-8>
Flow Control
y
Sliding window
1 2 3 4 5 6 7 8 9
10 11 12 13 14
Sliding window
1 2 3 4 5 6 7 8 9
10 11 12 13 14
TCP uses two buffers and one window to control the flow of data. The sending part has a buffer and the size of the window. The size of the window in the sending TCP is determined by the receiver and is announced in the ACK segments.
Pointer
Lee
<Lesson 9-9>
Window management
Sender Receiver
Buffer
The sending TCP sends 4K of data in its first segment.The buffer of the receiver windows becomes full. The receiver TCP ACK the receipt of the segment, but announces a window size of zero.The sending TP can not send any more data. It must wait for ack advertising a nonzero window size. <Lesson 9-10>
Lee
Sending application creates data slowly or the receiving application consumes data slowly. If TCP contain only 1 byte of data. It means that we are sending a 41-byte that transfer only 1 byte. Meaning that using the capacity of the network very inefficiently. Syndrome Created by the sender: Nagles Algorithm
The sending TCP sends the first piece of data it receives from the sending application program even if it is only one byte. After sending the first segment, the sending TCP accumulates data in the output buffer and waits until either the receiver TCP sends an ack or until enough data has accumulated to fill a max. segment. The above procedure is repeated.
Lee
<Lesson 9-11>
Error Control
y
TCP is a reliable transport layer protocol. Reliable means segments in order, without error, and without any part lost or duplicated. TCP provides reliability using error control. Error control includes mechanisms for detecting corrupted segments, lost segments, out-of-order segments, and duplicated segments. Error detection in TCP is achieved through the use of three simple tools: checksum, acknowledge, and time-out.
Case 1: Corrupted Segment: Sender resend the corrupted segment after time-out, the receiver discarded the corrupted segment. Case 2: Lost Segment: Sender resend the corrupted segment after time-out. Case 3: Duplicate Segment: sender resend the segment after time-out but the ACK is only delayed. The receiver simply discard the duplicate segment. Case 4: Out-of-Order Segment: the segment that receiver before its previous segment would not ACK immediately instead they are buffer until its previous segments are all received and the ACK is resend. Case 5: Lost ACK: TCP uses an accumulative ACK system. Any ACK confirm everything up to the byte specified by the ACK number. So, if ACK 1601 is lost, but ACK 1801 is received, there is a confirmation up to 1801.
Lee
<Lesson 9-12>
OK
Lee
<Lesson 9-13>
TCP Timers
y
TCP uses the four timers: retransmission timer, Persistence timer, Keepalive Timer, and Time-Waited Timer.
retransmission timer: handles the waiting time for an acknowledgement of a segment. Retransmission time = 2 x RTT (round-trip time) RTT = E x previous RTT + (1- E) x current RTT Persistence timer: when face with the zero window-size advertisement, TCP need this timer to solve the might deadlock problem if the receive resume to send the ack, but lost in the transmit. Keepalive timer: prevent a long idle connection between two TCPs. Suppose that a client opens a TCP connection to a server, transfers some data, and becomes silent. Time-waited timer: used during connection termination. When TCP closes a connection, it doesnt consider the connection really closed. The connection is held in limbo for a time-waited period.
Lee
<Lesson 9-14>
TCP is a connection-oriented protocol which establishes a virtual path between the source and destination.Three-way Handshaking
Receiver
Sender
Lee
Step 1: the client sends the first segment, a SYN segment. The segment includes the source and destination port numbers, Step 2: the server sends the second segment, a SYN and ACK segment.This segment has a dual propose. First, it acknowledges the receipt of the first segment using the ACK flag and ack number. Second, the segment is used as the initialization segment for the server. Step 3:The client sends the third segment.This is just an <Lesson 9-15> ACK segment.
Step 1: the client sends the first segment, a FIN segment. Step 2: the server sends the second segment, a ACK segment to confirm the receipt of the FIN segment. Step 3: the server TCP can continue sending data in the server-client direction. When it does not have any more data to send, it sends the third segment. FIN segment. Step 4: the client TCP sends the fourth segment an ACK segment to confirm the receipt of the FIN segment.
Lee
<Lesson 9-16>
TCP Operation
Process Process
Message from process TCP header IP header Frame header TCP header IP header Frame header
TCP data
TCP data
IP data
IP data
Frame data
Frame data
a. Encapsulation
b. Decapsulation
Lee
<Lesson 9-17>
TCP Operation
TELNET client
Incoming queue Outgoing queue
TELNETserver
Outgoing queue
Incoming queue
TCP
Port 52000
TCP
Port 23
Use of TCP TCP uses a buffer to store the stream of data coming from the sending applicatio program, the sending TCP has the choice to create segments of any size from the s The receiving TCP also buffers the data when they arrive and delivers them to the application program when the application program is ready or when receiving is o. Push operation is used when a keystore in the interactive way.
Lee
<Lesson 9-18>
Urgent Data TCP uses a buffer to store the stream of data coming from the sending applicatio program. It wants to abort the process, but it has already sent a huge amount of da If it issues a abort command (control+C), these two characters will be stored at th end of the receiving TCP buffer.The solution is to send a segment with the URG b The sending application tells the sending TCP that the piece of data is urgent.The TCP creates a segment and inserts the urgent data at the beginning of the 9-19> Lee <Lesson segmen
(Time-out)
CLOSED
Active open/SYN
Green line for Client Red line for server Dot line for unusual situations
SYN-RCVD
Close /FIN
FIN WAIT -1
FIN /ACK
CLOSING
FIN/ACK
ACK /-
FIN+ACK/ACK
ACK/-
Close /ACK
LAST ACK
FIN WAIT -2
TIMEWAIT
FIN/ACK
Lee
<Lesson 9-20>
Client Diagram
y
Initiations:
The client TCP starts in the CLOSED state.
Connection establishment:
While in this state, the client TCP can receive an active open reuest from the client application. It sends s SYN segment to the server TCP and goes to the SYN-SENT state. In this state, the client TCP can receive an SYN+ACK segment from the other TCP. It sends an ACK segment to the other TCP and goes to the ESTABLISHED state.
Connection termination:
While in this state, the client TCP can receive a close request from the client application. It sends a FIN segment to the other TCP and goes to the FIN-WAIT-1 state. While in this state, the client TCP waits to receive an ACK from the server TCP. When the ACK is received, it goes to the FIN-WAIT-2 state. It does not send anything. Now the connection is closed in one direction. The client remains in this state for the server to close the connection from the other end. If the client receives a FIN segment from the other end, it sends an ACK segment and goes to the TIME-WAIT state. When the client is in this state, it starts a timer and waits until this timer goes off. the value of this timer is set to double the lifetime estimate of a segment of maximum size. The client remains in the state before totally closing to let all duplicate packets, if any, arrive at their destination to be discarded. After the time-out, the client goes to the CLOSED state, where it began.
Lee
<Lesson 9-21>
Server Diagram
y
Initiation:
The server TCP starts in the CLOSED state.
Data transfer:
In the ESTABLISHED state, data transfer.The server remains in this state as long as it is sending and receiving data.
Lee
<Lesson 9-22>
TCP Design
Application layer Message from application
TCP
TCBs
TCP Segment
IP
4 components: (two data-structures plus three modules) Control-block table: keep tracks of the open ports. Four fields: the state, the Process ID, the port number, and the corresponding queue number. Input Queues: s set of input queues, one for each process. Lee <Lesson 9-23>
State: defines the state of connection Process: process ID and server/client, Local IP address: Local port number: Remote IP address: Remote port number: Interface: local interface Local window: comprise several subfields, holds information about the window at the local TCP Remote window: Sending sequence number: Receiving sequence number: Sending ACK number: Round-trip time: several fields holds information about the RTT Time out values: several fields hold the values of different time-out values such Lee as retransmission time-out, persistence time-out, <Lesson 9-24> Buffer size.
Lee
<Lesson 9-25>
Lee
<Lesson 9-26>
Quiz 1
Question 1: Fill the procedures in the MAIN operation for the LISTEN state?
Question 2: The following is a dump of a TCP header in hexadecimal format. 05320017 00000001 00000000 500207FF 00000000 Q: What is the source port number, destination port number, sequence number, ack number, length of the header, type of the segment, and the window size?
Lee
<Lesson 9-27>
Lee
<Lesson 9-28>
Quiz 2
1. 2. 3. 4. 5. 6.
Explain connection establishment procedure in TCP? Explain connection termination procedure in TCP? Explain flow control in TCP? Explain error control in TCP? Write out the Main module operation for State: SYN-SENT? Compare TCP and UDP in terms of connection, flow control, and error control? Compare the header between TCP and UDP?
7.
Lee
<Lesson 9-29>