Advanced Computer Networks. Transport Layer TCP/UDP. Internet transport-layer protocols. Outline. Islamic Azad University of Hamedan

Similar documents
Transport Layer and Data Center TCP

Transport Layer Protocols

Transport Layer Services Mul9plexing/Demul9plexing. Transport Layer Services

Computer Networks. Chapter 5 Transport Protocols

Computer Networks - CS132/EECS148 - Spring

Chapter 5. Transport layer protocols

COMP 3331/9331: Computer Networks and Applications. Lab Exercise 3: TCP and UDP (Solutions)

First Midterm for ECE374 03/09/12 Solution!!

Data Communication & Networks G

TCP/IP Optimization for Wide Area Storage Networks. Dr. Joseph L White Juniper Networks

Computer Networks UDP and TCP

La couche transport dans l'internet (la suite TCP/IP)

ICOM : Computer Networks Chapter 6: The Transport Layer. By Dr Yi Qian Department of Electronic and Computer Engineering Fall 2006 UPRM

Names & Addresses. Names & Addresses. Hop-by-Hop Packet Forwarding. Longest-Prefix-Match Forwarding. Longest-Prefix-Match Forwarding

B-2 Analyzing TCP/IP Networks with Wireshark. Ray Tompkins Founder of Gearbit

Outline. TCP connection setup/data transfer Computer Networking. TCP Reliability. Congestion sources and collapse. Congestion control basics

First Midterm for ECE374 03/24/11 Solution!!

Final for ECE374 05/06/13 Solution!!

TCP in Wireless Mobile Networks

This sequence diagram was generated with EventStudio System Designer (

CSE 473 Introduction to Computer Networks. Exam 2 Solutions. Your name: 10/31/2013

[Prof. Rupesh G Vaishnav] Page 1

La couche transport dans l'internet (la suite TCP/IP)

Improving the Performance of TCP Using Window Adjustment Procedure and Bandwidth Estimation

q Connection establishment (if connection-oriented) q Data transfer q Connection release (if conn-oriented) q Addressing the transport user

SIP: Session Initiation Protocol

Higher Layer Protocols: UDP, TCP, ATM, MPLS

Mobile Communications Chapter 9: Mobile Transport Layer

Prefix AggregaNon. Company X and Company Y connect to the same ISP, and they are assigned the prefixes:

Chapter 6 Congestion Control and Resource Allocation

Visualizations and Correlations in Troubleshooting

Transport Layer. Chapter 3.4. Think about

How do I get to

TCP Flow Control. TCP Receiver Window. Sliding Window. Computer Networks. Lecture 30: Flow Control, Reliable Delivery

Ethernet. Ethernet. Network Devices

TCP over Multi-hop Wireless Networks * Overview of Transmission Control Protocol / Internet Protocol (TCP/IP) Internet Protocol (IP)

TCP Performance Management for Dummies

TCP and Wireless Networks Classical Approaches Optimizations TCP for 2.5G/3G Systems. Lehrstuhl für Informatik 4 Kommunikation und verteilte Systeme

Overview. Securing TCP/IP. Introduction to TCP/IP (cont d) Introduction to TCP/IP

15-441: Computer Networks Homework 2 Solution

Lecture 15: Congestion Control. CSE 123: Computer Networks Stefan Savage

Application Level Congestion Control Enhancements in High BDP Networks. Anupama Sundaresan

Indian Institute of Technology Kharagpur. TCP/IP Part I. Prof Indranil Sengupta Computer Science and Engineering Indian Institute of Technology

First Midterm for ECE374 02/25/15 Solution!!

COMP 361 Computer Communications Networks. Fall Semester Midterm Examination

Improved Digital Media Delivery with Telestream HyperLaunch

2 TCP-like Design. Answer

TCP for Wireless Networks

A Survey on Congestion Control Mechanisms for Performance Improvement of TCP

IP Network Layer. Datagram ID FLAG Fragment Offset. IP Datagrams. IP Addresses. IP Addresses. CSCE 515: Computer Network Programming TCP/IP

Data Communications & Networks. Session 6 Main Theme Reliable Data Transfer. Dr. Jean-Claude Franchitti

Computer Networks Homework 1

IP - The Internet Protocol

Transport layer protocols for ad hoc networks

Networking Overview. (as usual, thanks to Dave Wagner and Vern Paxson)

Architecture and Performance of the Internet

Lecture Objectives. Lecture 07 Mobile Networks: TCP in Wireless Networks. Agenda. TCP Flow Control. Flow Control Can Limit Throughput (1)

Voice over IP. Demonstration 1: VoIP Protocols. Network Environment

CSE331: Introduction to Networks and Security. Lecture 9 Fall 2006

Computer Networks Practicum 2015

Midterm Exam CMPSCI 453: Computer Networks Fall 2011 Prof. Jim Kurose

TCP Adaptation for MPI on Long-and-Fat Networks

Digital Audio and Video Data

Internet Protocols. Background CHAPTER

Transport Protocols and Distributed Applications

Simulation-Based Comparisons of Solutions for TCP Packet Reordering in Wireless Network

Homework 3 assignment for ECE374 Posted: 03/13/15 Due: 03/27/15

Chapter 11. User Datagram Protocol (UDP)

2.1 Introduction. 2.2 Voice over IP (VoIP)

Pig Laboratory. Additional documentation for the laboratory. Exercises and Rules. Tstat Data

TCP/IP Networking for Wireless Systems. Integrated Communication Systems Group Ilmenau University of Technology

Internet Control Protocols Reading: Chapter 3

Homework 2 assignment for ECE374 Posted: 02/21/14 Due: 02/28/14

Access Control: Firewalls (1)

Computer Networks. Data Link Layer

First Workshop on Open Source and Internet Technology for Scientific Environment: with case studies from Environmental Monitoring

IP address format: Dotted decimal notation:

Data Networks Summer 2007 Homework #3

Introduction to TCP/IP

Networks: IP and TCP. Internet Protocol

The Transport Layer and Implica4ons for Network Monitoring. CS 410/510 Spring 2014

Servicesin ns-3. Outline SIMULACIÓN DE PROTOCOLOS DE ENRUTAMIENTO PARA REDES MÓVILES AD-HOC MEDIANTE HERRRAMIENTA DE SIMULACIÓN NS-3

Outline. CSc 466/566. Computer Security. 18 : Network Security Introduction. Network Topology. Network Topology. Christian Collberg

Low-rate TCP-targeted Denial of Service Attack Defense

Congestions and Control Mechanisms n Wired and Wireless Networks

Based on Computer Networking, 4 th Edition by Kurose and Ross

What is a DoS attack?

Advanced Computer Networks Project 2: File Transfer Application

1 An application in BPC: a Web-Server

Note! The problem set consists of two parts: Part I: The problem specifications pages Part II: The answer pages

Basic Networking Concepts. 1. Introduction 2. Protocols 3. Protocol Layers 4. Network Interconnection/Internet

The Fundamentals of Intrusion Prevention System Testing

Protocols. Packets. What's in an IP packet

TCP over Wireless Networks

Multipath TCP in Practice (Work in Progress) Mark Handley Damon Wischik Costin Raiciu Alan Ford

D. SamKnows Methodology 20 Each deployed Whitebox performs the following tests: Primary measure(s)

Компјутерски Мрежи NAT & ICMP

Protocols and Architecture. Protocol Architecture.

CS268 Exam Solutions. 1) End-to-End (20 pts)

1. The subnet must prevent additional packets from entering the congested region until those already present can be processed.

Transcription:

Advanced Computer Networks By: Mohammad Nassiri m.nassiri@basu.ac.ir TCP/UDP Islamic Azad University of Hamedan 2009/2010 Semester II 3-2 Outline Internet transport-layer protocols!! reliable, in-order delivery (TCP) "! congestion control "! connection setup!! unreliable, unordered delivery: UDP "! no-frills extension of best-effort IP!! not available: "! delay guarantees "! bandwidth guarantees transport transport 3-3 3-4

Multiplexing/ Demultiplexing at rcv host: delivering received segments to correct socket transport link = socket P3 = process P1 P1 transport link Multiplexing at send host: gathering data from multiple sockets, enveloping data with header (later used for ) P2 P4 transport link How works!! host receives IP datagrams "! each datagram has source IP address, destination IP address "! each datagram carries 1 transport-layer segment "! each segment has source, destination port number!! host uses IP addresses & port numbers to direct segment to appropriate socket 32 bits source port # dest port # other header fields data (message) host 1 host 2 host 3 TCP/UDP segment format 3-5 3-6 Connectionless Connectionless demux (cont)!! Create sockets with port numbers: DatagramSocket mysocket1 = new DatagramSocket(12534); DatagramSocket mysocket2 = new DatagramSocket(12535);!! UDP socket identified by two-tuple: (dest IP address, dest port number)!! When host receives UDP segment: "! checks destination port number in segment "! directs UDP segment to socket with that port number!! IP datagrams with different source IP addresses and/or source port numbers directed to same socket DatagramSocket serversocket = new DatagramSocket(6428); P2 client IP: A SP: 9157 DP: 6428 SP: 6428 DP: 9157 SP provides return address P3 server IP: C SP: 6428 DP: 5775 SP: 5775 DP: 6428 P1 P1 Client IP:B 3-7 3-8

Connection-oriented demux Connection-oriented demux (cont)!! TCP socket identified by 4-tuple: "! source IP address "! source port number "! dest IP address "! dest port number!! recv host uses all four values to direct segment to appropriate socket!! Server host may support many simultaneous TCP sockets: "! each socket identified by its own 4-tuple!! Web servers have different sockets for each connecting client "! non-persistent HTTP will have different socket for each request P1 client IP: A SP: 9157 DP: 80 S-IP: A D-IP:C P4 server IP: C P5 P6 P2 P1 P3 SP: 5775 DP: 80 S-IP: B D-IP:C SP: 9157 DP: 80 S-IP: B D-IP:C Client IP:B 3-9 3-10 Connection-oriented demux: Threaded Web Server Outline P1 P4 SP: 5775 DP: 80 S-IP: B D-IP:C P2 P1 P3 SP: 9157 SP: 9157 client IP: A DP: 80 S-IP: A D-IP:C server IP: C DP: 80 S-IP: B D-IP:C Client IP:B 3-11 3-12

UDP: User Datagram Protocol [RFC 768] UDP: more!! no frills, bare bones Internet transport protocol!! best effort service, UDP segments may be: "! lost "! delivered out of order to app!! connectionless: "! no handshaking between UDP sender, receiver "! each UDP segment handled independently of others Why is there a UDP?!! no connection establishment (which can add delay)!! simple: no connection state at sender, receiver!! small segment header!! no congestion control: UDP can blast away as fast as desired!! often used for streaming muldia apps "! loss tolerant "! rate sensitive!! other UDP uses "! DNS "! SNMP!! reliable transfer over UDP: add reliability at layer "! -specific error recovery! Length, in bytes of UDP segment, including header source port # dest port # length 32 bits Application data (message) checksum UDP segment format 3-13 3-14 UDP checksum Goal: detect errors (e.g., flipped bits) in transmitted segment Sender:!! treat segment contents as sequence of 16-bit integers!! checksum: addition (1 s complement sum) of segment contents!! sender puts checksum value into UDP checksum field Receiver:!! compute checksum of received segment!! check if computed checksum equals checksum field value: "! NO - error detected "! YES - no error detected. But maybe errors nonetheless? More later. Internet Checksum Example!! Note "!When adding numbers, a carryout from the most significant bit needs to be added to the result!! Example: add two 16-bit integers wraparound sum checksum 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 3-15 3-16

Outline TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581!! point-to-point: "! one sender, one receiver!! reliable, in-order byte steam:!! pipelined: "! TCP congestion and flow control set window size!! send & receive buffers!! full duplex data: "! bi-directional data flow in same connection "! MSS: maximum segment size!! connection-oriented: "! handshaking (exchange of control msgs) init s sender, receiver state before data exchange!! flow controlled: "! sender will not overwhelm receiver 3-17 3-18 TCP segment structure URG: urgent data (generally not used) ACK: ACK # valid PSH: push data now (generally not used) RST, SYN, FIN: connection estab (setup, teardown commands) Internet checksum (as in UDP) 32 bits source port # dest port # head len sequence number acknowledgement number not used checksum U A P R S F Receive window Urg data pnter Options (variable length) data (variable length) counting by bytes of data (not segments!) # bytes rcvr willing to accept TCP seq. # s and ACKs Seq. # s: "! byte stream number of first byte in segment s data ACKs: "! seq # of next byte expected from other side "! cumulative ACK Q: how receiver handles out-of-order segments "! A: TCP spec doesn t say, - up to implementor User types C host ACKs receipt of echoed C Host A Host B simple telnet scenario host ACKs receipt of C, echoes back C 3-19 3-20

TCP Round Trip Time and Timeout TCP Round Trip Time and Timeout Q: how to set TCP out value?!! longer than RTT "! but RTT varies!! too short: premature out "! unnecessary retransmissions!! too long: slow reaction to segment loss Q: how to estimate RTT?!! SampleRTT: measured from segment transmission until ACK receipt "! ignore retransmissions!! SampleRTT will vary, want estimated RTT smoother "! average several recent measurements, not just current SampleRTT EstimatedRTT = (1-!)*EstimatedRTT +!*SampleRTT!! Exponential weighted moving average!! influence of past sample decreases exponentially fast!! typical value:! = 0.125 3-21 3-22 Example RTT estimation: TCP Round Trip Time and Timeout Setting the out!! EstimtedRTT plus safety margin "! large variation in EstimatedRTT -> larger safety margin!! first estimate of how much SampleRTT deviates from EstimatedRTT: DevRTT = (1-")*DevRTT + "* SampleRTT-EstimatedRTT (typically, " = 0.25) Then set out interval: TimeoutInterval = EstimatedRTT + 4*DevRTT 3-23 3-24

Outline TCP reliable data transfer!! TCP creates rdt service on top of IP s unreliable service!! Pipelined segments!! Cumulative acks!! TCP uses single retransmission r!! Retransmissions are triggered by: "! out events "! duplicate acks!! Initially consider simplified TCP sender: "! ignore duplicate acks "! ignore flow control, congestion control 3-25 3-26 TCP sender events: data rcvd from app:!! Create segment with seq #!! seq # is byte-stream number of first data byte in segment!! start r if not already running (think of r as for oldest unacked segment)!! expiration interval: TimeOutInterval out:!! retransmit segment that caused out!! restart r Ack rcvd:!! If acknowledges previously unacked segments "! update what is known to be acked "! start r if there are outstanding segments NextSeqNum = InitialSeqNum SendBase = InitialSeqNum loop (forever) { switch(event) event: data received from above create TCP segment with sequence number NextSeqNum if (r currently not running) start r pass segment to IP NextSeqNum = NextSeqNum + length(data) event: r out retransmit not-yet-acknowledged segment with smallest sequence number start r event: ACK received, with ACK field value of y if (y > SendBase) { SendBase = y if (there are currently not-yet-acknowledged segments) start r } TCP sender (simplified) Comment:!SendBase-1: last cumulatively ack ed byte Example:!SendBase-1 = 71; y= 73, so the rcvr wants 73+ ; y > SendBase, so that new data is acked } /* end of loop forever */ 3-27 3-28

TCP: retransmission scenarios TCP retransmission scenarios (more) Host A Host B Host A Host B Host A Host B out X loss Seq=92 out out X loss SendBase = 100 lost ACK scenario Sendbase = 100 SendBase = 120 SendBase = 120 Seq=92 out premature out SendBase = 120 Cumulative ACK scenario 3-29 3-30 TCP ACK generation [RFC 1122, RFC 2581] Fast Retransmit Event at Receiver Arrival of in-order segment with expected seq #. All data up to expected seq # already ACKed Arrival of in-order segment with expected seq #. One other segment has ACK pending Arrival of out-of-order segment higher-than-expect seq. #. Gap detected Arrival of segment that partially or completely fills gap TCP Receiver action Delayed ACK. Wait up to 500ms for next segment. If no next segment, send ACK Immediately send single cumulative ACK, ACKing both in-order segments Immediately send duplicate ACK, indicating seq. # of next expected byte Immediate send ACK, provided that segment starts at lower end of gap!! Time-out period often relatively long: "! long delay before resending lost packet!! Detect lost segments via duplicate ACKs. "! Sender often sends many segments back-toback "! If segment is lost, there will likely be many duplicate ACKs.!! If sender receives 3 ACKs for the same data, it supposes that segment after ACKed data was lost: "! fast retransmit: resend segment before r expires 3-31 3-32

Host A Host B Fast retransmit algorithm: out X event: ACK received, with ACK field value of y if (y > SendBase) { SendBase = y if (there are currently not-yet-acknowledged segments) start r } else { increment count of dup ACKs received for y if (count of dup ACKs received for y = 3) { resend segment with sequence number y } a duplicate ACK for already ACKed segment fast retransmit Figure 3.37 Resending a segment after triple duplicate Transport ACK Layer 3-33 3-34 Outline TCP Flow Control!! receive side of TCP connection has a receive buffer:!! app process may be slow at reading from buffer flow control sender won t overflow receiver s buffer by transmitting too much, too fast!! speed-matching service: matching the send rate to the receiving app s drain rate 3-35 3-36

TCP Flow control: how it works Outline (Suppose TCP receiver discards out-of-order segments)!! spare room in buffer = RcvWindow = RcvBuffer-[LastByteRcvd - LastByteRead]!! Rcvr advertises spare room by including value of RcvWindow in segments!! Sender limits unacked data to RcvWindow "! guarantees receive buffer doesn t overflow 3-37 3-38 TCP Connection Management Recall: TCP sender, receiver establish connection before exchanging data segments!! initialize TCP variables: "! seq. #s "! buffers, flow control info (e.g. RcvWindow)!! client: connection initiator Socket clientsocket = new Socket("hostname","port number");!! server: contacted by client Socket connectionsocket = welcomesocket.accept(); Three way handshake: Step 1: client host sends TCP SYN segment to server "! specifies initial seq # "! no data Step 2: server host receives SYN, replies with SYNACK segment "! server allocates buffers "! specifies server initial seq. # Step 3: client receives SYNACK, replies with ACK segment, which may contain data TCP Connection Management (cont.) Closing a connection: client closes socket: clientsocket.close(); Step 1: client end system sends TCP FIN control segment to server Step 2: server receives FIN, replies with ACK. Closes connection, sends FIN. close d wait closed client server close 3-39 3-40

TCP Connection Management (cont.) TCP Connection Management (cont) Step 3: client receives FIN, replies with ACK. closing client server "! Enters d wait - will respond with ACK to received FINs closing TCP server lifecycle Step 4: server, receives ACK. Connection closed. TCP client lifecycle Note: with small modification, can handle simultaneous FINs. d wait closed closed 3-41 3-42 Outline TCP congestion control: additive increase, multiplicative decrease!! Approach: increase transmission rate (window size), probing for usable bandwidth, until loss occurs "!additive increase: increase CongWin by 1 MSS every RTT until loss detected "!multiplicative decrease: cut CongWin in half after loss Saw tooth behavior: probing for bandwidth congestion window size 3-43 3-44

TCP Congestion Control: details TCP Slow Start!! sender limits transmission: LastByteSent-LastByteAcked # CongWin!! Roughly, rate = CongWin RTT Bytes/sec!! CongWin is dynamic, function of perceived congestion How does sender perceive congestion?!! loss event = out or 3 duplicate acks!! TCP sender reduces rate (CongWin) after loss event three mechanisms: "! AIMD "! slow start "! conservative after out events!! When connection begins, CongWin = 1 MSS "! Example: MSS = 500 bytes & RTT = 200 msec "! initial rate = 20 kbps!! available bandwidth may be >> MSS/RTT "! desirable to quickly ramp up to respectable rate!! When connection begins, increase rate exponentially fast until first loss event 3-45 3-46 TCP Slow Start (more) Refinement: inferring loss!! When connection begins, increase rate exponentially until first loss event: "! double CongWin every RTT "! done by incrementing CongWin for every ACK received!! Summary: initial rate is slow but ramps up exponentially fast RTT Host A Host B!! After 3 dup ACKs: "!CongWin is cut in half "!window then grows linearly!! But after out event: "!CongWin instead set to 1 MSS; "!window then grows exponentially "!to a threshold, then grows linearly Philosophy:!!3 dup ACKs indicates capable of delivering some segments!!out indicates a more alarming congestion scenario 3-47 3-48

Refinement Q: When should the exponential increase switch to linear? A: When CongWin gets to 1/2 of its value before out. Implementation:!! Variable Threshold!! At loss event, Threshold is set to 1/2 of CongWin just before loss event Summary: TCP Congestion Control!! When CongWin is below Threshold, sender in slow-start phase, window grows exponentially.!! When CongWin is above Threshold, sender is in congestion-avoidance phase, window grows linearly.!! When a triple duplicate ACK occurs, Threshold set to CongWin/2 and CongWin set to Threshold.!! When out occurs, Threshold set to CongWin/2 and CongWin is set to 1 MSS. 3-49 3-50 TCP sender congestion control Summary State Event TCP Sender Action Commentary Slow Start (SS) Congestion Avoidance (CA) SS or CA ACK receipt for previously unacked data ACK receipt for previously unacked data Loss event detected by triple duplicate ACK CongWin = CongWin + MSS, If (CongWin > Threshold) set state to Congestion Avoidance CongWin = CongWin+MSS * (MSS/CongWin) Threshold = CongWin/2, CongWin = Threshold, Set state to Congestion Avoidance SS or CA Timeout Threshold = CongWin/2, CongWin = 1 MSS, Set state to Slow Start SS or CA Duplicate ACK Increment duplicate ACK count for segment being acked Resulting in a doubling of CongWin every RTT Additive increase, resulting in increase of CongWin by 1 MSS every RTT Fast recovery, implementing multiplicative decrease. CongWin will not drop below 1 MSS. Enter slow start CongWin and Threshold not changed!! principles behind transport layer : "!multiplexing, "!reliable data transfer "!flow control "!congestion control!! instantiation and implementation in the Internet "!UDP "!TCP Next:!! leaving the edge (, transport layers)!! into the core 3-51 3-52