ICS 156: Networking Lab

23
ICS 156: Networking Lab Magda El Zarki Professor, ICS UC, Irvine

description

ICS 156: Networking Lab. Magda El Zarki Professor, ICS UC, Irvine. Course Outline. Ch 1: Introduction Ch 2:Bridges Ch 3:Routers Ch 4: Transport Protocols. 4. Transport Layer Protocols. Introduction Transport Layer Protocols: Transport Control Protocol (TCP) and - PowerPoint PPT Presentation

Transcript of ICS 156: Networking Lab

Page 1: ICS 156: Networking Lab

ICS 156: Networking Lab

Magda El Zarki

Professor, ICS

UC, Irvine

Page 2: ICS 156: Networking Lab

Course Outline

Ch 1: Introduction Ch 2:Bridges Ch 3:Routers Ch 4: Transport Protocols

Page 3: ICS 156: Networking Lab

4. Transport Layer Protocols

Introduction

Transport Layer Protocols:

– Transport Control Protocol (TCP) and

– User Datagram Protocol (UDP)

Page 4: ICS 156: Networking Lab

4.1 Introduction

1

2

3

4

1

2

3

1

2

3

1

2

3

1

2

3

4End-to-End Transport

Subnet 1 Subnet 2 Subnet 3 Subnet 4

Host Host

Router Router Router

Page 5: ICS 156: Networking Lab

4.1.1 TCP and UDP

There are two kinds of Transport Protocols used in the Internet:

– UDP: User Datagram Protocol

– TCP: Transport Control Protocol

They both operate over IP.

They both use PORT numbers for connecting to applications.

Page 6: ICS 156: Networking Lab

4.1.2 Port Numbers (1/3) The concatenation of IP address and Port Number

provides a unique identifier for transferring information between a source and a destination. This is known as a socket, the door between an application and the underlying transport system.

Each application service is allocated a unique port number:

– FTP - 21

– Telnet - 23

– Domain Name Server - 53, etc.

Page 7: ICS 156: Networking Lab

4.1.2 Port Numbers (2/3)

There are 1023 port numbers available for application services.

Not all port numbers are well known, in that case a request is sent to a catch all port number. The response packet contains the correct port number.

Page 8: ICS 156: Networking Lab

4.1.2 Port Numbers (3/3)

1

2

3

1

2

3

2

1

3

2

1

Subnet 1 Subnet 2

Physical Address

Port Number

4 4Network IP Address

Page 9: ICS 156: Networking Lab

4.1.3 TCP vs UDP

The tuple <Source Port, Destination Port> is used in the addressing of the Transport Data Unit (TDU).

Most applications that require a reliable transport mechanism use TCP, otherwise UDP is used because it is simpler.

UDP is the preferred choice for real-time services as it does not incorporate a lot of the overhead that is associated with TCP.

Page 10: ICS 156: Networking Lab

4.2 UDP (1/3)

Uses only 8 bytes of header:

– 2 bytes for source port

– 2 bytes for destination port

– 2 bytes for length of data unit

– 2 bytes for checksum (covers IP addresses and IP length field included)

Page 11: ICS 156: Networking Lab

4.2 UDP (2/3)

Provides connectionless service - no sequencing, no end to end error control (only error detection, includes data), no flow control.

NFS, some routing protocols (e.g., RIP), RTP (Real-Time Protocol), TFTP, etc., use UDP as it is simple and fast if reliability is not an issue.

IP will do fragmentation if the UDP packet is too large for the path (i.e., > path MTU).

Page 12: ICS 156: Networking Lab

4.2 UDP (3/3)

A UDP packet can be as large as the max. IP packet minus the headers. Generally the application will limit the packet size.

UDP leaves most of the work to the upper (application) layer. This can slow things down, as ACKs, re-ordering, etc., has to be done by the application.

Page 13: ICS 156: Networking Lab

4.3 TCP (1/2)32 bits

Dest. Port

Sequence Number

Acknowledgement Number

Header Length Advertised Window

Checksum Urgent Pointer

Data

Source Port

Flags

2) FIN - last segment connection tear down 3) URG - urgent data carried 4) ACK - read ack field 5) RESET, 6) PSH - pass data to application asap Advertised Window: amount of data sender can send.Urgent Pointer: Points to where urgent data starts in data fieldChecksum: for whole segment

Options

Flags: 1) SYN - for connection set-up

Page 14: ICS 156: Networking Lab

4.3 TCP (2/2)

20 byte header (without options)

Header plus data referred to as a transport segment

Segment size chosen to accommodate the smallest IP packet size on path to avoid fragmentation

Page 15: ICS 156: Networking Lab

4.3.1 Connection Establishment and Tear Down TCP goes through a 3 phase set-up:

– Connection set-up (3 way hand-shake): SYN, SYN ACK, ACK

– Data transfer

– Connection tear down: FIN, ACK, FIN, ACK (two way or one way)

Page 16: ICS 156: Networking Lab

4.3.2 Sequence Numbers and ACKs TCP is connection oriented - uses sequence numbers

(always increasing, numbers not consecutive, reflect the number of bytes not segments!). For example: if TCP wants to send 2000 bytes and sends them in two segments of 1000 bytes each, if first segment has sequence no 102, then sequence number of second segment will be 102+1000= 1102.

The ACKs on the other hand reflect the sequence number of the next byte that the receiver is expecting. If the receiver received segment with sequence number 102 of length 1000, then ACK will use number: 102+ 1000 = 1102.

Page 17: ICS 156: Networking Lab

4.3.3 Out of Order Arrivals

The RFC does not specify what to do with out of order packets. TCP will only acknowledge ordered transmissions, but the question is: should it keep out of order packets in its buffer or just discard them? The easiest implementation is to discard and wait for all packets to arrive in order.

An ACK is sent in response to an out of order packet, it contains the “expected” sequence number.

Page 18: ICS 156: Networking Lab

4.3.4 Group and Delayed ACKs Group ACKs: TCP will use group ACKs, also

referred to as delayed ACKs. in otherwords, it will not ACK each received segment, it will wait for a short while (differs on each system, 200msecs for WANs, 20msec for LANs) and then ACK all segments (max. 2 segments) that it has received so far.

It does that so that: 1) it can do group ACKing which is more efficient, and 2) it hopes to be able to piggyback an ACK on data going in the reverse direction. If there is data in the buffer that needs to be sent, it will not do a delayed ACK. Only uses delayed ACK if send buffer is empty.

Page 19: ICS 156: Networking Lab

4.3.5 Timers & Retransmissions

Uses error detection and recovery - ACKs and retransmissions. If an ACK is not received before a timer expires, the segment is resent.

The retransmission timer is not a static value. It is calculated based upon current network status. The timer must be greater than the roundtrip delay!

Page 20: ICS 156: Networking Lab

4.3.6 Flow Control (1/2) Sliding window is used as the flow control

technique (matching of sender and receiver data rates): Each end system will advertise the largest window it is willing to receive without ACKs, i.e., packets that can be outstanding between source and destination.

This value is dynamic, it changes based upon how fast the receiver can read the arriving data. It is always advertised in the messages sent from the destination to the source. Note however that the TCP congestion control mechanism does kick in too and affects the amount of data that can be sent.

Page 21: ICS 156: Networking Lab

4.3.6 Flow Control (2/2)

If an ACK packet comes back with a receiver window size of “0”, that means that the destination wants the source to hold off with transmission. In this case the sending host can only send segments with 1 byte of data. This is to keep the connection alive between the two ends, i.e., keep ACKs flowing from destination to source indicating the window size.

Page 22: ICS 156: Networking Lab

4.3.7 Congestion Control TCP has imbedded congestion control. When ACKs come

back with a delay (i.e. timers expire) the window size is reduced by the sender. The sender will only send data = min{congestion window, receiver (or sliding) window}.

TCP also uses something called slow start: The sender starts off with only sending 1 (in some cases 2) packet, then doubles that if the ACK comes back before the retransmit timer expires. It keeps on doubling until it reaches a threshold then goes into a linear increase (i.e., adds one to the window size). If at anytime an ACK is delayed, it sets the threshold to half the current congestion window size and starts again with slow start.

Page 23: ICS 156: Networking Lab

4.3.8 Applications and TCP

All applications that are concerned with reliable transport use TCP

SMTP (email), ftp, RIP, http, etc. use TCP.

TCP hides the underlying network from the application: it segments,it re-orders packets, does error control and handles flow matching and congestion control.