1 Server Design Discuss Design issues for Servers Review Server Creation in Windows.

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
© Janice Regan, CMPT 128, CMPT 371 Data Communications and Networking Socket Programming 0.
Slide 1 Client / Server Paradigm. Slide 2 Outline: Client / Server Paradigm Client / Server Model of Interaction Server Design Issues C/ S Points of Interaction.
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.
Socket Programming.
Sockets Basics Conectionless Protocol. Today IPC Sockets Basic functions Handed code Q & A.
1 Data Communications and Networking Socket Programming Part II: Design of Server Software Reference: Internetworking with TCP/IP, Volume III Client-Server.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
Client Server Model The client machine (or the client process) makes the request for some resource or service, and the server machine (the server process)
Concurrent vs. iterative servers
SOCKETS Lecture #3. The Socket Interface Funded by ARPA (Advanced Research Projects Agency) in Developed at UC Berkeley Objective: to transport.
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.
Chapter 26 Client Server Interaction Communication across a computer network requires a pair of application programs to cooperate. One application on one.
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.
資 管 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.
9/12/2015B.R1 Socket Abstraction and Interprocess Communication B.Ramamurthy CSE421.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
 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.
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.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Remote Shell CS230 Project #4 Assigned : Due date :
Networking Tutorial Special Interest Group for Software Engineering Luke Rajlich.
CS 158A1 1.4 Implementing Network Software Phenomenal success of the Internet: – Computer # connected doubled every year since 1981, now approaching 200.
CPSC 441 TUTORIAL – FEB 13, 2012 TA: RUITNG ZHOU UDP REVIEW.
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.
1 Client-Server Interaction. 2 Functionality Transport layer and layers below –Basic communication –Reliability Application layer –Abstractions Files.
Sockets Socket = abstraction of the port concept: –Application programs request that the operating system create a socket when one is needed –O.S. returns.
Client/Server Socket Programming Project
CS 6401 Introduction to Computer Networks 09/21/2010 Outline - UNIX sockets - A simple client-server program - Project 1 - LAN bridges and learning.
Part 4: Network Applications Client-server interaction, example applications.
Socket Programming.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: HsinYu Ha.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Berkeley Socket Abstraction
CSCI 330 UNIX and Network Programming Unit XIV: User Datagram Protocol.
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.
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 3 TCP and UDP Sockets CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
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.
1 Issues in Client/Server Refs: Chapter 27 Case Studies RFCs.
CS 1652 Jack Lange University of Pittsburgh
Concurrent vs. iterative servers
Socket Programming in C
Socket Interface 1 Introduction 11 Socket address formats 2 API 12 13
Review: TCP Client-Server Interaction
CHAPTER 8 ELEMENTARY UDP SOCKETS
Interacting With Protocol Software
UNIX Sockets Outline Homework #1 posted by end of day
Advanced Network Programming spring 2007
Issues in Client/Server Programming
Console A presentation by Inti Vincenzo Pizzoni.
Presentation transcript:

1 Server Design Discuss Design issues for Servers Review Server Creation in Windows

2 Server Software Design Concurrent Vs. Iterative –Concurrent servers support multiple clients concurrently (may or may not use concurrent processes) –Iterative servers support a single client at a time. (Much easier to build, but usually much less efficient)

3 Server Software Design Concurrent Vs. Iterative –Concurrent servers support multiple clients concurrently (may or may not use concurrent processes) –Iterative servers support a single client at a time. (Much easier to build, but usually much less efficient) Connection-Oriented Vs. Connectionless –Connection Oriented access is provided through TCP which provides all of the reliability for the access. –Connectionless access is provided through UDP, and requires the application to provide reliability.

4 Server Software Design Stateless Vs. Stateful Servers –Stateful servers maintain status of ongoing client communications. Use of state information can allow more efficient communication (less information needed in each message), but it does open up the possibility of state dependencies if not carefully designed into the server. –Stateless servers rely on the client to provide all of the information needed for each request. Easier to design, but generally less efficient.

5 Stateless Vs. Stateful Servers Example Client queries server for file information (ftp, database search, etc.) Stateless model: –query includes filename, offset, # of bytes to read

6 Stateless Vs. Stateful Servers Example Client queries server for file information (ftp, database search, etc.) Stateless model: –query includes filename, offset, # of bytes to read Stateful model: –server maintains table of client info current queries containing filename, current offset –client sends request to read # of bytes –server accesses buffer for info, if available,or disk file.

7 Stateless Vs. Stateful Servers Filename: X Offset: 512 Buffer Pointer: Filename: Y Offset: 1024 Buffer Pointer: hash(IP, port) Buffer for file X, pointer at 512 Buffer for file Y, pointer at 1024

8 Basic Server Types Iterative connectionless Iterative connection-oriented Concurrent connectionless Concurrent connection-oriented

9 Basic Server Types Iterative connectionless Iterative connection-oriented Concurrent connectionless Concurrent connection-oriented

10 Iterative Connection-Oriented Server Create a socket & bind to the port for the service being offered. Place the socket in passive mode (listen) Accept the next connection request from the socket and obtain a new socket for the connection. Repeatedly send a request from client, formulate a response, and send response back to client. When finished with a client, close the connection & return to accept mode, waiting for a new connection.

11 Iterative Connectionless Server Create a socket and bind to the well- known address for the service being offered. Repeatedly read the next request from a client, formulate a response, and send a reply back to the client according to the application protocol.

12 Concurrent Connectionless Server (P) Create a socket & bind to the port for the service being offered. (P) Repeatedly call recvfrom to receive the next request from client, & create a new child process (c) Recieve a specific request upon creation as well as access to the socket. (c) Form a reply according to application protocol and send it back to client using sendto. (c) Terminate child process upon completion of task

13 Concurrent Connection- Oriented Server (P) Create a socket & bind to the port for the service offered. Leave the socket unconnected (P) Place the socket in passive mode (listen) (P) Repeatedly call accept to receive the next request from client, & create new child process (c) Receive a connection request upon creation (c) Interact with client (read request(s) & send(s)) (c) Terminate child process upon completion of task

14 Server Issues Request processing time Vs. Observed response time

15 Server Issues Request processing time Vs. Observed response time Use of INADDR_ANY to receive datagrams from any IP address.

16 Server Issues Request processing time Vs. Observed response time Use of INADDR_ANY to receive datagrams from any IP address. Connectionless communications: –ans = sendto(s, buf, buflen, flags, toaddr, toaddrlen) –ans = recvfrom(s, buf, buflen, flags, toaddr, toaddrlen)

17 Server Issues Request processing time Vs. Observed response time Use of INADDR_ANY to receive datagrams from any IP address. Connectionless communications: –ans = sendto(s, buf, buflen, flags, toaddr, toaddrlen) –ans = recvfrom(s, buf, buflen, flags, toaddr, toaddrlen) Use of exec for child processes

18 Apparent vs Real Concurrency Create a socket and bind to the well-known address for the service being offered. Add socket to the list of those on which I/O is possible

19 Apparent vs Real Concurrency Create a socket and bind to the well-known address for the service being offered. Add socket to the list of those on which I/O is possible Use select to wait for I/O on existing sockets

20 Apparent vs Real Concurrency Create a socket and bind to the well-known address for the service being offered. Add socket to the list of those on which I/O is possible Use select to wait for I/O on existing sockets If original responds, use accept for new connection & add socket to the list If other socket responds, use read / write to communicate Return to select

21 Apparent Concurrency Select (fdsize, &fd_set_in, &fd_set_out, &fd_set_err, time) –Fdsize: Not used in Windows, but used in UNIX or Linux to indicate the number of sockets that should be scanned. –&fd_set_in:address of the file descriptor set that is monitoring sockets for pending input work –&fd_set_out: Address of the file descriptor set that is moniroting sockets for pending outgoing work. –&fd_set_err: File descriptor set that monitors for exceptions to normal work (special error messages, or urgent messages) –Time: set to NULL to wait until there is some activity. Otherwise may be set to the maximum time to wait until select function returns.

22 Server Creation in Windows Formal service creation and installation requires administrative privilege.

23 Server Creation in Windows Formal service creation and installation requires administrative privilege. Normal console applications maintain access to a console window. Can’t delete window without terminating process.

24 Server Creation in Windows Formal service creation and installation requires administrative privilege. Normal console applications maintain access to a console window. Can’t delete window without terminating process. Would like to create a new process that is detached from the console (runs in “background” mode.

25 CreateProcess BOOL CreateProcess ( LPCTSTR IpApplicationName, LPTSTRIpCommandLine, LPSECURITY_ATTRIBUTES IpProcessAttributes, LPSECURITY_ATTRIBUTES IpthreadAttributes, DWORD fdwCreate, BOOLbInheritHandles, LPVOIDIpEnvironment, LPCTSTRIpCurrentDirectory, LPSTARTINFO IpStartInfo, LPPROCESS_INFORMATION IpProcessInformation );

26 struct STARTUPINFO typedef struct _STARTUPINFO { DWORDcb;DWORDdwFillAttribute; LPSTRlpReserved;DWORDdwFlags; LPSTR lpDesktop;WORDwShowWindow; LPSTRlpTitle;WORDcbReserved2; DWORDdwX;LPBYTE lpReserved2; DWORDdwY;HANDLE hStdInput; DWORDdwXSize;HANDLE hStdOutput; DWORDdwYSize;HANDLE hStdError; DWORDdwXCountChars; DWORDdwYCountChars; } STARTUPINFO, *LPSTARTUPINFO;

27 struct PROCESS_INFORMATION typedef struct _PROCESS_INFORMATION HANDLEhProcess; HANDLEhThread; DWORDdwProcessId; DWORDdwThreadID; } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;

28 Server Creation in Windows WinProcess.cpp #include #define NAMESIZE 50 void main (int argc, char *argv[]) { char AppName[NAMESIZE] = "timetest.exe"; char answer[NAMESIZE]; STARTUPINFO si; PROCESS_INFORMATION ProcessInformation;

29 Server Creation in Windows WinProcess.cpp // Get the desired background process name... if (argc != 2) { printf("Usage: Winprocess background_prog\n"); exit(1); } strcpy(AppName, argv[1]); printf("Starting %s in background mode. OK?(yes/no) ", AppName); gets (answer); if (strcmp(answer, "yes") != 0) { printf("Aborting background program startup...\n"); printf("Select any key to continue....."); gets(answer); exit(1); }

30 Server Creation in Windows WinProcess.cpp // Initialize the STARTINFO buffer to the // parameters needed for a detached process si.cb = sizeof(STARTUPINFO); si.lpReserved = NULL; si.lpTitle = NULL; si.lpDesktop = ""; si.dwX = 0L; si.dwY = 0L; si.dwXSize = 0L; si.dwYSize = 0L; si.dwFlags = 0; si.wShowWindow = SW_SHOW; si.lpReserved2 = NULL; si.cbReserved2 = 0;

31 Server Creation in Windows WinProcess.cpp if (!CreateProcess(NULL, AppName, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &ProcessInformation)) { printf("ERROR: Cannot launch child process\n"); printf("Select any key to continue....."); gets(answer); exit(1); } printf("New process id: %ld, new thread id: %ld\n", ProcessInformation.dwProcessId, ProcessInformation.dwThreadId); printf("Select any key to close WinProcess..."); gets(answer); }

32 timetest.cpp #include #define MYBUFFER80 #define ENTRYCOUNT15 void main () { char *timeptr; intentries; FILE *fp; time_t newtime;

33 timetest.cpp if ((fp = fopen( "timetest.dat", "w" )) == NULL ) exit(1); fputs( "This is my time test file.\n\n", fp); fclose (fp); for (entries = 0; entries < ENTRYCOUNT; entries++) { (void) time (&newtime); timeptr = ctime(&newtime); if ((fp = fopen( "timetest.dat", "a" )) == NULL ) exit(1); fputs (timeptr, fp); fputs ("Now we sleep... \n\n\n", fp); fclose (fp); Sleep (1000L); }

34 timetest.cpp (output) C:\cotter\cs490d_ws98\WinProcess>winprocess timetest This will start timetest in background mode. Proceed?(yes/no) yes The new process id is 68, and the new thread id is 46 Select any key to close WinProcess... C:\cotter\cs490d_ws98\WinProcess>

35 Summary Several different factors involved in server design 4 basic types of servers Server concurrency can be real or apparent Server creation in Windows allows user to configure operating environment for the server program