IP Multiplexing Ying Zhang EECS 489 W07.

Slides:



Advertisements
Similar presentations
Introduction to Sockets Jan Why do we need sockets? Provides an abstraction for interprocess communication.
Advertisements

Nonblocking I/O Blocking vs. non-blocking I/O
Socket Programming. Basics Socket is an interface between application and network – Application creates a socket – Socket type dictates the style of communication.
Sop, Fan Reference: Daniel Spangenberger Computer Networks PPT-4 Socket Programming.
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.
Daemon Processes Long lived utility processes Often started at system boot and ended when system shuts down Run in the background with no controlling terminal.
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;
Computer Networks Sockets. Sockets and the OS F An end-point for Internet connection –What the application “plugs into” –OS provides Application Programming.
TDC561 Network Programming Camelia Zlatea, PhD Week 3: Unix Asynchronous Events; Signals and Alarms API.
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.
I/O Multiplexing© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science.
Katz, Stoica F04 EECS 122: Introduction to Computer Networks Sockets Programming Computer Science Division Department of Electrical Engineering and Computer.
Programming with Berkeley Sockets Presented by Chris GauthierDickey Written by Daniel Stutzbach (I think!) for CIS 432/532 Useful References: ● man pages.
Event-Driven Programming Vivek Pai Dec 5, GedankenBits  What does a raw bit cost?  IDE  40GB: $100  120GB: $180  32MB USB Pen: $38  FireWire:
1 Data Communications and Networking Socket Programming Part II: Design of Server Software Reference: Internetworking with TCP/IP, Volume III Client-Server.
Introduction to Socket Programming April What is a socket? An interface between application and network –The application creates a socket –The socket.
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.
EECS122 Communications Networks Socket Programming January 30th, 2003 Jörn Altmann.
1 I/O Multiplexing Computer Network Programming. 2 Input from multiple sources Process keyboard sockets file A process may have multiple sources of input.
Introduction to Project 1 Web Client and Server Jan 2006.
Network LayerDatalink LayerPhysical LayerNetwork LayerDatalink LayerPhysical Layer ClientServer Framework.
Computer Networks Sockets. Outline F Socket basics F Socket details.
Some slides are in courtesy of J. Kurose and K. Ross Review of Previous Lecture Electronic Mail: SMTP, POP3, IMAP DNS Socket programming with TCP.
Lecture 8 UDP Sockets & I/O Multiplexing
Select The select function determines the status of one or more sockets, waiting if necessary, to perform synchronous I/O. int select( int nfds, fd_set*
CS4516: Medical Examiner Client/Server Evan Frenn 1.
ECE 4110 – Internetwork Programming Client-Server Model.
Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test.
Signal-Driven I/O Concepts and steps for using signal-driven I/O
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Networking Concepts, Socket Programming Spring 2012.
Socket Models Different ways to manage your connections.
Nonblocking I/O Blocking vs. non-blocking I/O Nonblocking input, output, accept, and connect Readings –UNP Ch16 1.
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.
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.
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 Socket Programming EE 122: Intro to Communication Networks Vern Paxson TAs: Lisa Fowler, Daniel Killebrew, Jorge Ortiz Materials with thanks to Sukun.
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,
Single Process, Concurrent, Connection-Oriented Servers (TCP) (Chapter 12)
UNIX Internet Socket API
CMPT 471 Networking II Network Programming © Janice Regan,
回到第一頁 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.
CSCI 330 UNIX and Network Programming Unit XVII: Socket Programming Detail.
I/O Multiplexing Chap 6. I/O Models  Blocking I/O Model  Nonblocking I/O Model  I/O Multiplexing Model  Signal Driven I/O Model  Asynchronous I/O.
Ioctl Operations. ioctl Function Interface Configuration  Netstat, ifconfig command 에서 사용.
EECS340 Recitation 1: Very helpful to your project Hongyu Gao 1.
@Yuan Xue CS 283Computer Networks Spring 2013 Instructor: Yuan Xue.
SOCKET PROGRAMMING Presented By : Divya Sharma.
More Project 1 and HW 1 stuff! Athula Balachandran Wolfgang Richter
I/O Multiplexing.
Socket Option.
Pertemuan 7 I/O Multiplexing
Socket Programming EE 122: Intro to Communication Networks Vern Paxson
Review: TCP Client-Server Interaction
Imam Ahmad Trinugroho, ST., MMSI
Sockets, part 2 (Addresses, poll())
Advanced Sockets Introduction to Networking
Lecture 4 Socket Programming Issues
Lecture 11 Overview.
EE 122: Sockets Kevin Lai September 11, 2002.
Socket Programming.
Computer Networks, Spring 2013
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,
Presentation transcript:

IP Multiplexing Ying Zhang EECS 489 W07

IP Multiplexing Multiple descriptors (interactive inputs, sockets) Multiple protocols’ daemon Example: A client two inputs: standard input and TCP socket Block in a call to fgets; server TCP sends a FIN Capability to tell the kernel : “ we want to be notified if one or more I/O conditions are ready” IP Multiplexing! (select and poll)

Blocking kernel application No data ready recvfrom System call Copy data Return OK Copy complete Process data

Polling kernel application System call No data ready recvfrom EWOULDBLOCK System call No data ready EWOULDBLOCK System call Data ready Copy data Return OK Copy complete Process data

Select kernel application No data ready select System call Return OK Copy data recvfrom System call Return OK Copy complete Process data

Select int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout); It takes these parameters: ·        int nfds - The highest file descriptor in all given sets plus one ·        fd_set *readfds - File descriptors that will trigger a return when data is ready to be read ·        fd_set *writefds - File descriptors that will trigger a return when data is ready to be written to ·        fd_set *errorfds - File descriptors that will trigger a return when an exception occurs ·        struct timeval *timeout - The maximum period select() should wait for an event

·        FD_ZERO(fd_set *) - Initializes an fd_set to be empty ·        FD_CLR(int fd, fd_set *) - Removes the associated fd from the fd_set ·        FD_SET(int fd, fd_set *) - Adds the associated fd to the fd_set ·        FD_ISSET(int fd, fd_set *) - Returns a nonzero value if the fd is in fd_set Upon return from select(), FD_ISSET() can be called for each fd in a given set to identify whether its condition has been met.

Any descriptors in set[1,4,5] are ready to read fd_set rset; FD_ZERO(1,&rest) FD_SET(1,&rset) FD_SET(4,&rset) FD_SET(5,&rset) Maxfdp=6 Any descriptors in set[2,7] are ready to write Any descriptors in set[1,4] have an exception condition X

Data ready Number of bytes is greater than low-water mark for socket receive buffer Read half of the connection is closed(FIN,EOF) Listen socket, incoming connection; Socket error pending

I/O Multiplexing: Polling first get current socket option settings int opts = fcntl (sock, F_GETFL); if (opts < 0) { perror ("fcntl(F_GETFL)"); abort (); } opts = (opts | O_NONBLOCK); if (fcntl (sock, F_SETFL, opts) < 0) { perror ("fcntl(F_SETFL)"); while (1) { if (receive_packets(buffer, buffer_len, &bytes_read) != 0) { break; if (read_user(user_buffer, user_buffer_len, &user_bytes_read) != 0) { then adjust settings finally store settings back get data from socket get user input

I/O Multiplexing: Select (2) fd_set read_set; struct timeval time_out; while (1) { FD_ZERO (read_set); FD_SET (stdin, read_set); /* stdin is typically 0 */ FD_SET (sock, read_set); time_out.tv_usec = 100000; time_out.tv_sec = 0; select_retval = select(MAX(stdin, sock) + 1, &read_set, NULL, NULL, &time_out); if (select_retval < 0) { perror ("select"); abort (); } if (select_retval > 0) { if (FD_ISSET(sock, read_set)) { if (receive_packets(buffer, buffer_len, &bytes_read) != 0) { break; if (FD_ISSET(stdin, read_set)) { if (read_user(user_buffer, user_buffer_len, &user_bytes_read) != 0) { set up parameters for select() run select() interpret result