1 Dimension of Server Designs r Iterative vs Concurrent r Connection-oriented vs. connectionless r Stateful and stateless m Constrained by application.

Slides:



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

Computer Net Lab/Praktikum Datenverarbeitung 2 1 Overview Sockets Sockets in C Sockets in Delphi.
© Janice Regan, CMPT 128, CMPT 371 Data Communications and Networking Socket Programming 0.
1 Chapter 6 Datagram Delivery by UDP Just as the Internet Protocol uses the services of subnetworks, transport protocols build upon the services of IP.
Data Communications and Networking (Third Edition)
Elementary TCP Sockets Computer Networks Computer Networks Term B10 UNIX Network Programming Vol. 1, Second Ed. Stevens Chapter 4.
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.
Sockets Basics Conectionless Protocol. Today IPC Sockets Basic functions Handed code Q & A.
1 Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write)
Socket Addresses. Domains Internet domains –familiar with these Unix domains –for processes communicating on the same hosts –not sure of widespread use.
SOCKETS Lecture #3. The Socket Interface Funded by ARPA (Advanced Research Projects Agency) in Developed at UC Berkeley Objective: to transport.
Lecture 10 Overview. Network API Application Programming Interface – Services that provide the interface between application and protocol software often.
I NTRODUCTION OF S OCKET P ROGRAMMING L.Aseel AlTurki King Saud University.
1 Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Yukun Zhu (Slides are mainly from Monia Ghobadi, and Amin Tootoonchian,
Client Software Design Objectives: Understand principles of C/S design, with focus on clients Review Windows implementations of Socket functions.
Server Design Discuss Design issues for Servers Review Server Creation in Linux.
ECE 4110 – Internetwork Programming Client-Server Model.
Hands On Networking Socket Programming Ram P Rustagi, ISE Dept Abhishek Gupta, ISE Dept Laxmi Kuber, MCA Dept June 28-30, 2012.
Network Programming Tutorial #9 CPSC 261. A socket is one end of a virtual communication channel Provides network connectivity to any other socket anywhere.
Elementary TCP Sockets
9/12/2015B.R1 Socket Abstraction and Interprocess Communication B.Ramamurthy CSE421.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
Vassil Roussev 2 A socket is the basic remote communication abstraction provided by the OS to processes. controlled by operating system.
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 26.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2000 Chapter 16 Socket Interface
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2000 Chapter 16 Socket Interface.
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.
The Socket Interface Chapter 22. Introduction This chapter reviews one example of an Application Program Interface (API) which is the interface between.
CS 158A1 1.4 Implementing Network Software Phenomenal success of the Internet: – Computer # connected doubled every year since 1981, now approaching 200.
CSCE 515: Computer Network Programming UDP Socket Wenyuan Xu Department of Computer Science and Engineering.
Chapter 27 Socket API Interface The interface between an application program and the communication protocols in an operating system is known as the Application.
Socket Programming Lab 1 1CS Computer Networks.
1 Client-Server Interaction. 2 Functionality Transport layer and layers below –Basic communication –Reliability Application layer –Abstractions Files.
Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.
Part 4: Network Applications Client-server interaction, example applications.
Socket Programming.
CSCI 330 UNIX and Network Programming Unit XV: Transmission Control Protocol.
Berkeley Socket Abstraction
UNIX Sockets Outline UNIX sockets CS 640.
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl1 1 Chapter 16 Socket Interface.
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.
1 Network Communications A Brief Introduction. 2 Network Communications.
1 K. Salah Application Layer Module K. Salah Network layer duties.
1 Socket Interface. 2 Client-Server Architecture The client is the one who speaks first Typical client-server situations  Client and server on the same.
1 Socket Interface. 2 Basic Sockets API Review Socket Library TCPUDP IP EthernetPPP ARP DHCP, Mail, WWW, TELNET, FTP... Network cardCom Layer 4 / Transport.
SOCKET PROGRAMMING Presented By : Divya Sharma.
Socket Programming original by Joonbok Lee KAIST heavily adapted by /Jens.
Socket Abstraction and Interprocess Communication
Socket Interface 1 Introduction 11 Socket address formats 2 API 12 13
CHAPTER 8 ELEMENTARY UDP SOCKETS
Interacting With Protocol Software
Network Programming CSC- 341
Socket Abstraction and Interprocess Communication
Socket Programming in C
TCP Sockets Programming
Chapter 16 Socket Interface.
Issues in Client/Server Programming
Socket Abstraction and Interprocess Communication
CSC Advanced Unix Programming, Fall 2015
Socket Abstraction and Interprocess Communication
Socket Abstraction and Interprocess Communication
Socket Abstraction and Interprocess Communication
Socket Abstraction and Interprocess Communication
CSI 4118 – UNIVERSITY OF OTTAWA
Presentation transcript:

1 Dimension of Server Designs r Iterative vs Concurrent r Connection-oriented vs. connectionless r Stateful and stateless m Constrained by application protocols r Four classes of servers  Iterative, connectionless server ( 37 TIME )  Iterative, connection-oriented server ( 13 DAYTIME )  Concurrent, connectionless server ( 7 ECHO ) m Concurrent, connection-oriented server

2 Server Design Combinations Iterative r simple Concurrent r multi-user ( time slice, multi-core ) r multi-processor, multi-process, multi- thread, async IO r performance Connection (TCP) r reliable pipe r prone to attack r 3 way handshaking (SYN attack) r Nothing going on when idle m resource exhaustion m client crash – unintentional or intentional m memory leak Connectionless (UDP) r simple r fast most app diagnostic programs some app

3 Iterative Server r A simple iterative server m Creates a socket, binds address, and makes it passive m Server accepts a connection, services the request, and closes the connection. This step repeats for each incoming connection r What is the problem with this simple server?

4 master thread Iterative UDP Server addr family port msock port bind server port/addr sendto recvfro m r Other clients block while one request is processed, not for a full connection time r Each subsequent recvfrom can be from a different client r Server identifies client by from_addr r Not reliable, but no connection overhead

5 master thread Iterative TCP Server addr family port addr family port msock port ssock Queue bind liste n accep t client port/addr server port/addr read, write work on new sock until close then, go back to accept three way handshaking disconnect sequence data

6 Iterative, Connection-Oriented Server (1-3) 1. Create a socket r sock = socket (PF_INET, SOCK_STREAM, 0); 2. Bind to a local address r bind (sock, localaddr, addrlen) r For well-known service, use getservbyname (name, protocol) to get port number from service name r Often use wildcard address (INADDR_ANY) for host IP 3. Place socket in passive mode r listen (sock, queuelen) r Need to establish queue length

7 Iterative, Connection-Oriented Server (4) 4. Accepting a connection from a client m new_sock = accept (sock, addr, addrlen); m accept() blocks until there is an incoming request m Based on the queue length specified in listen() call, incoming connection requests may be accepted by the operating system and queued to be accepted later by the application server using accept() m New socket descriptor (new_sock) is used to send and receive messages with the connected client.

8 Iterative, Connection-Oriented Server (5-6) 5. Interact with client using new_sock m Depending on application-level protocol m Send and receive messages using the connected socket send (new_sock,…) or write (new_sock…) recv (new_sock…) or read (new_sock, …) 6. Close the connection and return to step 4 to accept a new connection m close (new_sock)

9 Iterative, Connection-Oriented Server Example r DAYTIME server m Server blocks until a client connects m Client sends no data m time() returns a 32-bit integer that gives the current time in seconds since the Mac epoch m ctime() converts the epoch seconds into human- readable character string m close the connection Is it safe here?

10 Possible Server Deadlocks r A deadlock occurs when m The client waits for the server m The server waits for the client r A simple deadlock Server Client accept () connect () | | recv () recv ()

11 More Server Deadlocks r Deadlocks can happen in a more subtle way r Why deadline in the following scenario? Server Client accept () connect () | | recv () send (BIGBUFFER) | send () ---> | ----

12 Iterative, Connectionless Server Example r TIME server listens at port 37 r recvfrom() to receive the datagram sent by the client m Read only one byte m What about the remaining data? r time() returns the number of seconds in EPOCH r Converting the number of seconds to network byte order before sending to the client!