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.

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.
Introduction 1 Lecture 13 Transport Layer (Transmission Control Protocol) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer.
Transmission Control Protocol (TCP)
© Janice Regan, CMPT 128, CMPT 371 Data Communications and Networking Socket Programming 0.
Out-of-Band Data© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science.
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 Issues about sending structures with TCP. Server design alternatives: concurrent server and multiplexed server. I/O multiplexing.
Chapter 7 Protocol Software On A Conventional Processor.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
Precept 3 COS 461. Concurrency is Useful Multi Processor/Core Multiple Inputs Don’t wait on slow devices.
I/O Multiplexing© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science.
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.
1 Nonblocking I/O Nonblocking reads and writes Buffers enabling overlapped nonblocking I/O Nonblocking connect.
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.
WXES2106 Network Technology Semester /2005 Chapter 8 Intermediate TCP CCNA2: Module 10.
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.
Transport Layer3-1 TCP sender (simplified) NextSeqNum = InitialSeqNum SendBase = InitialSeqNum loop (forever) { switch(event) event: data received from.
Signal-Driven I/O Concepts and steps for using signal-driven I/O
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 26.
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.
June-Hyun, Moon Computer Communications LAB., Kwangwoon University Chapter 26 - Threads.
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.
Chapter 2 Applications and Layered Architectures Sockets.
The Socket Interface Chapter 21. Application Program Interface (API) Interface used between application programs and TCP/IP protocols Interface used between.
Network Programming Eddie Aronovich mail:
2000 년 11 월 20 일 전북대학교 분산처리실험실 TCP Flow Control (nagle’s algorithm) 오 남 호 분산 처리 실험실
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.
TFTP: Trivial file transfer protocol
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.
OS2014 PROJECT 2 Supplemental Information. Outline Sequence Diagram of Project 2 Kernel Modules Kernel Sockets Work Queues Synchronization.
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.
CE Operating Systems Lecture 13 Linux/Unix interprocess communication.
Practical Session 11 Multi Client-Server Java NIO.
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.
Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed.
TCP Client-Server Example
CMPT 471 Networking II Network Programming © Janice Regan,
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.
1 Dimension of Server Designs r Iterative vs Concurrent r Connection-oriented vs. connectionless r Stateful and stateless m Constrained by application.
Ioctl Operations. ioctl Function Interface Configuration  Netstat, ifconfig command 에서 사용.
Netprog: Client/Server Issues1 Issues in Client/Server Programming Refs: Chapter 27.
Lecture 3 TCP and UDP Sockets CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
SPL/2010 Reactor Design Pattern 1. SPL/2010 Overview ● blocking sockets - impact on server scalability. ● non-blocking IO in Java - java.niopackage ●
Ch 3. Transport Layer Myungchul Kim
Fast Retransmit For sliding windows flow control we waited for a timer to expire before beginning retransmission of a packet TCP uses an additional mechanism.
I/O Multiplexing.
Socket Option.
CH5 TCP Client - Server Example:
Review: TCP Client-Server Interaction
Starting TCP Connection – A High Level View
Issues in Client/Server Programming
TA: Donghyun (David) Kim
An Introduction to Internetworking
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 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 Model

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.

Comparison of I/O Model

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 possibilities  wait forever: timeout = NULL  wait up to a fixed amount of time  polling: do not wait at all: timer value = 0

Select Function(Cont’d)  Exception conditions  arrival of out-of-band data for a socket  presence of control status information to be read from the master side of pseudo terminal in packet mode  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 (1)  A socket is ready for reading (readable)  Connected socket: read() returns  > 0 : data in socket receive buffer >= low-water mark( SO_RCVLOWAT )  by default, SO_RCVLOWAT == 1 (for TCP, UDP)  0 (end-of-file) : read-half of connection is closed(TCP has received a FIN)  -1 : socket error is pending  listening socket: # of completed connections > 0  A socket is ready for writing (writable): write returns  >= 0 : available space in socket send buffer >= low-water mark( SO_SNDLOWAT ) only if connected TCP socket or UDP socket  by default, SO_SNDLOWAT == 2048 (TCP, UDP)  -1  socket error is pending  write-half connection is closed: write() will generate SIGPIPE and return error EPIPE

Conditions for Descriptor Ready (2)  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

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

close versus shutdown  Close  decrease reference count  close the socket only if count == 0  terminates both directions of data transfer: reading and writing  Cannot read after close  Shutdown  initiate TCP’s normal termination regardless of reference count  terminates one direction (half of connection)  SHUT_RD: read-half of the connection is closed  Any data currently in socket receive buffer is discarded  Any data received after this call is acknowledged and then silently discarded  SHUT_WR: write-half of the connection is closed(half-close)  Any data currently in socket send buffer will be sent  SHUT_RDWR: read-half and write-half of connection are both closed  SHUT_RD + SHUT_WR

str_cli Function (Revisited)

TCP Echo Iterative Server

TCP Echo Iterative Server Program

Yet Another Problems  한 client 가 1byte data 보내고 계속 sleep 한다면 Readline() 에서 newline 도착할 때까지 blocked 됨  다른 client 도 서비스 불가  Denial of Service Attack  Possible Solutions  Use nonblocking I/O  Have each client serviced by a separate thread (or a process)  Place a timeout on the I/O operation