User Datagram Protocol An initial look at using the UDP transport protocol for sending and receiving network packets.

Slides:



Advertisements
Similar presentations
Computer Networks20-1 Chapter 20. Network Layer: Internet Protocol 20.1 Internetworking 20.2 IPv IPv6.
Advertisements

Taekyung Kim 0x410 ~ 0x International Standards Organization (ISO) is a multinational body dedicated to worldwide agreement on international.
Umut Girit  One of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer.
ECE Department: University of Massachusetts, Amherst ECE 354 Lab 3: Transmitting and Receiving Ethernet Packets.
Internet Control Message Protocol (ICMP)
The Network Layer Chapter 5. The IP Protocol The IPv4 (Internet Protocol) header.
UDP - User Datagram Protocol UDP – User Datagram Protocol Author : Nir Shafrir Reference The TCP/IP Guide - ( Version Version.
Socket Programming.
Chapter 5 The Network Layer.
EECS122 Communications Networks Socket Programming January 30th, 2003 Jörn Altmann.
Routing multicast messages How to adjust our Routing Table so we can examine the IGMP group membership messages.
UDP: User Datagram Protocol. UDP: User Datagram Protocol [RFC 768] r “bare bones”, “best effort” transport protocol r connectionless: m no handshaking.
ECE Department: University of Massachusetts, Amherst ECE 354 Spring 2009 Lab 3: Transmitting and Receiving Ethernet Packets.
Internet Networking Spring 2003
Leon-Garcia & Widjaja: Communication Networks Copyright ©2000 The McGraw Hill Companies The user clicks on a link to indicate which document is to be retrieved.
2: Application Layer 1 Chapter 2 Application Layer Computer Networking: A Top Down Approach, 5th edition. Jim Kurose, Keith Ross Addison-Wesley, April.
Chapter 3 Review of Protocols And Packet Formats
1 Application Presentation Session Transport Network Datalink Physical OSI model Application IPv4, IPv6 Device Driver Hardware TCPUDP Internet.
Socket options A way for network applications to ‘tweak’ the processing done at lower-levels of the TCP/IP stack.
Network Layer4-1 Network layer r transport segment from sending to receiving host r on sending side encapsulates segments into datagrams r on rcving side,
Network Layer4-1 Network layer r transport segment from sending to receiving host r on sending side encapsulates segments into datagrams r on rcving side,
Process-to-Process Delivery:
4: Network Layer4a-1 IP datagram format ver length 32 bits data (variable length, typically a TCP or UDP segment) 16-bit identifier Internet checksum time.
Petrozavodsk State University, Alex Moschevikin, 2003NET TECHNOLOGIES Internet Control Message Protocol ICMP author -- J. Postel, September The purpose.
© Janice Regan, CMPT 128, CMPT 371 Data Communications and Networking Network Layer ICMP and fragmentation.
1 Introduction to Raw Sockets 2 IP address Port address MAC address TCP/IP Stack 67 Bootp DHCP OSPF protocol frame type UDP Port # TCP Port.
CS1652 September 13th, 2012 The slides are adapted from the publisher’s material All material copyright J.F Kurose and K.W. Ross, All Rights.
The Network Layer. Network Projects Must utilize sockets programming –Client and Server –Any platform Please submit one page proposal Can work individually.
Socket Programming. Introduction Sockets are a protocol independent method of creating a connection between processes. Sockets can be either – Connection.
University of Calgary – CPSC 441.  UDP stands for User Datagram Protocol.  A protocol for the Transport Layer in the protocol Stack.  Alternative to.
Lecture 2 TCP/IP Protocol Suite Reference: TCP/IP Protocol Suite, 4 th Edition (chapter 2) 1.
1 ELEN602 Lecture 2 Review of Last Lecture Layering.
TCP/IP Essentials A Lab-Based Approach Shivendra Panwar, Shiwen Mao Jeong-dong Ryoo, and Yihan Li Chapter 5 UDP and Its Applications.
CMPT 471 Networking II Address Resolution IPv4 ARP RARP 1© Janice Regan, 2012.
Internetworking Internet: A network among networks, or a network of networks Allows accommodation of multiple network technologies Universal Service Routers.
Internet Protocols. Address Resolution IP Addresses are not recognized by hardware. If we know the IP address of a host, how do we find out the hardware.
1 Network Layer Lecture 16 Imran Ahmed University of Management & Technology.
Networking Tutorial Special Interest Group for Software Engineering Luke Rajlich.
CPSC 441 TUTORIAL – FEB 13, 2012 TA: RUITNG ZHOU UDP REVIEW.
Presented by Rebecca Meinhold But How Does the Internet Work?
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.
1 Introduction to TCP/IP. 2 OSI and Protocol Stack OSI: Open Systems Interconnect OSI ModelTCP/IP HierarchyProtocols 7 th Application Layer 6 th Presentation.
Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.
Socket Programming.
CSCI 330 UNIX and Network Programming Unit XIV: User Datagram Protocol.
1 Kyung Hee University Chapter 11 User Datagram Protocol.
Department of Computer Science Southern Illinois University Edwardsville Spring, 2010 Dr. Hiroshi Fujinoki CS 547/490 Network.
IP Fragmentation. Network layer transport segment from sending to receiving host on sending side encapsulates segments into datagrams on rcving side,
Packet Switch Network Server client IP Ether IPTCPData.
Socket Programming in C CS587x Lecture 3 Department of Computer Science Iowa State University.
1 Socket Interface. 2 Client-Server Architecture The client is the one who speaks first Typical client-server situations  Client and server on the same.
Process-to-Process Delivery:
IP - Internet Protocol No. 1  Seattle Pacific University IP: The Internet Protocol Kevin Bolding Electrical Engineering Seattle Pacific University.
Socket Programming(1/2). Outline  1. Introduction to Network Programming  2. Network Architecture – Client/Server Model  3. TCP Socket Programming.
1 Socket Interface. 2 Basic Sockets API Review Socket Library TCPUDP IP EthernetPPP ARP DHCP, Mail, WWW, TELNET, FTP... Network cardCom Layer 4 / Transport.
UDP. User Datagram Protocol (UDP)  Unreliable and unordered datagram service  Adds multiplexing  No flow control  Endpoints identified by ports 
SOCKET PROGRAMMING Presented By : Divya Sharma.
Behrouz A. Forouzan TCP/IP Protocol Suite, 3rd Ed.
Lecture 3 By Miss Irum Matloob.
Transport Protocols Relates to Lab 5. An overview of the transport protocols of the TCP/IP protocol suite. Also, a short discussion of UDP.
A quick intro to networking
Objective: ARP.
CS 1652 Jack Lange University of Pittsburgh
Internet Control Message Protocol (ICMP)
Process-to-Process Delivery:
CPEG514 Advanced Computer Networkst
Process-to-Process Delivery: UDP, TCP
32 bit destination IP address
Transport Layer 9/22/2019.
Presentation transcript:

User Datagram Protocol An initial look at using the UDP transport protocol for sending and receiving network packets

The Client/Server Paradigm A great many network applications employ this asymmetrical program-design idea: server application runs on station A time client application runs on station B request response

The sockets API for server server struct sockaddr_insaddr = {0}; intsalen = sizeof( saddr ); saddr.sin_family = AF_INET; saddr.sin_port = htons( port ); saddr.sin_addr = htonl( INADDR_ANY ); sock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); bind( sock, (sockaddr*)&saddr, salen ); struct sockaddr_inpeer = {0}; intplen = sizeof( peer ); charbuf[ BUFSIZ ] = {0}; recvfrom( sock, buf, BUFSIZ, 0, (sockaddr*)&peer, &plen ); sendto( sock, buf, BUFSIZ, 0, (sockaddr*)&peer, plen ); close( sock );

The sockets API for client client struct hostent*pp = gethostbyname( peername, NLEN ); struct sockaddr_inpeer = {0}; intplen = sizeof( peer ); peer.sin_family = AF_INET; peer.sin_port = htons( port ); peer.sin_addr.s_addr = *(uint32_t*)pp->h_addr; sock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); charmsg[ MSGSIZ ] = “Hello, world! \n”; sendto( sock, msg, MSGSIZ, 0, (sockaddr*)&peer, plen ); charbuf[ BUFSIZ ] = {0}; recvfrom( sock, buf, BUFSIZ, 0, (sockaddr*)&peer, &plen ); close( sock );

‘udpserver.cpp’ and ‘udpclient.cpp’ This pair of network application-programs provides us with a simple illustration of the basic paradigm: –First, launch ‘udpserver’ on station A –Then launch ‘udpclient’ on station B We can watch the ethernet frames being sent and received using our ‘nicwatch’

The packet format Ethernet Frame Header Internet Protocol Header UDP Header application’s message This message is written to the socket by the application This header is added by the transport layer This header is added by the network layer This header is added by the link layer

The UDP header Source portDestination port UDP ChecksumUDP Length 32 bits The UDP Length field is the total number of bytes of data, plus the 8 bytes that comprise this UDP Header structure The UDP Checksum field is computed using an algorithm based upon ones-complement addition of the 16-bit words in the entire UDP segment (its data and its header), along with an extra structure known as the UDP Pseudo-Header

The IP header Time-to-Live Header Checksum Source IP-address Destination IP-address IdentificationFragment offset Header length Total Length (in bytes) Type of Service IP version Protocol ID-number DM 32 bits Options

The Frame header Destination MAC-address (6 bytes) Source MAC-address (6 bytes) Type/Length (2 bytes ) 14 bytes The unique hardware-address for the network interface which should receive this packet The unique hardware-address for the network interface which is transmitting this packet An integer which describes the type of this packet, or its length in bytes Used for ‘filtering’ packets that are not intended for a particular host interface Needed when sending back replies to requests, and for error-notifications

Algorithm # Rough idea for a simplified ‘traceroute’ algorithm intttl = 1; do{ send UDP message toward host using ttl; receive response from router or from host; if ‘Resource temporarily unavailable’, break; if ‘No route to Host’, then show who sent it; } while ( ++ttl < 30 ); Implementing this basic ‘traceroute’ algorithm would require us to modify the value of the ‘Time-to-Live’ field in an outgoing packet’s IP-header, but doing that directly is prohibited by our lack of access to kernel data

Using ‘setsockopt()’ There is a socket-option at the IP-Level which allows an application program to adjust the ‘Time-to-Live’ value assigned to any outgoing UDP packet’s IP header unsigned charttl = 5;// maximum of five ‘hops’ inttlen = sizeof( ttl );// length of the option data if ( setsockopt( sock, SOL_IP, IP_TTL, &ttl, tlen ) < 0 ) { perror( “setsockopt TTL” ); exit(1); }

Demo: ‘tweakttl.cpp’ This program allows a user to specify the destination hostname, the port-number, and the desired ‘Time-to-Live’ value For example: $./tweakttl stargate You can watch the outgoing packet, and any ICPM reply-message, with ‘nicwatch’