UDP Sockets Chap 8, 14, 22. Elementary UDP Sockets Chap 8.

Slides:



Advertisements
Similar presentations
Introduction to Sockets Jan Why do we need sockets? Provides an abstraction for interprocess communication.
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.
Prentice HallHigh Performance TCP/IP Networking, Hassan-Jain Chapter 2 TCP/IP Fundamentals.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public ITE PC v4.0 Chapter 1 1 OSI Transport Layer Network Fundamentals – Chapter 4.
TELE 402 Lecture 11: Advanced UDP… 1 by Dr Z. Huang Overview Last Lecture –Nonblocking I/O and ioctl operations –Source: Chapter 16 & 17 of Stevens’ book.
1 Transport Layer Lecture 9 Imran Ahmed University of Management & Technology.
EECC694 - Shaaban #1 lec #12 Spring Internet Transport Protocols Transmission Control Protocol (TCP):Transmission Control Protocol (TCP):
TELE202 Lecture 14 TCP/UDP (2) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (1) »Source: chapter 17 ¥This Lecture »TCP/UDP (2) »Source: chapter.
UNIT 07 Process – to – Process Delivery: UDP,TCP and SCTP
Socket Programming.
1 © 2003, Cisco Systems, Inc. All rights reserved. CCNA 1 v3.0 Module 11 TCP/IP Transport and Application Layers.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
TCP/IP Protocol Suite 1 Chapter 11 Upon completion you will be able to: User Datagram Protocol Be able to explain process-to-process communication Know.
TCP. Learning objectives Reliable Transport in TCP TCP flow and Congestion Control.
Advanced UDP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
WXES2106 Network Technology Semester /2005 Chapter 8 Intermediate TCP CCNA2: Module 10.
Process-to-Process Delivery:
Gursharan Singh Tatla Transport Layer 16-May
Process-to-Process Delivery:
TRANSPORT LAYER T.Najah Al-Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System NET331.
1 Transport Layer Computer Networks. 2 Where are we?
Elementary UDP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
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.
ECE 4110 – Internetwork Programming Client-Server Model.
Copyright 2003 CCNA 1 Chapter 9 TCP/IP Transport and Application Layers By Your Name.
IP and Errors IP Best Effort Datagrams can be: –Lost –Delayed –Duplicated –Delivered out of order –Corrupted.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
TCP/IP Essentials A Lab-Based Approach Shivendra Panwar, Shiwen Mao Jeong-dong Ryoo, and Yihan Li Chapter 5 UDP and Its Applications.
Transport Layer Layer #4 (OSI-RM). Transport Layer Main function of OSI Transport layer: Accept data from the Application layer and prepare it for addressing.
TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public ITE PC v4.0 Chapter 1 1 OSI Transport Layer Network Fundamentals – Chapter 4.
More on Socket API. How to Place Timeouts on Sockets (1)  Using SIGALRM signal Connection timeout 기간의 축소 Response timeout advio/dgclitimeo3.clib/connect_timeo.c.
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
Chapter 4: Interprocess Communication‏ Pages
Transport Layer Moving Segments. Transport Layer Protocols Provide a logical communication link between processes running on different hosts as if directly.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
CCNA 1 v3.0 Module 11 TCP/IP Transport and Application Layers.
23.1 Chapter 23 Process-to-Process Delivery: UDP, TCP, and SCTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 2 Applications and Layered Architectures Sockets.
The Socket Interface Chapter 22. Introduction This chapter reviews one example of an Application Program Interface (API) which is the interface between.
Overview of TCP/IP protocols –Application layer (telnet, ssh, http, ftp, etc) The things that we use daily. –Transport layer (TCP, UDP) Allows processes.
Advanced Sockets API-II Vinayak Jagtap
CPSC 441 TUTORIAL – FEB 13, 2012 TA: RUITNG ZHOU UDP REVIEW.
Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.
Computer Networks23-1 PART 5 Transport Layer. Computer Networks23-2 Position of Transport Layer Responsible for the delivery of a message from one process.
Programming with UDP – II Covered Subjects: Creating UDP sockets Client Server Sending data Receiving data Connected mode.
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.
IP1 The Underlying Technologies. What is inside the Internet? Or What are the key underlying technologies that make it work so successfully? –Packet Switching.
1 Dimension of Server Designs r Iterative vs Concurrent r Connection-oriented vs. connectionless r Stateful and stateless m Constrained by application.
1 Kyung Hee University Chapter 11 User Datagram Protocol.
McGraw-Hill Chapter 23 Process-to-Process Delivery: UDP, TCP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
1 Network Communications A Brief Introduction. 2 Network Communications.
1 K. Salah Application Layer Module K. Salah Network layer duties.
Process-to-Process Delivery:
Socket Programming original by Joonbok Lee KAIST heavily adapted by /Jens.
Chapter 11 User Datagram Protocol
Chapter 9: Transport Layer
Instructor Materials Chapter 9: Transport Layer
Elementary UDP Sockets
PART 5 Transport Layer Computer Networks.
TCP Transport layer Er. Vikram Dhiman LPU.
Magda El Zarki Professor, ICS UC, Irvine
CHAPTER 8 ELEMENTARY UDP SOCKETS
Chapter 14 User Datagram Protocol (UDP)
Process-to-Process Delivery:
Process-to-Process Delivery: UDP, TCP
Computer Networks Protocols
Transport Layer 9/22/2019.
Presentation transcript:

UDP Sockets Chap 8, 14, 22

Elementary UDP Sockets Chap 8

TCP versus UDP  TCP  connection-oriented  reliable  byte stream  Application: typically concurrent server  SMTP(Simple Mail Transfer Protocol)  Telnet  FTP  HTTP  NNTP(Network News TP)  UDP  connectionless  unreliable  datagram  Applications: typically iterative server  SNMP(Simple Network Management Protocol)  TFTP(Trivial FTP)  BOOTP(Bootstrap Protocol)  DHCP(Bootstrap Protocol)

Socket Functions for UDP Client/Server  recvfrom  Return value 0 : datagram of length 0  If no interest in senders address  from : NULL, addrlen : NULL

UDP Echo Server : main Function  Never terminate  TCP 에서 처럼 EOF 를 알 수 없음  Lost datagram: UDP has no flow control  Socket receive buffer 가 full 이면 datagram 은 discard 됨  Protocol-dependent

UDP Echo Client: main Function  Lost datagram  recvfrom 에서 blocked  수신된 response 가 server 가 보낸 것이지 verification 필요.  Response 의 IP address 와 server address 를 비교 : IP address 를 2 개이상 가질 수 있음  IP address 를 domain name 으로 conversion 하여 domain name 으로 비교  Server 는 각각의 client 에 대하여 socket 을 create  Server 가 running 되고 있지 않으면 recvfrom 에서 blocked

If Server is not Running ??  Asynchronous error 발생  보낸 datagram 이 전달되지 못해서, 만일 ICMP error message(port unreachable) 가 reporting 되었을 경우 client process 에게 error return 해 줄 방법이 없음  recvfrom 으로 기다리고 있는 client 에게 kernel 이 error 를 발생시킨 datagram 의 destination IP address 와 destination port # 를 알려 줄 방법 없음  Solution: use a connected UDP socket  단, UDP socket 이 1 개의 peer 와 connect 하면 asynchronous error 가 return 가능  Sendto() 가 successful return 했다고 해서 datagram 이 destination 에 전달된 것은 아님.  다만, interface output queue 에 성공적으로 write 했음을 의미함

UDP Client_Server from Client’s Perspective  Client ephemeral port is chosen once (on the first sendto ), and then never changes.  Client IP address may change for every datagram, if client does not bind a specific address (in case of multihomed host)

UDP Client-Server from Server’s Perspectives UDP Client-Server from Server’s Perspectives

Connected UDP Socket  Call connect only to communication with exactly one peer  Kernel just records IP address and port # of the peer  Connected UDP socket  No need to specify the destination IP addr and port # for output operation  write, send instead of sendto  No need to verify received response  read, recv instead of recvfrom  Asynchronous errors are returned  Connected UDP socket provides better performance  Unconnected UDP socket: make a temporary connection(1/3 overhead)  May connect multiple times for a UDP socket by specifying a new IP addr and port #

UDP Echo Client: Connected UDP socket  Lost datagram due to  lost in network  socket receive buffer overflow  UDP has no flow control  Connected UDP socket can also be used to determine the outgoing interface to the particular destination

TCP and UDP Echo Server using select

Advanced I/O Functions Chap 14

How to Place Timeouts on Sockets (1)  Using SIGALRM signal Connection timeout 기간의 축소 Response timeout advio/dgclitimeo3.clib/connect_timeo.c alarm() 은 초 단위 setitimer() 는 micro sec 단위 설정 가능 ( 실제는 msec 단위로 동작 )

How to Place Timeouts on Sockets (2)  Using select with timeout advio/dgclitimeo1.c lib/readable_timeo.c

How to Place Timeouts on Sockets (3)  Using SO_RCVTIMEO and SO_SNDTIMEO socket options  Caution: timeout applies to all I/O operations for the socket descriptor advio/dgclitimeo2.c

More on Socket I/O Functions  recv and send (only for sockets)  Scatter read and gather write

More Advanced Socket I/O Functions

Ancillary data - cmsghdr Structure

Socket I/O Summary

Socket and Standard I/O  Buffering in Standard I/O library  fully buffered: all stream except for terminal devices  line buffered : terminal devices  unbuffered: stderr  Caution  Socket 에 standard I/O functions(fgets, fputs) 를 쓰면 fully buffered 됨

Advanced UDP Sockets Chap 22

More on UDP  Determining destination address of a UDP datagram  Wild card address can receive unicast, broadcast, and multicast datagrams on any interface  Need some features for reliabilility  timeout and retransmission  handle lost datagrams  support sequence number

Receiving Flags, Destination IP addr, and Interface Index  Use recvmsg  returns msg_flags value  MSG_BCAST: broadcast address  MSG_MCAST: multicast address  MSG_TRUNC: datagram truncated  MAG_CTRUNC: control info truncated  returns destination addr of the received datagram setsockopt(sockfd, IPPROTO_IP, IP_RECVDSTADDR, &on, size(on));  return index of the interface on which the datagram was received setsockopt(sockfd, IPPROTO_IP, IP_RECVIF, &on, size(on));

Datagram Truncation  If received UDP datagram > application buffer, the datagram will be truncated  Three possible scenarios on datagram truncation (depending upon implementation)  Discard the excess bytes and return MSG_TRUNC flag (Berkeley-derived implementation, Posix1.g)  Discard the excess bytes but do not tell the application (Solaris 2.5)  Keep the excess bytes and return them in subsequent read operatation  Allocate application buffer > largest datagram  If equal, error

When to Use UDP instead of TCP  Adv. Of UDP  supports broadcasting and multicasting  no overhead for connection setup or teardown  UDP requires 2 packets to exchange a request and a reply  TCP requires about 10 packets to exchange assuming new TCP connection is established for each request-reply exchange  Features of TCP that are not provided by UDP  positive ACK, reTx of lost packet, duplicate packet detection, sequencing of packets  windowed flow control  slow start and congestion avoidance  Recommendation of UDP Usage  must be used for broadcast or multicast applications  desired level of error control must be added  can be used for simple request-reply applications  error detection must be needed  should not be used for bulk data transfer

Adding Reliability to a UDP Application  Add sequence numbers to detect lost, duplicated, or out- of-ordered packets  Add timeout and retransmission  How to estimate retransmission timeout (RTO) - Jacobson  When estimate RTO ? - Karn  Only when we receive a reply to a request that is not retransmitted, update the RTT estimators  Retransmission ambiguity problem

Example

Concurrent UDP Servers  Most UDP servers are iterative, but use concurrent server where the processing of client request takes long time