Review: How to create a TCP end point? What is the right format for sin_port and sin_addr in the sockaddr_in data structure? How many different ways we.

Slides:



Advertisements
Similar presentations
Sockets: Network IPC Internet Socket UNIX Domain Socket.
Advertisements

I/O Models Satish Krishnan. I/O Models Blocking I/O Non-blocking I/O I/O Multiplexing Signal driven I/O Asynchronous I/O.
I/O Multiplexing Road Map: 1. Motivation 2. Description of I/O multiplexing 3. Scenarios to use I/O multiplexing 4. I/O Models  Blocking I/O  Non-blocking.
Today’s topic: Basic TCP API –Socket –Bind –Listen –Connect –Accept –Read –Write –Close.
Today’s topic Issues about sending structures with TCP. Server design alternatives: concurrent server and multiplexed server. I/O multiplexing.
Lecture 16 Overview. Creating a TCP socket int bind(int sockfd, const struct sockaddr *myaddr, socklen_t addrlen); int mysock; struct sockaddr_in myaddr;
Networks: TCP/IP Socket Calls1 Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
Socket Programming.
Sockets Basics Conectionless Protocol. Today IPC Sockets Basic functions Handed code Q & A.
Advanced Sockets Amit Mondal TA, Intro to Networking Jan 22, 2009 Recital 3 Introduction to Networking Instructor: Prof. Aleksandar Kuzmanovic.
Network Programming UNIX Internet Socket API. Everything in Unix is a File –When Unix programs do any sort of I/O, they do it by reading or writing to.
1 Socket Interfaces Professor Jinhua Guo CIS527 Fall 2003.
I/O Multiplexing© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science.
Tutorial 8 Socket Programming
Programming with Berkeley Sockets Presented by Chris GauthierDickey Written by Daniel Stutzbach (I think!) for CIS 432/532 Useful References: ● man pages.
I/O Multiplexing Capability of tell the kernel that wants to be notified when one or more I/O conditions are ready. For example, I/O data is available.
Introduction to Project 1 Web Client and Server Jan 2006.
Computer Networks Sockets. Outline F Socket basics F Socket details.
Lecture 8 UDP Sockets & I/O Multiplexing
IP Multiplexing Ying Zhang EECS 489 W07.
Elementary UDP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
ECE 4110 – Internetwork Programming Client-Server Model.
University of Calgary – CPSC 441.  UDP stands for User Datagram Protocol.  A protocol for the Transport Layer in the protocol Stack.  Alternative to.
Zhu Reference: Daniel Spangenberger Computer Networks, Fall 2007 PPT-4 Socket Programming.
 Wind River Systems, Inc Chapter - 13 Network Programming.
Remote Shell CS230 Project #4 Assigned : Due date :
TELE 402 Lecture 4: I/O multi … 1 Overview Last Lecture –TCP socket and Client-Server example –Source: Chapters 4&5 of Stevens’ book This Lecture –I/O.
1 COMP/ELEC 429/556 Introduction to Computer Networks Creating a Network Application Some slides used with permissions from Edward W. Knightly, T. S. Eugene.
Socket Programming Lec 2 Rishi Kant. Review of Socket programming Decide which type of socket – stream or datagram. Based on type create socket using.
1 I/O Multiplexing We often need to be able to monitor multiple descriptors:We often need to be able to monitor multiple descriptors: –a generic TCP client.
CSCE 515: Computer Network Programming Select Wenyuan Xu Department of Computer Science and Engineering.
Advanced Sockets API-II Vinayak Jagtap
I/O Multiplexing. TCP Echo Client: I/O operation is sequential !! tcpcliserv/tcpcli01.c: lib/str_cli.c: TCP Client TCP Server stdin stdout fgets fputs.
1 Computer Networks An Introduction to Computer Networks University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani Lecture 3: Sockets.
CSCE 515: Computer Network Programming UDP Socket Wenyuan Xu Department of Computer Science and Engineering.
Socket Programming Lab 1 1CS Computer Networks.
I/O Multiplexing. What is I/O multiplexing? When an application needs to handle multiple I/O descriptors at the same time –E.g. file and socket descriptors,
Programming with UDP – II Covered Subjects: Creating UDP sockets Client Server Sending data Receiving data Connected mode.
Today’s topic: UDP Reliable communication over UDP.
Review: –Concurrent server and multiplexed server How they work? Which one is better?
UNIX Internet Socket API
CMPT 471 Networking II Network Programming © Janice Regan,
Review: – Why layer architecture? – peer entities – Protocol and service interface – Connection-oriented/connectionless service – Reliable/unreliable service.
2: Application Layer 1 Socket Programming UNIX Network Programming, Socket Programming Tutorial:
CSCI 330 UNIX and Network Programming Unit XIV: User Datagram Protocol.
回到第一頁 Client/sever model n Client asks (request) – server provides (response) n Typically: single server - multiple clients n The server does not need.
Socket Programming. Computer Science, FSU2 Interprocess Communication Within a single system – Pipes, FIFOs – Message Queues – Semaphores, Shared Memory.
1 Spring Semester 2008, Dept. of Computer Science, Technion Internet Networking recitation #7 Socket Programming.
Distributed Computing Systems Project 3 – Nutella a P2P Streaming Movie System Due: Sunday, February 14 th.
Lecture 3 TCP and UDP Sockets CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
Sockets Intro to Network Programming. Before the internet... Early computers were entirely isolated No Internet No network No model No external communications.
1 UDP Sockets Programming Creating UDP sockets.Creating UDP sockets. –Client –Server Sending data.Sending data. Receiving data.Receiving data. Connected.
I/O Multiplexing.
Elementary UDP Sockets
Review: TCP Client-Server Interaction
Imam Ahmad Trinugroho, ST., MMSI
Lecture 4 Socket Programming Issues
UDP Sockets Programming
Socket Programming in C
Lecture 11 Overview.
TCP Sockets Programming
Advanced Network Programming spring 2007
Socket Programming.
TCP/IP Socket Programming in C
Elementary UDP Sockets connectionless, unreliable, datagram
Internet Networking recitation #8
I/O Multiplexing We often need to be able to monitor multiple descriptors: a generic TCP client (like telnet) need to be able to handle unexpected situations,
Sockets.
Socket Programming with UDP
Presentation transcript:

Review: How to create a TCP end point? What is the right format for sin_port and sin_addr in the sockaddr_in data structure? How many different ways we can bind a socket?

How to specify the maximum number of connections for a socket? How to find out the remote machine information?

Today’s topic: Introduction to UDP Some server design alternatives Select

TCP: Reliable byte stream service. –Different ways to build client/servers –How to get around blocking I/O –Assumption: whatever sent will eventually be received!! UDP: Unreliable datagram service. Data may get lost – application may need to deal with more details in the communication.

Why UDP: –Applications that do not need 100% reliability communication. E.g VoIP, video stream, DNS servers. –Applications care a lot about performance: high performance computing (TCP cares too much about fairness). –Applications that need multicast or broadcast (TCP only supports point to point communication).

Basic UDP service interface: –Socket, bind, sendto, recvfrom, close UDP server client socket bind sendto recvfrom Sendto close TCP server client socket Bind connect Listen … … close close

#include ssize_t recvfrom(int sockfd, void *buff, size_t nbytes, int flags, struct sockaddr *from, socklen_t *addrlen); ssize_t sendto(int sockfd, void *buff, size_t nbytes, int flags, const struct sockaddr *to, socklen_t addrlen); See udpsender.c/udprecv.c for communication using UDP.

Server design alternatives: concurrent and multiplexed server. Concurrent server (see lect3/example5.c): Use a new child process to handle a new connection requests.

Multiplexed Server: The use of select. I/O multiplexing – check the file descriptor before performing a blocking operation (what happen to the client when a concurrent server clushs?).

–The select function that allows: To detect any of the descriptors in the read set are ready for reading. To detect any of the descriptors in the write set are ready for writing To detect any of the descriptors in the error set have exception conditions pending. To wait for a period for something to happen.

#include int select (int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout)

–Set the timeout value: Struct timeval { long tv_sec; /* seconds */ long tv_usec; /* microseconds */ } Wait forever (blocking select): timeout = NULL Non blocking select (return right away: tv_sec = 0; tv_usec = 0; Wait for a certain amount of time: tv_sec and tv_usec

–Set the set of file descriptors value: void FD_ZERO(fd_set *fdset) void FD_SET(int fd, fd_set *fdset) void FD_CLR(int fd, fd_set *fdset) void FD_ISSET(int fd, fd_set *fdset)

–Maxfdp1: the maximum file descriptor number plus 1. (can just specify a big number (64) if unknown). –Select clears the uninteresting file descriptors in the fd_sets – always reset the fd_sets before calling select.

When is a socket ready for read? The number of bytes in the socket is more than the low-water mark (can be set, default 1 for TCP/UDP socket) Half of the connection is closed Listening socket with nonzero of completed connections Socket error.

When is a socket ready for write? The available buffer space is larger than the low-water mark Half the connection is closed Error pending Exception? Out of band data exists.

A multiplexed server (multiserv.c) –A single process to handle everything including connection request and data processing. –Using select the check on all descriptors that might need communication. Response to whatever from the clients.