Lecture 6 Overview
TCP: Transmission Control Protocol TCP is an alternative transport layer protocol supported by TCP/IP. TCP provides: – Connection-oriented – Reliable – Full-duplex – Byte-Stream CPE 401/601 Lecture 6 : TCP/IP model 2
TCP Segment Format CPE 401/601 Lecture 6 : TCP/IP model 3 Destination Port Options (if any) Data 1 byte Source Port Sequence Number Request Number (ACK) 1 byte offset Rsrvd Control Window Size ChecksumUrgent Pointer
TCP Segment Format Sequence Number refers to the first byte of data included in the segment Request Number (Acknowledgement Number) indicates the byte number of the next data that is expected to be received – All bytes up through this number have been received Window: tells sender how many bytes it can send before receiver will have to toss it away – due to fixed buffer size CPE 401/601 Lecture 6 : TCP/IP model 4
Control Flags URG: urgent data included ACK: this segment is (among other things) an acknowledgement RST: error - abort the session SYN: synchronize Sequence Numbers (setup) FIN: polite connection termination CPE 401/601 Lecture 6 : TCP/IP model 5
TCP Connection Creation CPE 401/601 Lecture 6 : TCP/IP model 6 Client Server SYN ISN=X SYN ISN=X 1 SYN ISN=Y, ACK=X+1 SYN ISN=Y, ACK=X+1 2 ACK=Y+1 3 time
TCP Data and ACK Once the connection is established, data can be sent Each data segment includes a sequence number identifying the first byte in the segment Each segment (data or empty) includes a request number indicating what data has been received CPE 401/601 Lecture 6 : TCP/IP model 7
TCP Buffers The TCP layer doesn’t know when the application will ask for any received data – buffers incoming data so it’s ready when application asks for it Both client and server allocate buffers to hold incoming and outgoing data Both client and server announce with every ACK how much buffer space remains – Window field in a TCP segment CPE 401/601 Lecture 6 : TCP/IP model 8
Send Buffers The application gives the TCP layer some data to send The data is put in a send buffer, where it stays until the data is ACK’d – it has to stay, as it might need to be sent again! TCP layer won’t accept data from application unless (or until) there is buffer space CPE 401/601 Lecture 6 : TCP/IP model 9
ACKs A receiver doesn’t have to ACK every segment – it can ACK many segments with a single ACK segment Each ACK can also contain outgoing data – piggybacking If a sender doesn’t get an ACK after some time limit (MSL) it resends the data. CPE 401/601 Lecture 6 : TCP/IP model 10
TCP Segment Order IP delivers TCP segments and IP in not reliable – IP datagrams can be lost or arrive out of order Most TCP implementations will accept out-of- order segments – if there is room in the buffer Once the missing segments arrive, a single ACK can be sent for the whole thing TCP/IP model 11
Termination The TCP layer can send a RST segment that terminates a connection if something is wrong Usually the application tells TCP to terminate the connection politely with a FIN segment CPE 401/601 Lecture 6 : TCP/IP model 12
Connection Termination CPE 401/601 Lecture 6 : TCP/IP model 13 App1 App2 FIN SN=X FIN SN=X 1 ACK=X+1 2 ACK=Y+1 4 FIN SN=Y FIN SN=Y 3...
TCP TIME_WAIT Once a TCP connection has been terminated there is some unfinished business: – What if the ACK is lost? The last FIN will be resent and it must be ACK’d. – What if there are lost or duplicated segments that finally reach the destination after a long delay? TCP hangs out for a while to handle these situations CPE 401/601 Lecture 6 : TCP/IP model 14
Lecture 7 Routing CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger slides are modified from J. Kurose & K. Ross
Two Key Network-Layer Functions forwarding: move packets from router’s input to appropriate router output routing: determine route taken by packets from source to dest. – routing algorithms Analogy – routing: process of planning trip from source to destination – forwarding: process of getting through single interchange CPE 401/601 Lecture 7 : Routing 16
1 2 3 local forwarding table header value output link routing and forwarding 0111 value in arriving packet’s header routing algorithm CPE 401/601 Lecture 7 : Routing 17
Connection setup 3 rd important function in some architectures – ATM, frame relay, X.25 before datagrams flow, two end hosts and intervening routers establish virtual connection – routers get involved network vs transport layer connection service: – network: between two hosts may also involve intervening routers in case of VCs – transport: between two processes CPE 401/601 Lecture 7 : Routing 18
Network service model Q: What service model for channel transporting datagrams from sender to receiver? Example services for individual datagrams: – guaranteed delivery – guaranteed delivery with less than 40 msec delay Example services for a flow of datagrams: – in-order datagram delivery – guaranteed minimum bandwidth to flow – restrictions on changes in inter-packet spacing CPE 401/601 Lecture 7 : Routing 19
Network layer service models Network Architecture Internet ATM Service Model best effort BR VBR ABR UBR Bandwidth none constant rate guaranteed rate guaranteed minimum none Loss no yes no Order no yes Timing no yes no Congestion feedback no (inferred via loss) no congestion no congestion yes no Guarantees ? CPE 401/601 Lecture 7 : Routing 20
Connection and connection-less service Datagram network provides network-layer connectionless service Virtual Circuit network provides network-layer connection service analogous to the transport-layer services, but: – service: host-to-host – no choice: network provides one or the other – implementation: in network core CPE 401/601 Lecture 7 : Routing 21
Virtual circuits src-to-dst path behaves much like telephone circuit – performance-wise – network actions along source-to-dest path call setup, teardown for each call before data can flow each packet carries VC identifier – not destination host address every router on source-dest path maintains “state” for each passing connection link, router resources (bandwidth, buffers) may be allocated to VC – dedicated resources = predictable service) CPE 401/601 Lecture 7 : Routing 22
VC implementation A VC consists of: – path from source to destination – VC numbers one number for each link along path – entries in forwarding tables in routers along path packet belonging to VC carries VC number – rather than dest address VC number can be changed on each link – New VC number comes from forwarding table CPE 401/601 Lecture 7 : Routing 23
Forwarding table VC number interface number Incoming interface Incoming VC # Outgoing interface Outgoing VC # … … Forwarding table in northwest router: Routers maintain connection state information! CPE 401/601 Lecture 7 : Routing 24
Virtual circuits: signaling protocols used to setup, maintain teardown VC used in ATM, frame-relay, X.25 not used in today’s Internet application transport network data link physical application transport network data link physical 1. Initiate call 2. incoming call 3. Accept call 4. Call connected 5. Data flow begins 6. Receive data CPE 401/601 Lecture 7 : Routing 25
Datagram networks no call setup at network layer routers: no state about end-to-end connections – no network-level concept of “connection” packets forwarded using destination host address – packets between same src-dst pair may take different paths application transport network data link physical application transport network data link physical 1. Send data 2. Receive data CPE 401/601 Lecture 7 : Routing 26
Forwarding table Destination Address Range Link Interface through through through otherwise 3 4 billion possible entries CPE 401/601 Lecture 7 : Routing 27
Longest prefix matching Network Layer 4-28 Prefix Match Link Interface otherwise 3 DA: Examples DA: Which interface?
Datagram or VC network: why? Internet (datagram) – data exchange among computers “elastic” service, no strict timing requirement – “smart” end systems (computers) can adapt, perform control, error recovery simple inside network, complexity at “edge” – many link types different characteristics uniform service difficult CPE 401/601 Lecture 7 : Routing 29
Datagram or VC network: why? ATM (VC) – evolved from telephony – human conversation: strict timing, reliability requirements need for guaranteed service – “dumb” end systems telephones complexity inside network CPE 401/601 Lecture 7 : Routing 30