Presentation is loading. Please wait.

Presentation is loading. Please wait.

NWEN 243 Networked Applications Lecture 13: Layer 4 – Transport NWEN 243 © , Kris Bubendorfer.

Similar presentations


Presentation on theme: "NWEN 243 Networked Applications Lecture 13: Layer 4 – Transport NWEN 243 © , Kris Bubendorfer."— Presentation transcript:

1 NWEN 243 Networked Applications Lecture 13: Layer 4 – Transport NWEN 243 © 2011-15, Kris Bubendorfer

2 Data loss some apps (e.g., audio) can tolerate some loss other apps (e.g., file transfer, telnet) require 100% reliable data transfer Timing some apps (e.g., Internet telephony, interactive games) require low delay to be “effective” Bandwidth some apps (e.g., multimedia) require minimum amount of bandwidth to be “effective” other apps (“elastic apps”) make use of whatever bandwidth they get Why 2 Transport protocols? 2

3 Application file transfer e-mail Web documents real-time audio/video stored audio/video interactive games financial apps Data loss no loss loss-tolerant no loss Bandwidth elastic audio: 5Kb-1Mb video:10Kb-5Mb same as above few Kbps up elastic Time Sensitive no yes, 100’s msec yes, few secs yes, 100’s msec yes and no Common Application Protocols 3

4 Internet Applications: Their Protocols and Transport Protocols Application e-mail remote terminal access Web file transfer streaming multimedia remote file server Internet telephony Application layer protocol smtp [RFC 821] telnet [RFC 854] http [RFC 2068] ftp [RFC 959] proprietary (e.g. RealNetworks) NFS proprietary (e.g., Vocaltec) Underlying transport protocol TCP TCP or UDP typically UDP 4

5 Recall… TCP Socket Structure Client process Client process Server process Server process “public” socket “connection” socket client socket 3-way handshake stream data NWEN 243 © 2011-15, Kris Bubendorfer

6 Socket programming with TCP Client must contact server server process must first be running server must have created socket (door) that welcomes client’s contact Client contacts server by: creating client-local TCP socket specifying IP address, port number of server process When client creates socket: client TCP establishes connection to server TCP When contacted by client, server TCP creates new socket for server process to communicate with client ◦ allows server to talk with multiple clients TCP provides reliable, in-order transfer of bytes (a “pipe”) between client and server Application viewpoint NWEN 243 © 2011-15, Kris Bubendorfer

7 TCP Steps Server (on hostId) Create public socket with port = x Wait for connection create connection socket Read request from connection socket Write reply to connection socket Client Create socket Connect to hostId, port x Send request on client socket Read reply from client socket Close client socket NWEN 243 © 2011-15, Kris Bubendorfer

8 Recall… Sockets and Ports IP (network layer) receives all datagrams for host IP delivers to appropriate transport layer (protocol) Transport protocol delivers to socket (application) IP application

9 TCP Ports and Sockets - Detail Server listens on a socket for a connection Connect request causes new socket on same port Server uses new thread to service connection TCP listener thread server socket port socket worker

10 Packet Data Units (PDUs) Packet-switched data networks Different name at each layer ◦ Layer 2 (Data Link) = frame ◦ Layer 3 (Network) = packet ◦ Layer 4 (Transport)  TCP = segment (data is broken up into multiple segments)  UDP = datagram (data must fit within maximum datagram size of 1024 bytes) NWEN 243 © 2011-15, Kris Bubendorfer

11 The Role of Headers Each PDU is header + data Network header addresses machines ◦ Denotes protocol (TCP or UDP) Transport header addresses ports (sockets) transport header destination port other header data source port source host destination host protocol network header

12 Protocol layering and data Each layer takes data (service data unit or SDU) from above adds header information to create new data unit (PDU) passes new data unit to layer below Allows protocol layers to coordinate PDU = SDU + header (SDU is encapsulated) application transport network link physical application transport network link physical source destination M M M M H t H t H n H t H n H l M M M M H t H t H n H t H n H l message segment/ datagram packet frame NWEN 243 © 2011-15, Kris Bubendorfer

13 Back to Ports Port numbers 0->1023 are well known port numbers, and are restricted. ◦ 25 SMTP ◦ 80 WWW ◦ etc Why does a transport header have both source and destination port numbers? Surely the destination port number alone is sufficient to identify the recipient? We saw how TCP creates multiple worker sockets per port ◦ we need this extra info to tell them apart ◦ so we can send packets to the correct thread. Client process Client process Server process Server process “public” socket “connection” socket client socket 3-way handshake stream data NWEN 243 © 2011-15, Kris Bubendorfer

14 Simple Example Client is assigned some random unused port x by its host. The SMTP server runs on well known port 25. Reply is to destination port x, with src port 25 Client Server source port: x dest. port: 25 source port:25 dest. port: x port used: smtp © 2011-14, Kris Bubendorfer

15 What About Two Clients? Web client host A Web server B Source IP: C Dest IP: B source port: x dest. port: 80 Source IP: C Dest IP: B source port: y dest. port: 80 port use: Web server Source IP: A Dest IP: B source port: x dest. port: 80 Web client host C Need more information to, ensure that the port is Demultiplexed correctly. NWEN 243 © 2011-15, Kris Bubendorfer

16 Delivery Without Guarantees Remember, IP Datagrams may be: ◦ Duplicated, ◦ Delivered out of order, ◦ Lost/Discarded ◦ Corrupted By the network layer. The TCP protocol will need to resolve these, while the UDP protocol ignores them. NWEN 243 © 2011-15, Kris Bubendorfer

17 How? Duplication: ◦ Store and forward (routers and switches) Out of Order Delivery ◦ Subsequent packets take different routes Lost ◦ Router input queue is full, drop packets Corrupted ◦ Interference on the physical media ◦ DLL layer can check and resolve this. NWEN 243 © 2011-15, Kris Bubendorfer

18 What can we do? The DLL can check packets for corruption (CRC), but How do we police the routers, with the changes in the routes dropping packets, and so on? We need to ensure the delivery from machine to machine is reliable This is only done in the end machines. NWEN 243 © 2011-15, Kris Bubendorfer

19 Simple Approach Send segment and starts a timer. Receiver receives segment. Receiver sends an ACK (acknowledgement). Either: ◦ ACK received, sender can send next segment. ◦ Timer goes off, assume segment lost so resends. This is called Stop-and-Wait. NWEN 243 © 2011-15, Kris Bubendorfer

20 Stop And Wait Sender transmits a data packet ◦ Stops and waits for an ACK from receiver ◦ Alternating (0 or 1) sequence number Sequence number used to: ◦ Identify lost packet ◦ Discard redundant packet A Timer is used to recover from a: ◦ lost packet ◦ lost ACK 0 0 0 0 NWEN 243 © 2011-15, Kris Bubendorfer

21 SenderReceiver No loss: send pkt0 rcv pkt0 send ACK0 rcv ACK0 send pkt1 rcv pkt1 send ACK1 rcv ACK1 send pkt0 rcv pkt0 send ACK0 rcv ACK0 send pkt1 SenderReceiver Lost packet: send pkt0 X (lost) tImeout resend pkt1 rcv pkt1 send ACK1 rcv ACK1 send pkt0 rcv pkt0 send ACK0 Stop And Wait NWEN 243 © 2011-15, Kris Bubendorfer

22 SenderReceiver Lost ACK: send pkt0 rcv pkt0 send ACK0 rcv ACK0 send pkt1 rcv pkt1 send ACK1 rcv pkt0 send ACK0 rcv ACK0 send pkt1 SenderReceiver Premature timeout: send pkt0 tImeout resend pkt1 rcv pkt1 drop duplicate rcv pkt0 send ACK0 (lost) X tImeout resend pkt1 rcv pkt1 send ACK1 rcv ACK1 send pkt0 rcv pkt1 send ACK1 rcv ACK1 send pkt0 Stop And Wait NWEN 243 © 2011-15, Kris Bubendorfer

23 Stop and wait is a terribly inefficient approach (wasting bandwidth especially when probability of loss is low), we can do better. example: 1 Gbps link, 15 ms e-e prop. delay, 1KB segment: T transmit = 8kb/seg 10 9 b/sec = 8 microsec Utilization = U = = 8 microsec 30.016 msec fraction of time sender busy sending = 0.00027 1KB seg every 30 msec -> 33kB/sec thruput over 1 Gbps link network protocol limits use of physical resources! Stop And Wait NWEN 243 © 2011-15, Kris Bubendorfer

24 Stop and Wait Performance Transmit 1250B at 10Mbps = 1 msec. Travel 600km in 3 msec Round trip ≈ 14-30+ msec Network performance <10% NWEN 243 © 2011-15, Kris Bubendorfer

25 Pipelining Acknowldegement arrives every msec Segment arrives every msec Network performance ≈100% NWEN 243 © 2011-15, Kris Bubendorfer

26 Pipelining: sender allows multiple, “in-flight ”, yet-to-be- acknowledged segments. Two generic forms of pipelined protocols: go-Back-N, selective repeat Pipelined Protocols NWEN 243 © 2011-15, Kris Bubendorfer

27 How do we manage all these Segments Inflight? We can use a software construct called a sliding window. ◦ We have a fixed size window (i.e. n segments)  This means we can have up to n segments on the ‘wire’.  When we successfully send a segment (i.e. its been ack’d by the receiver), we can move the window on by 1.  range of sequence numbers must be increased, need more than {0,1}.  We need buffering at sender and/or receiver 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 … Ack’d SegmentsunAck’d SegmentsForbidden sequence numbers available seq numbers NWEN 243 © 2011-15, Kris Bubendorfer

28 Protocols The important features of a sliding window protocol are: ◦ Sequence number assignment ◦ The resend protocol ◦ Window management We’re going to look at GoBackN (two variations) followed by Selective repeat. VIP: The sender and receiver views of the windows may differ at any time. NWEN 243 © 2011-15, Kris Bubendorfer

29 Go Back N Very simple receiver, only accepts segments that arrive in-order and discards others. Send each segment in window in turn, window moves on when first segment in window is acknowledged. Each segment has a timer, started when it is sent. Timeout on first segment, then all UNACKNOWLEDGED segments resent Because the receiver has discarded segments received out of order, it won’t see them twice. ◦ Packets 7, 8 and 9, see first point. 012345678910111213141516171819 window (size = 8) ACK’d sent not ACK’d available Not available 101114 window (size = 8) 6 timer expires!! 78978966 © 2011-13, Kris Bubendorfer

30 9876 Go Back N (Cumulative ACK) Should a later segment be ACK’d, consider all prior segments in the window to also be ACKed, so in other words: ◦ ACK is cumulative, so an ACK for a later sequence number effectively ACKs all preceding segments. Lost ACK(6) and ACK(7) Get ACK(8) 012345678910111213141516171819 window (size = 8) ack’ed sent not ack’ed available Not available 1011 67814 window (size = 8) 1516 ACK(8) © 2011-13, Kris Bubendorfer

31 Go Back N in action SenderReceiver send pkt0 send pkt1 rcv pkt0 send ACK0 rcv pkt1 send ACK1 send pkt2 Lost! send pkt3 rcv ACK0 send pkt4 rcv ACK1 send pkt5 rcv pkt3, discard send ACK1 rcv pkt4, discard send ACK1 rcv pkt5, discard send ACK1 pkt2 timeout send pkt2 send pkt3 send pkt4 send pkt5 rcv pkt2 send ACK2 NWEN 243 © 2011-15, Kris Bubendorfer

32 Selective Repeat Can send fewer segements at the cost of making the protocol more complicated. segments are individually acknowledged Only one segment resent on timer expiry Window must bracket any unacknowledged segments 012345678910111213141516171819 window (size = 8) ack’ed sent not ack’ed available not available 101114 window (size = 8) 6 timer expires!! 7866121516 © 2011-13, Kris Bubendorfer

33 Selective Repeat in Action pkt0 sent 0 1 2 3 4 5 6 7 8 9 pkt1 sent 0 1 2 3 4 5 6 7 8 9 pkt2 sent 0 1 2 3 4 5 6 7 8 9 lost pkt3 sent 0 1 2 3 4 5 6 7 8 9 ACK0 rcvd, pkt4 sent 0 1 2 3 4 5 6 7 8 9 pkt0 rcvd, ACK0 sent 0 1 2 3 4 5 6 7 8 9 pkt2 timeout, pkt2 sent 0 1 2 3 4 5 6 7 8 9 pkt1 rcvd, ACK1 sent 0 1 2 3 4 5 6 7 8 9 pkt3 rcvd, ACK3 sent 0 1 2 3 4 5 6 7 8 9 pkt4 rcvd, ACK4 sent 0 1 2 3 4 5 6 7 8 9 pkt5 rcvd, ACK5 sent 0 1 2 3 4 5 6 7 8 9 pkt2 rcvd, ACK2 sent 0 1 2 3 4 5 6 7 8 9 ACK1 rcvd, pkt5 sent 0 1 2 3 4 5 6 7 8 9 NWEN 243 © 2011-15, Kris Bubendorfer

34 PiggyBacking There is one further way to increase efficiency. ◦ Assume that any connection is duplex, ◦ with data flowing evenly back and forth. Now, we don’t need to send a separate acknowledgment, just attach to a returning data segment. NWEN 243 © 2011-15, Kris Bubendorfer

35 Fin.


Download ppt "NWEN 243 Networked Applications Lecture 13: Layer 4 – Transport NWEN 243 © , Kris Bubendorfer."

Similar presentations


Ads by Google