User Datagram Protocol UDP. Remember, UDP is Not reliable; data may be dropped No guarantee of in-order delivery Duplicate data is possible No built-in.

Slides:



Advertisements
Similar presentations
Transport Layer3-1 Transport Overview and UDP. Transport Layer3-2 Goals r Understand transport services m Multiplexing and Demultiplexing m Reliable data.
Advertisements

Umut Girit  One of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer.
Java I/O The Cheat Sheet. Reading and Writing The basic architecture of Java IO is pluggable. The idea is to have some very simple classes do very simple.
Transmission Control Protocol (TCP)
IS333, Ch. 26: TCP Victor Norman Calvin College 1.
CSE551: Computer Network Review r Network Layers r TCP/UDP r IP.
User Datagram Protocol (UDP) Don McGregor Research Associate MOVES Institute
Chapter 3: Transport Layer
User Datagram Protocol. Introduction UDP is a connectionless transport protocol, i.e. it doesn't guarantee either packet delivery or that packets arrive.
Prepared By E. Musa Alyaman1 User Datagram Protocol (UDP) Chapter 5.
1 Java Networking – Part I CS , Spring 2008/9.
Transport Layer3-1 Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable data transfer.
Lecture 8 Chapter 3 Transport Layer
UDP© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science Department.
8-1 Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable data transfer m flow.
TCP Sockets Reliable Communication. TCP As mentioned before, TCP sits on top of other layers (IP, hardware) and implements Reliability In-order delivery.
Process-to-Process Delivery:
Review: –What is AS? –What is the routing algorithm in BGP? –How does it work? –Where is “policy” reflected in BGP (policy based routing)? –Give examples.
VIII. UDP Datagrams and Sockets. The User Datagram Protocol (UDP) is an alternative protocol for sending data over IP that is very quick, but not reliable:
Data Communications and Computer Networks Chapter 3 CS 3830 Lecture 12 Omar Meqdadi Department of Computer Science and Software Engineering University.
TCP Lecture 13 November 13, TCP Background Transmission Control Protocol (TCP) TCP provides much of the functionality that IP lacks: reliable service.
Transport Layer and UDP Tahir Azim Ref:

Transport Layer 3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012 Part.
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
RGEC MEERUT(IWT CS703) 1 Java Networking RGEC Meerut.
Chapter 3 Transport Layer
The Transmission Control Protocol (TCP) Application Services (Telnet, FTP, , WWW) Reliable Stream Transport (TCP) Connectionless Packet Delivery.
Transport Layer1 Ram Dantu (compiled from various text books)
Transport Layer Moving Segments. Transport Layer Protocols Provide a logical communication link between processes running on different hosts as if directly.
Lecture91 Administrative Things r Return homework # 1 r Review some problems in homework # 1 r Questions about grading? Yona r WebCT for CSE245 is working!
1. I NTRODUCTION TO N ETWORKS Network programming is surprisingly easy in Java ◦ Most of the classes relevant to network programming are in the java.net.
1 Chapter 28 Networking. 2 Objectives F To comprehend socket-based communication in Java (§28.2). F To understand client/server computing (§28.2). F To.
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
TCP Sockets Reliable Communication. TCP As mentioned before, TCP sits on top of other layers (IP, hardware) and implements Reliability In-order delivery.
Overview of TCP/IP protocols –Application layer (telnet, ssh, http, ftp, etc) The things that we use daily. –Transport layer (TCP, UDP) Allows processes.
Transport Layer 3-1 Chapter 3 Outline r 3.1 Transport-layer services r 3.2 Multiplexing and demultiplexing r 3.3 Connectionless transport: UDP.
Chapter 3: Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable data transfer.
Lecture 4 Overview. Ethernet Data Link Layer protocol Ethernet (IEEE 802.3) is widely used Supported by a variety of physical layer implementations Multi-access.
Transport Layer3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley,
Advanced UNIX programming Fall 2002, lecture 16 Instructor: Ashok Srinivasan Acknowledgements: The syllabus and power point presentations are modified.
Today’s topic: UDP Reliable communication over UDP.
MULTIPLEXING/DEMULTIPLEXING, CONNECTIONLESS TRANSPORT.
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
1 Transport Layer: Basics Outline Intro to transport UDP Congestion control basics.
CS/EE 145A Reliable Transmission over Unreliable Channel II Netlab.caltech.edu/course.
4343 X2 – The Transport Layer Tanenbaum Ch.6.
Socket programming in C. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
Data Communications and Networks Chapter 6 – IP, UDP and TCP ICT-BVF8.1- Data Communications and Network Trainer: Dr. Abbes Sebihi.
Transport Layer3-1 Chapter 3: Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable.
McGraw-Hill Chapter 23 Process-to-Process Delivery: UDP, TCP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
Introduction 1-1 source application transport network link physical HtHt HnHn M segment HtHt datagram destination application transport network link physical.
2: Transport Layer 11 Transport Layer 1. 2: Transport Layer 12 Part 2: Transport Layer Chapter goals: r understand principles behind transport layer services:
Process-to-Process Delivery:
UDP: User Datagram Protocol. What Can IP Do? Deliver datagrams to hosts – The IP address in a datagram header identify a host – treats a computer as an.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 33 Networking.
Chapter 3 outline 3.1 Transport-layer services
06- Transport Layer Transport Layer.
PART 5 Transport Layer Computer Networks.
Beyond HTTP Up to this point we have been dealing with software tools that run on browsers and communicate to a server that generates files that can be.
Transport Layer Our goals:
Process-to-Process Delivery:
CPEG514 Advanced Computer Networkst
Process-to-Process Delivery: UDP, TCP
Computer Networks Protocols
Chapter 3 Transport Layer
Socket Programming with UDP
Transport Layer Our goals:
Presentation transcript:

User Datagram Protocol UDP

Remember, UDP is Not reliable; data may be dropped No guarantee of in-order delivery Duplicate data is possible No built-in rate limiting

UDP Why accept these limitations? What happens if the network drops some data being sent in TCP? The receipt of data on the other application stops until a time-out expires and the data is resent and received If we are sending continuous updates, this means all data stops until the dropped data is resent and received UDP is usually lower latency than TCP

UDP But what if we are sending position updates every 1/30th of a second (frame rate?) If one update gets dropped, another one is on the way. What’s more, we’ll get the new faster than if we go through a timeout-resend cycle What about duplicates and out-of-order? How can you handle that?

Sequence Numbers You can easily handle this by including a monotonically increasing sequence number in your data If you get a sequence number equal to or before your last-received sequence number, throw the packet away

Stream vs. Packets TCP sockets are stream-oriented. You read or sent a stream of bytes, like reading or writing from a file. (InputStream, OutputStream) UDP is packet-oriented. You compose discrete packets or messages, then send them. (array of bytes, usually) UDP packets can be big (up to 64K), but you should keep them below 1500 bytes for performance reasons. This is usually easy to do.

Message Contents In TCP it was best to use text, because it was universal and easy to debug. But with numeric data we often have to translate from text to binary In UDP we are often dealing with data that is low latency and numeric. Position updates, streaming audio, streaming video, etc. It usually makes sense to use binary data for this, but this choice introduces all sorts of problems

Message Contents Binary float and double value formats vary from CPU to CPU and operating system to operating system The good news is that what a “float” or “double” is is sort of standardized The bad news is that byte order is not Different CPUs may arrange the four bytes in a float in different ways

Byte Order From least to most significant bit (integers) The same number may be represnted as On a different CPU This is called “endian”, as in big endian or little endian, a hangover from the elder days of computingµ

Byte Order Luckily, in Java these issues are taken care of for you so long as you stick to the standard input and output streams If you work with C or other languages, this is not necessarily taken care of for you, and you need to be alert to the implications But as long as it’s java on both ends, you will be OK, and maybe even if it’s not Java on each end

Protocols How should we arrange the data? With text, we could simply put it in some easily parsed text format that we could also read With binary, we need prior knowledge of how the data is laid out, so we can read it correctly. If the data isn’t read in the same format as it was written, you’ll get garbage

Java Binary Data ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); dos.writeFloat(17.0f); dos.writeFloat(23.0f); byte[] buffer = Baos.toByteArray();

Java Binary Data The data is now in an array of bytes. This is cross-platform, as long as the receiving side knows the byte order Floating Point Value 1Floating Point Value 2

Binary Data Reading is straightforward ByteArrayInputStream bais = new ByteArrayInputStream(buffer); DataInputStream dis = new DataInputStream(bais); float x = dis.readFloat();

Reading Data What happens if you read an integer from the data input stream instead of a float? A double instead of a float? This means that you need prior knowledge of what format the data is in so you don’t get garbage out It is a very good idea to have a protocol version number in the first slot of the binary data Usually a good idea to have a sequence number as well

UDP Sockets You create UDP (or “datagram”) sockets in one line. These are unconnected. With TCP, we had a stream connection to another host. With UDP it’s like an open mailbox that anyone can drop messages into DatagramSocket socket = new DatagramSocket(4545); Note no other IP, just the UDP port number (which is distinct from the TCP port number)

Datagram Packets The discrete messages being created are DatagramPackets. These contain an address (the port and IP of the machine they are being sent to) and a payload. The payload is our binary data byte[] buffer; …// fill out contents here DatagramPacket packet = new DatagramPacket(buffer, buffer.length, ipAddress, port) socket.send(packet);

Vs TCP UDP is packet-oriented, TCP is stream-oriented UDP is unreliable UDP is not TCP! A common rookie mistake is to say “I want to use UDP, but I also want it to be reliable”. You then wind up creating a complex protocol that re-invents TCP. Embrace the limitations of UDP

Rate Limiting TCP automatically throttles back the sender if it is overwhelming the receiver. Not so for UDP Due to the nature of the software, even if the sender and receiver have the same CPU speed, the sender will at full rate overwhelm the receiver. This means you need to be careful that you don’t denial of service your own software

Rate Limiting Packets Sent/sec Rec/sec Packets received at high rates fall off a cliff

Data Loss How do you handle losses of position updates? How about streaming audio data? One solution is to include redundant data or hamming codes in multiple packets. If one packet gets lost you can recover the data from other packets

Assignment Write an application that sends, in binary format, an entity identifier and position