Presentation is loading. Please wait.

Presentation is loading. Please wait.

Internet and Intranet Protocols and Applications

Similar presentations


Presentation on theme: "Internet and Intranet Protocols and Applications"— Presentation transcript:

1 Internet and Intranet Protocols and Applications
Lecture 3: Network Programming Feb 8, 2000 Arthur P. Goldberg Computer Science Department New York University

2 Client/Server Paradigm
Basis for most application layer communications Client (typically) Initiates communication Sends requests and receives responses Interacts with just a few servers at a time Server (typically) Waits for incoming requests Receives requests and sends responses Interacts with many clients concurrently 11/28/2018

3 How do applications use the transport layer?
Conceptual operations (Comer 4.3) Allocate local resources for communications Specify local and remote communications endpoints Initiate a connection (client) Wait for an incoming connection (server) Send or receive data Terminate a connection Handle connection termination from the remote site Abort communications Handle error conditions or a connection abort Release local resources when communication finishes 11/28/2018

4 Design CHOICES for Networking API
Assume networking is in the OS Which system calls? Define a new set of networking calls Use existing I/O calls As in Unix and Win32 Which protocols? Specific Generic 11/28/2018

5 Unix system calls, review
11/28/2018 Comer, Fig 4.2

6 Network Client System Calls
socket_descriptor = socket ( family, type, protocol ); rc = connect ( sd, (& sockaddr_in) addr, addr_len ); rc = write ( sd, (& char) buf, buf_len ); rc = read ( sd, (& char) buf, buf_len ); rc = close ( sd ); rc = shutdown ( sd, direction ); unspecified types are int. 11/28/2018

7 Addressing IP Port (& hostent) gethostbyname ((& char) name );
rc = gethostname ((& char) name, namelen ); Port (& servent) getservbyname ((& char) name, (& char) name ); 11/28/2018

8 Minimal TCP Client in C /* BUGS: NO ERROR CHECKING; DESIGN FLAW: NO MODULARITY */ #include "minimal_tcp.h" /* usage: TCP_client domain_name port_num */ void main( int argc, char *argv[] ) { struct hostent *phe; struct protoent *ppe; struct sockaddr_in sin; char c; int j, socket_desc; char hi[] = "hello world\n"; phe = gethostbyname( argv[1] ); memcpy ( &sin.sin_addr, phe->h_addr, phe->h_length ); sin.sin_port = atoi(argv[2]); sin.sin_family = AF_INET; ppe = getprotobyname("tcp"); socket_desc = socket( PF_INET, SOCK_STREAM, ppe->p_proto ); (void) connect( socket_desc, &sin, sizeof(sin) ); (void) write( socket_desc, hi, strlen( hi ) ); for( j = 0; j < strlen( hi ); j++ ) { (void) read( socket_desc, &c, 1 ); putc ( c , stdout ); } (void) close( socket_desc ); 11/28/2018

9 Minimal TCP Client, include file
/* Comer procedure 7.7 */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <stdio.h> 11/28/2018

10 IBQ Assume packets arrive reliably
What are these programs’ minimum duration, in round trip delays? What are these programs’ maximum duration? 11/28/2018

11 Client design issues Parameterize, with respect to host and server
Connection-based or connectionless Applications should use TCP unless it Does not need reliability Require broadcast or multi-cast Cannot tolerate TCP’s overhead 11/28/2018

12 Reasons for New Networking System Calls in the API
Greater control over protocol Eg., send data with SYN message Performance Eg., pre-compute checksum for TCP messages 11/28/2018


Download ppt "Internet and Intranet Protocols and Applications"

Similar presentations


Ads by Google