IEG4180 Tutorial 3 Shaoquan Zhang. Announcement The deadline of the project 1 is extended to 11pm, 12/02/2011 Follow the requirement of the marking scheme.

Slides:



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

Socket Programming. Basics Socket is an interface between application and network – Application creates a socket – Socket type dictates the style of communication.
Transmission Control Protocol (TCP)
Programming with TCP – I
© Janice Regan, CMPT 128, CMPT 371 Data Communications and Networking Socket Programming 0.
CSEE W4140 Networking Laboratory Lecture 6: TCP and UDP Jong Yul Kim
1 CS 4396 Computer Networks Lab Transmission Control Protocol (TCP) Part I.
TCP segment structure source port # dest port # 32 bits application data (variable length) sequence number acknowledgement number rcvr window size ptr.
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.
Elementary TCP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
Today’s topic Issues about sending structures with TCP. Server design alternatives: concurrent server and multiplexed server. I/O multiplexing.
CSCE 515: Computer Network Programming TCP Details Wenyuan Xu Department of Computer Science and Engineering.
UDP and Multi-thread Socket Programming
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.
Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write) Receive.
Socket Programming.
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
1 Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write)
1 Data Communications and Networking Socket Programming Part II: Design of Server Software Reference: Internetworking with TCP/IP, Volume III Client-Server.
CSEE W4140 Networking Laboratory Lecture 6: TCP and UDP Jong Yul Kim
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.
TCP. Learning objectives Reliable Transport in TCP TCP flow and Congestion Control.
1 ELEN 602 Lecture 15 More on IP TCP. 2 byte stream Send buffer segments Receive buffer byte stream Application ACKs Transmitter Receiver TCP Streams.
IP Multiplexing Ying Zhang EECS 489 W07.
Socket Programming -What is it ? -Why bother ?. Basic Interface for programming networks at transport level It is communication end point Used for inter.
ECE 4110 – Internetwork Programming Client-Server Model.
Sockets and intro to IO multiplexing. Goals We are going to study sockets programming as means to introduce IO multiplexing problem. We will revisit socket.
Hands On Networking Socket Programming Ram P Rustagi, ISE Dept Abhishek Gupta, ISE Dept Laxmi Kuber, MCA Dept June 28-30, 2012.
Elementary TCP Sockets
NET0183 Networks and Communications Lecture 31 The Socket API 8/25/20091 NET0183 Networks and Communications by Dr Andy Brooks Lecture powerpoints from.
Signal-Driven I/O Concepts and steps for using signal-driven I/O
Section 5: The Transport Layer. 5.2 CS Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 26.
Transport Layer: TCP and UDP. Overview of TCP/IP protocols Comparing TCP and UDP TCP connection: establishment, data transfer, and termination Allocation.
Elementary TCP Sockets
Winsock Programming Blocking and Asynchronous Sockets for Windows.
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.
CSE 461 Section. Let’s learn things first! Joke Later!
Chapter 2 Applications and Layered Architectures Sockets.
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.
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.
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.
CSCI 465 D ata Communications and Networks Lecture 27 Martin van Bommel CSCI 465 Data Communications & Networks 1.
Interfaces and Services Each layer provides a service to the layer above it. A service is a set of primitive operations. Under UNIX, primitives are implemented.
CSE/EE 461 Getting Started with Networking. 2 Basic Concepts A PROCESS is an executing program somewhere. –Eg, “./a.out” A MESSAGE contains information.
Socket Programming Lab 1 1CS Computer Networks.
Project 2: Socket Programming. Overview Sockets Working with sockets Client-Server example Project 1 Hints.
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.
Socket Programming. Computer Science, FSU2 Interprocess Communication Within a single system – Pipes, FIFOs – Message Queues – Semaphores, Shared Memory.
UNIX Sockets Outline UNIX sockets CS 640.
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 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 에서 사용.
1 Socket Interface. 2 Basic Sockets API Review Socket Library TCPUDP IP EthernetPPP ARP DHCP, Mail, WWW, TELNET, FTP... Network cardCom Layer 4 / Transport.
Netprog: TCP Sockets1 TCP Sockets Programming Creating a passive mode (server) socket.Creating a passive mode (server) socket. Establishing an application-level.
Socket Programming in C
Sockets, part 3 (nonblocking tcp using streams)
Network Programming CSC- 341
Socket Programming in C
I/O Systems I/O Hardware Application I/O Interface
TCP Sockets Programming
Advanced Network Programming spring 2007
28.
Process-to-Process Delivery: UDP, TCP
Presentation transcript:

IEG4180 Tutorial 3 Shaoquan Zhang

Announcement The deadline of the project 1 is extended to 11pm, 12/02/2011 Follow the requirement of the marking scheme

Outline Stream socket programming I/O modes in Unix

Stream Socket Programming Stream socket Q: When is the three-way handshake happened? A: When the client calls the function connect(), the TCP connection is built before the accept(). The function accept() selects one from the established connection queue.

TCP Connection Backlog TCP Connection Queue – For a given listening socket, the kernel maintains two queues for client sockets: An incomplete connection queue: three-way handshake is not completed yet; A completed connection queue: three-way handshake is completed. – listen(socket s, int backlog) backlog: the maximum of the sum of two queue lengths Problem: SYN attack

Accept() By default, when the completed queue is empty, the function will be blocked. Methods: – poll() : accept() becomes non-blocking – select(): accept() is called only when the completed queue is not empty – Multithread – Message driven

Message-driven Accept() SOCKET s=socket(); bind(); WSAAsyncSelect(s, m_hWnd, wMsg, FD_ACCEPT); //turn the socket s into a message-driven socket //m_hWnd: handle to window that will process the message //wMsg: message identifier; FD_ACCEPT: events to handle listen(s, 5);

Message Flow

WindowProc() HRESULT CNetProbeDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { if(message==wMsg) { SOCKET s = (SOCKET)wParam; int event = WSAGETSELECTEVENT(lParam); switch(event){ case FD_ACCEPT: OnAccept(s); break; case FD_READ: OnRead(s); //receive data break; } } return CDialog::WindowProc(message, wParam, lParam); } message events to handle void CNetProbeDlg::OnAccept(SOCKET s) { SOCKET newsfd = accept(s,…); WSAAsyncSelect(newsfd, m_hWnd, wMsg, FD_READ); //turn the new socket into a message-driven one; handle the recv() }

Add WindowProc() class review -> dialog class propertyoverrides

Unix I/O Modes Blocking I/O Non-blocking I/O I/O multiplexing (select and poll) Asynchronous I/O For a socket input operation, there are two steps: 1. wait data to arrive 2. copy data from kernel’s buffer to the process

Blocking I/O Acknowledgement: following pictures come from UNIX Networking Programming

Non-blocking I/O

I/O Multiplexing

Asynchronous I/O

Backup Host AHost B