1 Issues in Client/Server Refs: Chapter 27 Case Studies RFCs.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Data Communications and Networking (Third Edition)
Slide 1 Client / Server Paradigm. Slide 2 Outline: Client / Server Paradigm Client / Server Model of Interaction Server Design Issues C/ S Points of Interaction.
Lecture 12 Overview. UDP Connected mode A UDP socket can be used in a call to connect() This simply tells the O.S. the address of the peer No handshake.
Lecture 17 Client/Server Programming Chat CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
Lecture 16 Overview. Creating a TCP socket int bind(int sockfd, const struct sockaddr *myaddr, socklen_t addrlen); int mysock; struct sockaddr_in myaddr;
Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write) Receive.
Socket Programming.
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.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
Concurrent vs. iterative servers
Client Server Design Alternatives© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid.
Introduction to Network Programming and Client-Server Design.
An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.
Client Server Model and Software Design TCP/IP allows a programmer to establish communication between two application and to pass data back and forth.
I NTRODUCTION OF S OCKET P ROGRAMMING L.Aseel AlTurki King Saud University.
Chapter 26 Client Server Interaction Communication across a computer network requires a pair of application programs to cooperate. One application on one.
Server Design Discuss Design issues for Servers Review Server Creation in Linux.
Hands On Networking Socket Programming Ram P Rustagi, ISE Dept Abhishek Gupta, ISE Dept Laxmi Kuber, MCA Dept June 28-30, 2012.
資 管 Lee Application Layer and Client-Server Model A3.
Elementary TCP Sockets
Socket Programming. Introduction Sockets are a protocol independent method of creating a connection between processes. Sockets can be either – Connection.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
© 2008 Cisco Systems, Inc. All rights reserved.Cisco ConfidentialPresentation_ID 1 Chapter 7: Transport Layer Introduction to Networking.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
Server Sockets: A server socket listens on a given port Many different clients may be connecting to that port Ideally, you would like a separate file descriptor.
Operating Systems Recitation 9, May 19-20, Iterative server Handle one connection request at a time. Connection requests stored in queue associated.
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 26.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
Chapter 2 Applications and Layered Architectures Sockets.
1 Server Design Discuss Design issues for Servers Review Server Creation in Windows.
Page 1 Jan 5, 1998 CMPN 369 CPSC441 Sockets Module Sockets Application Programming Interface (API)
CS 158A1 1.4 Implementing Network Software Phenomenal success of the Internet: – Computer # connected doubled every year since 1981, now approaching 200.
Position of application layer. Application layer duties.
Introduction to Socket
CSE/EE 461 Getting Started with Networking. 2 Basic Concepts A PROCESS is an executing program somewhere. –Eg, “./a.out” A MESSAGE contains information.
Chapter 27 Socket API Interface The interface between an application program and the communication protocols in an operating system is known as the Application.
Process to process communication over network connections Includes references to Comer and Stevens Internetworking with TCP/IP vol 3 Client-server programming.
1 Client-Server Interaction. 2 Functionality Transport layer and layers below –Basic communication –Reliability Application layer –Abstractions Files.
Client/Server Socket Programming Project
Part 4: Network Applications Client-server interaction, example applications.
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl1 1 Chapter 15 Application Layer and Client-Server.
Socket Programming.
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.
4343 X2 – The Transport Layer Tanenbaum Ch.6.
1 Dimension of Server Designs r Iterative vs Concurrent r Connection-oriented vs. connectionless r Stateful and stateless m Constrained by application.
Netprog: Client/Server Issues1 Issues in Client/Server Programming Refs: Chapter 27.
Lecture 15 Socket Programming CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
1 Network Communications A Brief Introduction. 2 Network Communications.
Client/Server Design Issues Based on Java Network Programming and Distributed Computing, Chapter 6 Also Online Java Tutorial, Sun.
1 K. Salah Application Layer Module K. Salah Network layer duties.
Boots Cassel Villanova University
Sockets and Beginning Network Programming
File Transfer and access
Client-Server Interaction
Interacting With Protocol Software
UNIX Sockets Outline Homework #1 posted by end of day
Lecture 4 Socket Programming Issues
Process-to-Process Delivery:
Advanced Network Programming spring 2007
Issues in Client/Server Programming
Server-side Programming CSE 333 Summer 2018
Internet Applications & Programming
Sockets Programming Socket to me!.
Sockets Programming Socket to me!.
Exceptions and networking
Presentation transcript:

1 Issues in Client/Server Refs: Chapter 27 Case Studies RFCs

2 Issues in Client Programming l Identifying the Server. l Looking up a IP address. l Looking up a well known port name. l Specifying a local IP address. l UDP client design. l TCP client design.

3 Identifying the Server l Options: –hard-coded into the client program. –require that the user identify the server. –read from a configuration file. –use a separate protocol/network service to lookup the identity of the server.

4 Identifying a TCP/IP server. l Need an IP address, protocol and port. –We often use host names instead of IP addresses. –usually the protocol (UDP vs. TCP) is not specified by the user. –often the port is not specified by the user. Can you name one common exception ?

5 Services and Ports l Many services are available via “well known” addresses (names). l There is a mapping of service names to port numbers: struct *servent getservbyname( char *service, char *protocol ); l servent->s_port is the port number in network byte order.

6 Specifying a Local Address l When a client creates and binds a socket it must specify a local port and IP address. l Typically a client doesn’t care what port it is on: haddr->port = 0; give me any available port !

7 Local IP address l A client can also ask the operating system to take care of specifying the local IP address: haddr->sin_addr.s_addr= INADDR_ANY; Give me the appropriate address

8 UDP Client Design l Establish server address (IP and port). l Allocate a socket. l Specify that any valid local port and IP address can be used. l Communicate with server (send, recv) l Close the socket.

9 Connected mode UDP l A UDP client can call connect() to establish the address of the server. l The UDP client can then use read() and write() or send() and recv(). l A UDP client using a connected mode socket can only talk to one server (using the connected-mode socket).

10 TCP Client Design l Establish server address (IP and port). l Allocate a socket. l Specify that any valid local port and IP address can be used. l Call connect() l Communicate with server (read,write). l Close the connection.

11 Closing a TCP socket l Many TCP based application protocols support multiple requests and/or variable length requests over a single TCP connection. l How does the server known when the client is done (and it is OK to close the socket) ?

12 Partial Close l One solution is for the client to shut down only it’s writing end of the socket. l The shutdown() system call provides this function. shutdown( int s, int direction); shutdown( int s, int direction); –direction can be 0 to close the reading end or 1 to close the writing end. –shutdown sends info to the other process!

13 TCP sockets programming l Common problem areas: –null termination of strings. –reads don’t correspond to writes. –synchronization (including close()). –ambiguous protocol.

14 TCP Reads l Each call to read() on a TCP socket returns any available data (up to a maximum). l TCP buffers data at both ends of the connection. l You must be prepared to accept data 1 byte at a time from a TCP socket!

15 Server Design IterativeConnectionlessIterativeConnection-Oriented ConcurrentConnection-OrientedConcurrentConnectionless

16 Concurrent vs. Iterative l An iterative server handles a single client request at one time. l A concurrent server can handle multiple client requests at one time.

17 Concurrent vs. Iterative Iterative Small, fixed size requestsSmall, fixed size requests Easy to programEasy to programIterative Small, fixed size requestsSmall, fixed size requests Easy to programEasy to program Concurrent Large or variable size requestsLarge or variable size requests Harder to programHarder to program Typically uses more system resourcesTypically uses more system resourcesConcurrent Large or variable size requestsLarge or variable size requests Harder to programHarder to program Typically uses more system resourcesTypically uses more system resources

18 Connectionless vs. Connection-Oriented Connection-Oriented EASY TO PROGRAMEASY TO PROGRAM transport protocol handles the tough stuff.transport protocol handles the tough stuff. requires separate socket for each connection.requires separate socket for each connection.Connection-Oriented EASY TO PROGRAMEASY TO PROGRAM transport protocol handles the tough stuff.transport protocol handles the tough stuff. requires separate socket for each connection.requires separate socket for each connection. Connectionless less overheadless overhead no limitation on number of clientsno limitation on number of clientsConnectionless less overheadless overhead no limitation on number of clientsno limitation on number of clients

19 Statelessness l State: Information that a server maintains about the status of ongoing client interactions. l Connectionless servers that keep state information must be designed carefully! Messages can be duplicated!

20 The Dangers of Statefullness l Clients can go down at any time. l Client hosts can reboot many times. l The network can lose messages. l The network can duplicate messages.

21 Concurrent Server Design Alternatives One child per client Spawn one thread per client Preforking multiple processes Prethreaded Server

22 One child per client l Traditional Unix server: –TCP: after call to accept(), call fork(). –UDP: after readfrom(), call fork(). –Each process needs only a few sockets. –Small requests can be serviced in a small amount of time. Parent process needs to clean up after children!!!! (call wait() ). Parent process needs to clean up after children!!!! (call wait() ).

23 One thread per client l Just like using fork() - just call pthread_create instead. l Using threads makes it easier (less overhead) to have sibling processes share information.

24 Pre fork() ’d Server l Creating a new process for each client is expensive. l We can create a bunch of processes, each of which can take care of a client. l Each child process is an iterative server.

25 Pre fork() ’d TCP Server l Initial process creates socket and binds to well known address. Process now calls fork() a bunch of times. Process now calls fork() a bunch of times. All children call accept(). All children call accept(). l The next incoming connection will be handed to one child.

26 Preforking l As the book shows, having too many preforked children can be bad. l Using dynamic process allocation instead of a hard-coded number of children can avoid problems. l The parent process just manages the children, doesn’t worry about clients.

27 Sockets library vs. system call l A preforked TCP server won’t usually work the way we want if sockets is not part of the kernel: –calling accept() is a library call, not an atomic operation. l We can get around this by making sure only one child calls accept() at a time using some locking scheme.

28 Prethreaded Server l Same benefits as preforking. l Can also have the main thread do all the calls to accept() and hand off each client to an existing thread.

29 What’s the best server design for my application? l Many factors: –expected number of simultaneous clients. –Transaction size (time to compute or lookup the answer) –Variability in transaction size. –Available system resources (perhaps what resources can be required in order to run the service).

30 Server Design l It is important to understand the issues and options. l Knowledge of queuing theory can be a big help. l You might need to test a few alternatives to determine the best design.