CSCI 4550/8556 Computer Networks Comer, Chapter 3: Network Programming and Applications.

Slides:



Advertisements
Similar presentations
CSC383 Computer Networks Dr. Allen M. Johnson, Jr.
Advertisements

COP 4930 Computer Network Projects Summer C 2004 Prof. Roy B. Levow Lecture 1.
28.2 Functionality Application Software Provides Applications supply the high-level services that user access, and determine how users perceive the capabilities.
Data Communications and Networking (Third Edition)
Socket Programming.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
1 Java Networking – Part I CS , Spring 2008/9.
Layer 7- Application Layer
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
© Lethbridge/Laganière 2001 Chap. 3: Basing Development on Reusable Technology 1 Let’s get started. Let’s start by selecting an architecture from among.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
Sockets COS 518: Advanced Computer Systems Michael Freedman Fall
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Version 4.0 Application Layer Functionality and Protocols Network Fundamentals – Chapter.
I NTRODUCTION OF S OCKET P ROGRAMMING L.Aseel AlTurki King Saud University.
UNIX Sockets COS 461 Precept 1. Clients and Servers Client program – Running on end host – Requests service – E.g., Web browser Server program – Running.
1 Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Yukun Zhu (Slides are mainly from Monia Ghobadi, and Amin Tootoonchian,
CSIT 320 (Blum)1 Client-Server Interaction Based on Appendix 1 in Computer Networks and Internets, Comer.
Process-to-Process Delivery:
INTRODUCTION TO WEB DATABASE PROGRAMMING
1 Ch 3. Network Programming. 2 Network Programming (1)  Network allows arbitrary applications to communicate E.g., client-server computing such as WEB.
Agenda  Terminal Handling in Unix File Descriptors Opening/Assigning & Closing Sockets Types of Sockets – Internal(Local) vs. Network(Internet) Programming.
Computer Networks  Network - A system of computers interconnected in order to share information.  Data transmission - consists of sending and receiving.
TCP/IP protocols Communication over Internet is mostly TCP/IP (Transmission Control Protocol over Internet Protocol) TCP/IP "stack" is software which allows.
Chapter 17 Networking Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.
Computer Networking From LANs to WANs: Hardware, Software, and Security Chapter 12 Electronic Mail.
思科网络技术学院理事会. 1 Application Layer Functionality and Protocols Network Fundamentals – Chapter 3.
NET0183 Networks and Communications Lecture 31 The Socket API 8/25/20091 NET0183 Networks and Communications by Dr Andy Brooks Lecture powerpoints from.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Characteristics of Communication Systems
University of the Western Cape Chapter 15 – Application Layer The application layer is responsible for the following: Identifying and establishing the.
How Web Servers and the Internet Work by by: Marshall Brainby: Marshall Brain
1 Computer Networks DA Chapter 1-3 Introduction.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public ITE PC v4.0 Chapter 1 1 Application Layer Functionality and Protocols Network Fundamentals.
HOW WEB SERVER WORKS? By- PUSHPENDU MONDAL RAJAT CHAUHAN RAHUL YADAV RANJIT MEENA RAHUL TYAGI.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
Introduction to Network Programming Asst. Prof. Chaiporn Jaikaeo, Ph.D. Computer Engineering Department.
1 CSC111H Client-Server: An Introduction Dennis Burford
Internet Applications and Network Programming Dr. Abraham Professor UTPA.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
1. I NTRODUCTION TO N ETWORKS Network programming is surprisingly easy in Java ◦ Most of the classes relevant to network programming are in the java.net.
1 Welcome to CSC 301 Web Programming Charles Frank.
Application Layer Khondaker Abdullah-Al-Mamun Lecturer, CSE Instructor, CNAP AUST.
The Socket Interface Chapter 21. Application Program Interface (API) Interface used between application programs and TCP/IP protocols Interface used between.
ECEN “Internet Protocols and Modeling”, Spring 2012 Course Materials: Papers, Reference Texts: Bertsekas/Gallager, Stuber, Stallings, etc Class.
CS 158A1 1.4 Implementing Network Software Phenomenal success of the Internet: – Computer # connected doubled every year since 1981, now approaching 200.
1 Web Servers (Chapter 21 – Pages( ) Outline 21.1 Introduction 21.2 HTTP Request Types 21.3 System Architecture.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Computer Networks & PROTOCOLS (CSI 4118) FALL 2005 Professor Robert L. Probert.
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.
The Client-Server Model And the Socket API. Client-Server (1) The datagram service does not require cooperation between the peer applications but such.
Socket Programming.
Internet Applications (Cont’d) Basic Internet Applications – World Wide Web (WWW) Browser Architecture Static Documents Dynamic Documents Active Documents.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
1 Computer Networks and Internets. 2 Internet Growth.
© 2009 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets, 5e By Douglas E. Comer Lecture PowerPoints.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
1 Network Communications A Brief Introduction. 2 Network Communications.
1 K. Salah Application Layer Module K. Salah Network layer duties.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Sockets and Beginning Network Programming
Chapter 3 Internet Applications and Network Programming
MCA – 405 Elective –I (A) Java Programming & Technology
Client/Server Example
Process-to-Process Delivery:
CSI 4118 – UNIVERSITY OF OTTAWA
Internet Applications & Programming
Computer Networks DA2402.
Presentation transcript:

CSCI 4550/8556 Computer Networks Comer, Chapter 3: Network Programming and Applications

Introduction Use of a network requires programs (and systems) that are “network-aware.” Some applications are usually provided with machines (e.g. web clients, clients, file sharing). New custom applications must use the interface (API) to the network facilities provided by the system. We will look at a simple API and three sample applications (both the client and the server).

Network Communication Networks are the mechanisms that transmit data from one point to another. Logically, networks are (or should be) passive, and do not understand, act on, or modify the data being moved. There are two ends of a network communication, each associated with an application program that understands the generation and interpretation of the data being moved across the network.

Client-Server Computing The two applications that communicate using a network must locate each other. Typically, one application (the server) starts and then waits for the other application (the client) to contact it. This arrangement is usually called the client-server paradigm, or just client-server computing. The client must, of course, be able to locate the server for this arrangement to work.

Addressing Internet Applications Each network server application has a two-part address of the form (computer,application). The computer part of the address identifies the particular computer on which the application is running. This can be provided in symbolic (e.g. apollo.unomaha.edu) or numeric (e.g ) form. The application part of the address identifies the particular application. It, too, can be provided symbolically or numerically. When transmitted on a network, the (computer,application) address is always sent in binary.

Communication Paradigm Most Internet applications follow this basic sequence of operations for communication: The server starts first, and waits for contact from a client. The client contacts the server by specifying its location and requesting communication. The client and the server exchange messages. After they finish, the client and server each send an end- of-file to terminate communication. Functions are provided in the class library on apollo to perform each of these tasks.

An Example Application Program Interface The term “application program interface,” or API, is used to describe the set of operations available (in a particular programming domain) to a programmer. The simplified API presented in the textbook hides much of the complexity in network programming, but also doesn’t provide the richness of the usual networking API. We will see more details in later chapters.

Example API Overview OperationMeaning await_contactused by server to wait for a contact make_contactused by client to contact a server cname_to_comptranslate a computer name to an equivalent internal binary value appname_to_appnumtranslate a program name to an equivalent internal binary value sendused by client or server to send data recvused by client or server to receive data send_eofused by client or server after all data has been sent.

An Intuitive Look at the API The application actions usually follow this pattern: The server calls await_contact to wait for contact from a client. The client calls make_contact to establish the connection. [The server is said to be blocked until the contact is made.] Once contact is made, the applications use send and recv to exchange data. [The protocol dictates when each application sends or receives.] Once the data exchange is complete, the client or the server terminates the connection by calling send_eof. The other application detects the termination of the communication when recv returns 0.

A Trivial Example

API Definition – Data Types There are three data types (in addition to the usual integer, character, and real data types) used in the API: appnum : a binary value used to identify an application [this is really a port number]. computer : a binary value used to identify a computer [this is really an Internet Protocol address, or IP address.] connection : a value used to identify one endpoint of a connection between a client and a server [normally this identifies a socket data structure].

API Definition – await_contact A server calls await_contact to wait for a contact from a client. The function expects one argument of type appnum, and returns a connection which is then used in send, recv, and send_eof functions. connection await_contact (appnum a)

API Definition – make_contact A client calls make_contact to establish contact with a server. The arguments identify the computer on which the server is running, and the application number to be contacted. The function returns a connection used for send, recv, and send_eof by the client. connection make_contact (computer c, appnum a)

API Definition – appname_to_appnum This function is used to translate from a predefined human-readable name [character string] to a binary application number. Standard application names are defined in the /etc/services file on a UNIX system. It takes a string argument and returns the binary application number. appnum appname_to_appnum (char *name)

API Definition – cname_to_comp This function translates a symbolic computer name ( cname ) to the equivalent binary form (which is returned) of type computer. computer cname_to_comp (char *cname)

API Definition – send Send arranges to transmit data (a sequence of n bytes in a char array buf ) over an established connection c, returning the number of bytes actually transmitted. The last argument is always 0 in this simplified API. int send (connection c, char *buf, int n, 0)

API Definition – recv Recv receives at most n bytes of data from a connection c, placing it in a char array buf, and returning the number of bytes received and stored. Recv will return 0 only when the end of file is reached, and a negative value when an error occurred (e.g. recv without a valid connection). int recv (connection c, char *buf, int n)

API Definition – recvln Recvln reads one line of data (terminated by an end of line character) from a connection c into a char array buf ; no more than n -1 bytes will be read (allowing one byte for string termination). Recvln uses recv to read one byte at a time. int recvln (connection c, char *buf, int n)

API Definition – send_eof Send_eof terminates the connection c, returning a negative number if an error occurred. int send_eof (connection c)

The ECHO Application The ECHO application server merely resends each line it receives from a client. The server is started (from a command line) by typing the program name and a selected application number (usually in the range 1025 to 32767). The client application is started by typing its name, the name of the computer on which the server is running, and the same application number. Lines are then read by the client, echoed by the server, and displayed by the client, until an end of file (control-D on UNIX, or control-Z on Windows) is entered. Illustration…

An Important Observation If you examine the code for the echo client, you will find that it does not immediately read another line from the keyboard after reading data from the connection. This is because recv only returns as much data as it has actually read. The reason for this is that the underlying network may send a group of data bytes in several different packets. Thus the received data may arrive in pieces with sizes different from those used when the data was sent.

The CHAT Application The chat application is similar to the echo application. Here, however, the server displays the received data line and waits for a response from the user on that machine, which is then sent back to the client for display. Either the user at the server machine or the user at the client machine may terminate the chat session by entering an end of file. Illustration…

The WEB Application Our final example is a simple text-mode web server and browser. Only two web pages are provided by the server: “/” and “/time”. It is easy, however, to extend this application to deliver arbitrary pages stored as files on the server machine. The server and client both use the standard HTTP protocol, and the server delivers HTML documents with appropriate headers. Thus a commercial web browser could be used to contact our server. Illustration…