1 COMP 431 Internet Services & Protocols Client/Server Computing & Socket Programming Jasleen Kaur February 2, 2016.

Slides:



Advertisements
Similar presentations
2: Application Layer1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r Sockets are explicitly created, used, released by applications.
Advertisements

Network Programming and Java Sockets
Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Application Layer – Lecture.
2: Application Layer 1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
1 Creating a network app Write programs that  run on different end systems and  communicate over a network.  e.g., Web: Web server software communicates.
2: Application Layer1 Data Communication and Networks Lecture 12 Java Sockets November 30, 2006.
2: Application Layer1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
1 Overview r Socket programming with TCP r Socket programming with UDP r Building a Web server.
1 Review of Previous Lecture r Electronic Mail r DNS r P2P file sharing.
Internet and Intranet Protocols and Applications Lecture 4: Application Layer 3: Socket Programming February 8, 2005 Arthur Goldberg Computer Science Department.
Networking Overview February 2, /2/2004 Assignments Due – Homework 0 Due – Reading and Warmup questions Work on Homework 1.
2: Application Layer1 Chapter 2 (continued) Application Layer – part 2 Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim.
Socket programming with UDP and TCP. Socket Programming with TCP Connection oriented – Handshaking procedure Reliable byte-stream.
1 School of Computing Science Simon Fraser University CMPT 771/471: Internet Architecture and Protocols Socket Programming Instructor: Dr. Mohamed Hefeeda.
TCP Socket Programming. r An abstract interface provided to the application programmer  File descriptor, allows apps to read/write to the network r Allows.
TCP Socket Programming CPSC 441 Department of Computer Science University of Calgary.
2: Application Layer1 Socket Programming. 2: Application Layer2 Socket-programming using TCP Socket: a door between application process and end- end-transport.
2: Application Layer1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
1 Network Layers Application Transport Network Data-Link Physical bits.
Protocols Rules for communicating between two entities (e.g., a client and a server) “A protocol definition specifies how distributed system elements interact.
Welcome to CIS 235 Computer Networks Fall, 2007 Prof Peterson.
2: Application Layer 1 Socket Programming Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley,
2: Application Layer 1 Socket Programming TCP and UDP.
JAVA Socket Programming Source: by Joonbok Lee, KAIST, 2003.
Socket programming in C. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
1 1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm r two types of.
2: Application Layer1 Chapter 2 Application Layer Computer Networking: A Top Down Approach Featuring the Internet, 2 nd edition. Jim Kurose, Keith Ross.
2: Application Layer1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
2: Application Layer1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
CS 3830 Day 11 Introduction : Application Layer 2 Server-client vs. P2P: example Client upload rate = u, F/u = 1 hour, u s = 10u, d min ≥ u s.
1 CS 455/555 Intro to Networks and Communications Client/Server Computing and Socket Programming (2.1, ) Michele Weigle Department of Computer Science.
18-1 Last time □ Fast retransmit ♦ 3 duplicate ACKs □ Flow control ♦ Receiver windows □ Connection management ♦ SYN/SYNACK/ACK, FIN/ACK, TCP states □ Congestion.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
Discussion 2 Sockets Programming Applets TCP UDP HTTP Delay Estimation
1 CS: 4244 Internet Programming Sockets Programming Dr. Eli Tilevich January 29, 2007.
Chapter 2 Application Layer Computer Networking: A Top Down Approach, 5 th edition. Jim Kurose, Keith Ross Addison-Wesley, April A note on the use.
Winter 2002Suprakash Datta1 Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
-1- Georgia State UniversitySensorweb Research Laboratory CSC4220/6220 Computer Networks Dr. WenZhan Song Associate Professor, Computer Science.
1 CSCD 330 Network Programming Winter 2015 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 6 Application.
Vassil Roussev 2 A socket is the basic remote communication abstraction provided by the OS to processes. controlled by operating system.
Socket Programming Lee, Sooyong
Network Programming and Sockets CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison.
Socket Programming Tutorial. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
2: Application Layer1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
Java Socket programming. Socket programming with TCP.
2: Application Layer1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
2: Application Layer1 Socket programming Socket API Explicitly created, used, released by apps Client/server paradigm Two types of transport service via.
1 CSCD 330 Network Programming Spring 2014 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 7 Application.
Chapter 2 Application Layer Application 2-1. Chapter 2: Application layer 2.1 Principles of network applications 2.2 Web and HTTP 2.3 FTP 2.4 Electronic.
1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm r two types of.
CPSC Application Layer 1 Trying out HTTP (client side) for yourself 1. Telnet to your favorite Web server: Opens TCP connection to port 80 (default.
1 CSCD 330 Network Programming Winter 2016 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 6 Application.
Socket programming in C. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 11 Omar Meqdadi Department of Computer Science and Software Engineering University.
1 All rights reserved to Chun-Chuan Yang Upon completion you will be able to: The OSI Model and the TCP/IP Protocol Suite Understand the architecture of.
Socket Programming Socket Programming Overview
DNS: Domain Name System
Socket programming with TCP
CSCD 330 Network Programming
DMET 602: Networks and Media Lab
Chapter 2: outline 2.1 principles of network applications
Socket programming - Java
Socket Programming Socket Programming Overview
Socket Programming.
Socket Programming 2: Application Layer.
DNS: Domain Name System
DNS: Domain Name System
DNS: Domain Name System
Presentation transcript:

1 COMP 431 Internet Services & Protocols Client/Server Computing & Socket Programming Jasleen Kaur February 2, 2016

2 Application-Layer Protocols Overview u Application-layer protocols define: »The types of messages exchanged »The syntax and semantics of messages »The rules for when and how messages are sent u Public protocols (defined in RFCs) »HTTP, FTP, SMTP, POP, IMAP, DNS u Proprietary protocols »RealAudio, RealVideo »IP telephony »… local ISP company network regional ISP application transport network link physical application

3 Application-Layer Protocols Outline u The architecture of distributed systems »Client/Server computing u The programming model used in constructing distributed systems »Socket programming u Example client/server systems and their application-level protocols »The World-Wide Web (HTTP) »Reliable file transfer (FTP) » (SMTP & POP) »Internet Domain Name System (DNS) local ISP company network regional ISP application transport network link physical application

4 Application-Layer Protocols Outline local ISP company network regional ISP u Protocol design issues: »In-band vs. out-of-band control signaling »Push vs. pull protocols »Persistent vs. non-persistent connections u Client/server service architectures »Contacted server responds vs. forwards request u Example client/server systems and their application-level protocols »The World-Wide Web (HTTP) »Reliable file transfer (FTP) » (SMTP & POP) »Internet Domain Name System (DNS) application transport network link physical application

5 local ISP company network regional ISP The Application Layer The client-server paradigm u Typical network application has two pieces: client and server u Client: »Initiates contact with server (“speaks first”) »Requests service from server »For Web, client is implemented in browser; for , in mail reader u Server: »Provides requested service to client »“Always” running »May also include a “client interface” reply request Client Server application transport network link physical application transport network link physical application

6 Client/Server Paradigm Socket programming u Sockets are the fundamental building block for client/server systems u Sockets are created and managed by applications »Strong analogies with files a host-local, application created/released, OS-controlled interface into which an application process can both send and receive messages to/from another (remote or local) application process socket u Two types of transport services are available via the socket API: »UDP sockets: unreliable, datagram-oriented communications »TCP sockets: reliable, stream-oriented communications

7 Client/Server Paradigm Socket-programming using TCP u A socket is an application created, OS-controlled interface into which an application can both send and receive messages to and from another application »A “door” between application processes and end-to-end transport protocols process TCP with buffers, variables socket controlled by application developer controlled by operating system Host (end system) process TCP with buffers, variables socket controlled by application developer controlled by operating system Host (end system) Internet

8 Socket-programming using TCP TCP socket programming model u A TCP socket provides a reliable, bi-directional, byte-stream communications channel from one process to another »A “pair of pipes” abstraction Process socket Host (end system) Host (end system) Internet Process socket bytes write read writeread

9 TCP with buffers, variables TCP with buffers, variables Socket-programming using TCP Network addressing for sockets process socket End System process socket Local port numbers (e.g., 6500) Internet domain name of host e.g., classroom.cs.unc.edu DNS u Sockets are addressed using an IP address and port number Internet addresses of hosts (e.g., )

10 Socket-programming using TCP Socket programming in Java u When the client creates a socket, the client’s TCP establishes connection to server’s TCP u When contacted by a client, server creates a new socket for server process to communicate with client »This allows the server to talk with multiple clients u Client creates a local TCP socket specifying the host and port number of server process »Java resolves host names to IP addresses using DNS u Client contacts server »Server process must be running »Server must have created socket that “welcomes” client’s contact Client socket Internet Server socket bytes write read writeread

11 Socket-programming using TCP Socket creation in the client-server model process host or server Internet process bytes TCP 3-way handshake Client Server 3-way handshake Client client socket “welcoming” socket connection socket bytes socket

12 Socket-programming using TCP Simple client-server example u The client reads a line of text from standard input and sends the text to the server via a socket u The server receives the line of text from the client and converts the line of characters to all uppercase u The server sends the converted line back to the client u The client receives the converted text and writes it to standard output Server welcoming socket connection socket Client client socket stdin stdout

13 Socket programming with TCP Example Client structure  Client reads from standard input ( inFromUser stream), writes to server via a socket ( outToServer stream) u Server reads line from a socket u Server converts line to uppercase and writes back to client  Client reads from socket, ( inFromServer stream) prints modified line to standard output client socket inFromServer outToServer inFromUser Client Process (1) (2) (3) Standard output (4) Standard input

14 Socket programming with TCP Example Client/server TCP socket interaction in Java create socket for incoming request (port=6789) welcomeSocket = new ServerSocket(...) wait for incoming connection request connectionSocket = welcomeSocket.accept() create socket, connect to swan.cs.unc.edu, port=6789 clientSocket = new Socket(...) close connectionSocket close clientSocket Server (running on swan.cs.unc.edu) Client (running on classroom.cs...) read reply from clientSocket write request using clientSocket read request from connectionSocket write reply to connectionSocket TCP connection setup program flow data flow …

15 Socket programming with TCP Example Java client import java.io.*; import java.net.*; class TCPClient { public static void main(String argv[]) throws Exception { String sentence; String modifiedSentence; BufferedReader inFromUser = new BufferedReader( new InputStreamReader(System.in)); System.out.println("Client ready for input"); while ((sentence = inFromUser.readLine()) != null) { Socket clientSocket = new Socket("swan.cs.unc.edu", 6789); // Create (buffered) input stream using standard input // While loop to read and handle multiple input lines // Create client socket with connection to server at port 6789

16 Socket programming with TCP Example Java client II DataOutputStream outToServer = new DataOutputStream( clientSocket.getOutputStream()); BufferedReader inFromServer = new BufferedReader( new InputStreamReader( clientSocket.getInputStream())); outToServer.writeBytes(sentence + '\n'); modifiedSentence = inFromServer.readLine(); System.out.println("FROM SERVER: " + modifiedSentence); clientSocket.close(); } } // end main } // end class // Create output stream attached to socket // Create (buffered) input stream attached to socket // Write line to server // Read line from server // end while, loop to accept more lines from user

17 Socket programming with TCP Example Java server import java.io.*; import java.net.*; class TCPServer { public static void main(String argv[]) throws Exception { String clientSentence; String capitalizedSentence; ServerSocket welcomeSocket = new ServerSocket(6789); System.out.println("Server Ready for Connection"); while(true) { Socket connectionSocket = welcomeSocket.accept(); System.out.println("Client Made Connection"); // Create “welcoming” socket using port 6789 // While loop to handle arbitrary sequence of clients making requests // Waits for a client to connect and creates new socket for connection

18 Socket programming with TCP Example Java server II BufferedReader inFromClient = new BufferedReader( new InputStreamReader( connectionSocket.getInputStream())); DataOutputStream outToClient = new DataOutputStream( connectionSocket.getOutputStream()); clientSentence = inFromClient.readLine(); System.out.println("Client sent: " + clientSentence); capitalizedSentence = clientSentence.toUpperCase() + '\n'; outToClient.writeBytes(capitalizedSentence); connectionSocket.close(); } } // end main } // end class // Create (buffered) input stream attached to connection socket // Create output stream attached to connection socket // Read input line from socket // Write output line to socket // end while; loop back to accept a new client connection

19 Socket-programming using UDP UDP socket programming model u A UDP socket provides an unreliable bi-directional communication channel from one process to another »A “datagram” abstraction Host (end system) Host (end system) Process socket Internet Process socket bytes write read writeread

20 Socket programming with UDP Example Client/server UDP socket interaction in Java create socket for incoming request (port=9876) serverSocket = new DatagramSocket() create socket, clientSocket = new DatagramSocket() read reply from clientSocket create address ( , port = 9876) and send datagram using clientSocket read request from serverSocket write reply to serverSocket specifying client IP address and port number program flow data flow Server (running on ) Client close clientSocket

21 Socket Programming Services provided by Internet transport protocols u TCP service: »connection-oriented: setup required between client, server »reliable transport between sending and receiving process »flow control: sender won’t overwhelm receiver »congestion control: throttle sender when network overloaded »does not provide: timing, minimum bandwidth guarantees u UDP service: »unreliable data transfer between sending and receiving process »does not provide: connection setup, reliability, flow control, congestion control, timing, or minimum bandwidth guarantees Why bother? Why is there a UDP?