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.

Slides:



Advertisements
Similar presentations
Nonblocking I/O Blocking vs. non-blocking I/O
Advertisements

1 Interprocess Communication CS 241 April 2, 2012 University of Illinois.
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.
Returning to zombies and parents and children. –What happens to the children if the parent dies? /* ILLUSTRATING THAT UPON A PARENT KILL THE ZOMBIES /*
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.
1 Select and poll and Signals CS 241 April 6, 2012 University of Illinois.
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.
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.
I/O Multiplexing© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science.
Programming with Berkeley Sockets Presented by Chris GauthierDickey Written by Daniel Stutzbach (I think!) for CIS 432/532 Useful References: ● man pages.
1 Data Communications and Networking Socket Programming Part II: Design of Server Software Reference: Internetworking with TCP/IP, Volume III Client-Server.
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.
Socket Addresses. Domains Internet domains –familiar with these Unix domains –for processes communicating on the same hosts –not sure of widespread use.
1 Nonblocking I/O Nonblocking reads and writes Buffers enabling overlapped nonblocking I/O Nonblocking connect.
Computer Networks Sockets. Outline F Socket basics F Socket details.
Computer Network Architecture and Programming
Advanced UDP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
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*
IP Multiplexing Ying Zhang EECS 489 W07.
Server Design Discuss Design issues for Servers Review Server Creation in Linux.
Elementary UDP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
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
More on Socket API. How to Place Timeouts on Sockets (1)  Using SIGALRM signal Connection timeout 기간의 축소 Response timeout advio/dgclitimeo3.clib/connect_timeo.c.
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.
Network Programming Eddie Aronovich mail:
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.
TELE 402 Lecture 10: Unix domain … 1 Overview Last Lecture –Daemon processes and advanced I/O functions This Lecture –Unix domain protocols and non-blocking.
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
CE Operating Systems Lecture 13 Linux/Unix interprocess communication.
Consider Letting inetd Launch Your Application. inetd daemon  Problems starting with /etc/rc(without inet daemon)  All the servers contains nearly identical.
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,
Cs423-cotter1 Concurrency Issues in Client/Server Applications Chapters 15,16, 28.
Single Process, Concurrent, Connection-Oriented Servers (TCP) (Chapter 12)
TCP Client-Server Example
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.
Fork(), Concurrent Server, Normal Termination ( 금 ) 김 희 준
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.
1 TCP Sockets Programming Creating a passive mode (server) socket.Creating a passive mode (server) socket. Establishing an application-level connection.Establishing.
Ioctl Operations. ioctl Function Interface Configuration  Netstat, ifconfig command 에서 사용.
Lecture 3 TCP and UDP Sockets CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
Netprog: TCP Sockets1 TCP Sockets Programming Creating a passive mode (server) socket.Creating a passive mode (server) socket. Establishing an application-level.
SOCKET PROGRAMMING Presented By : Divya Sharma.
I/O Multiplexing.
Socket Option.
Pertemuan 7 I/O Multiplexing
CH5 TCP Client - Server Example:
Review: TCP Client-Server Interaction
Imam Ahmad Trinugroho, ST., MMSI
Concurrent Servers Topics Limitations of iterative servers
Lecture 4 Socket Programming Issues
Chapter 5 (part 1) TCP Client /Server Example By: Lim Meng Hui.
Lecture 11 Overview.
TCP Sockets Programming
Socket Programming.
IPC Prof. Ikjun Yeom TA – Hoyoun
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:

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 writen readline

I/O Models

Blocking I/O Model

Nonblocking I/O Model

I/O Multiplexing Model

Signal Driven I/O Model

Asynchronous I/O Model  Synchronous vs. Asynchronous I/O  A synchronous I/O operation causes the requesting process to be blocked until that I/O operation completes.  An asynchronous I/O operation does not cause the requesting process to be blocked.

Performance select() Ready! read() Ready! read() Blocking I/O I/O Multiplexing

Usage of I/O Multiplexing  Client  handles an interactive input and a socket  handles multiple sockets at the same time  Server  handles both a listening socket and its connected socket  handles both TCP and UDP  handles multiple services and perhaps multiple protocols (e.g., inetd daemon)

Select Functions  Wait for any one of multiple events to occur and wake up the process only when  one or more of these events occurs  or, a specified amount of time has passed  wait forever: timeout = NULL  wait up to a fixed amount of time  polling: do not wait at all: timer value = 0  readset, writeset, exceptset after select returns may be changed  Need to set them again for testing file descriptors ready ready ? Read set Write set Exception set readwrite exception handling #include /* UNIX */ #include /* Windows */ int select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, const struct timeval *timeout); Returns: count of read desciptors if positive, 0 on timeout, -1 on error

How to Manipulate Descriptor Sets  Descriptor sets(fd_set): array of integers(FD_SETSIZE)  if fdset == NULL, no interest on the condition  caution: value result arguments  Macros

Conditions for Descriptor Ready  A socket is ready for reading (readable)  data in socket receive buffer >= low-water mark SO_RCVLOWAT (==1, default)  read-half of connection is closed (TCP has received a FIN)  listening socket and # of completed connections > 0  socket error is pending  A socket is ready for writing (writable)  available space in socket send buffer >= low-water mark SO_SNDLOWAT ( == 2048, default (TCP, UDP))  write-half connection is closed: write() will generate SIGPIPE and return error EPIPE  A socket using nonblocking connect has completed the connection, or the connect has failed  socket error is pending  Socket has an exception condition pending if  there exists out-of-band data  still at out-of-band mark

Filling the Pipe: Echo C/S  In stop-and-wait mode  response time = RTT(round-trip time) + server’s processing time(=0)  batch mode 로 (file 을 stdin 으로 redirection 해서 ) 1000 line 을 보내면 1000 x response time  Continuous Tx  Fill the pipe TCP Client TCP Server stdin stdout fgets fputs writen readline

str_cli Function - using I/O Multiplexing EoF on input  close socket  남은 reply 를 socket 에서 read 불가능

str_cli Function (Revisited)

TCP Echo Iterative Server

TCP Echo Iterative Server Program