Client/Server Computing & Socket Programming

Similar documents
Client/Server Computing & Socket Programming

Chapter II: Application Layer

Computer Communication Networks Socket Programming

We will cover in this order: 2.1, 2.7, 2.5, 2.4, 2.2

Application Programming Interfaces

Chapter 2: outline. 2.1 principles of network applications. 2.6 P2P applications 2.7 socket programming with UDP and TCP

Java Network Programming

Chapter 2: outline. 2.6 P2P applications 2.7 socket programming with UDP and TCP

Introduction to the Application Layer. Computer Networks Term B14

Chapter 2 Application Layer. Lecture 4: principles of network applications. Computer Networking: A Top Down Approach

Goal and A sample Network App

CMPE 150/L : Introduction to Computer Networks. Chen Qian Computer Engineering UCSC Baskin Engineering Lecture 4

Distributed Systems. Networking Slides courtesy Kurose & Ross

CMPE 150/L : Introduction to Computer Networks. Chen Qian Computer Engineering UCSC Baskin Engineering Lecture 6

CS 3516: Advanced Computer Networks

Chapter 2. Application Layer. Chapter 2: Application Layer. Application layer - Overview. Some network apps. Creating a network appication

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

Client/Server Computing

Different Layers Lecture 21

Review of Previous Lecture

CMSC 322 Computer Networks Applications and End-To- End

CSC 401 Data and Computer Communications Networks

CSC 4900 Computer Networks: End-to-End Design

Chapter 2 Application Layer

The Application Layer: Sockets Wrap-Up

Distributed Systems. Remote Procedure Calls

Protocol Layers, Security Sec: Application Layer: Sec 2.1 Prof Lina Battestilli Fall 2017

Chapter 2 Application Layer

Chapter 2: outline. 2.1 principles of network applications app architectures app requirements

Foundations of Telematics

Chapter 2: Application Layer. Chapter 2: application layer. outline. Some network apps. Client-server architecture. Application architectures

JAVA SOCKET PROGRAMMING

Communication in Distributed Systems: Sockets Programming. Operating Systems

CS 3516: Advanced Computer Networks

Chapter 2: Application Layer. Chapter 2 Application Layer. Some network apps. Application architectures. Chapter 2: Application layer

Chapter 1 Introduction

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

CC451 Computer Networks

Chapter 2 Application Layer

Network Programming with Python. Sébastien Tixeuil

EECS 3214: Computer Network Protocols and Applications

Chapter 2: outline. 2.6 P2P applications 2.7 socket programming with UDP and TCP

Chapter 2 outline. 2.1 Principles of app layer protocols

Chapter 2 Application Layer

Lecture 04: Application Layer (Part 01) Principles and the World Wide Web (HTTP) Dr. Anis Koubaa

Lecture 11. Transport Layer (cont d) Transport Layer 1

CSCD 330 Network Programming Spring 2018

Internet applications

CSC358 Week 2. Adapted from slides by J.F. Kurose and K. W. Ross. All material copyright J.F Kurose and K.W. Ross, All Rights Reserved

Quick Guide to Python Socket Programming 吳俊興 國立高雄大學資訊工程學系

Applications & Application-Layer Protocols: FTP and (SMTP & POP)

Application Layer. CMPS 4750/6750: Computer Networks

ECE 4450:427/527 - Computer Networks Spring 2017

Computer Networking Introduction

Chapter 2: Application layer

Application Layer: HTTP

Application-Layer Protocols Peer-to-Peer Systems, Media Streaming & Content Delivery Networks

Application Layer. Applications and application-layer protocols. Goals:

CSEN 503 Introduction to Communication Networks. Mervat AbuElkheir Hana Medhat Ayman Dayf. ** Slides are attributed to J. F.

Network Communication

Transport Layer (TCP/UDP)

Chapter 2: outline. 2.5 P2P applications 2.6 video streaming and content distribution networks 2.7 socket programming with UDP and TCP

Chapter 2 Application Layer

Esempi di programmi client/server in Python 2

Chapter 2: outline. 2.5 P2P applications 2.6 video streaming and content distribution networks 2.7 socket programming with UDP and TCP

CSC 4900 Computer Networks: P2P and Sockets

Networking. Layered Model. DoD Model. Application Layer. ISO/OSI Model

Chapter 2 Application Layer

Socket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements

FTP. Mail. File Transfer Protocol (FTP) FTP commands, responses. Electronic Mail. TDTS06: Computer Networks

Transport layer Internet layer

Application Layer Protocols

Internet Protocol Stack! Principles of Network Applications! Some Network Apps" (and Their Protocols)! Application-Layer Protocols! Our goals:!

Network Programming in Python. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Layered Model. DoD Model. ISO/OSI Model

Transport Layer. Chapter 3: Transport Layer

Web Caching and HTTPS

Chapter 2 Application Layer

Review for Internet Introduction

CS321: Computer Networks Introduction to Application Layer

Processes communicating. Network Communication. Sockets. Addressing processes 4/15/2013

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.

Chapter 2 Application Layer

Outline. Inter-Process Communication. IPC across machines: Problems. CSCI 4061 Introduction to Operating Systems

Chapter 2 Application Layer

DATA COMMUNICATOIN NETWORKING

Data Communication & Computer Networks MCQ S

Chapter 2 Application Layer

IEMS 5780 / IERG 4080 Building and Deploying Scalable Machine Learning Services

Chapter 2: Application layer

Chapter 2 Application Layer

Chapter 2 Application Layer

Electronic Mail. Three Components: SMTP SMTP. SMTP mail server. 1. User Agents. 2. Mail Servers. 3. SMTP protocol

EC441 Fall 2018 Introduction to Computer Networking Chapter 2: Application Layer

Chapter 2: outline. 2.6 P2P applications 2.7 socket programming with UDP and TCP

OSI Transport Layer. Network Fundamentals Chapter 4. Version Cisco Systems, Inc. All rights reserved. Cisco Public 1

Application Layer. Chapter 2. Computer Networking: A Top Down Approach. A note on the use of these Powerpoint slides:

Lecture 05: Application Layer (Part 02) FTP, Peer-to-Peer, . Dr. Anis Koubaa

CSCE 463/612 Networks and Distributed Processing Spring 2018

Transcription:

COMP 431 Internet Services & Protocols Client/Server Computing & Socket Programming Jasleen Kaur January 29, 2019 Application-Layer Protocols Overview Application-layer protocols define:» The types of messages exchanged» The syntax and semantics of messages» The rules for when and how messages are sent Public protocols (defined in RFCs)» HTTP, FTP, SMTP, POP, IMAP, DNS Proprietary protocols» RealAudio, RealVideo» Skype» Institutional 1 2

Network Working Group R. Fielding UC Irvine Request for Comments: 2616 J. Gettys Compaq/W3C Obsoletes: 2068 J. Mogul Compaq Category: Standards Track H. Frystyk W3C/MIT L. Masinter Xerox June 1999 P. Leach Microsoft T. Berners-Lee W3C/MIT Abstract Hypertext Transfer Protocol -- HTTP/1.1 The Hypertext Transfer Protocol (HTTP) is an -level protocol for distributed, collaborative, hypermedia information systems. It is a generic, stateless, protocol which can be used for many tasks beyond its use for hypertext, such as name servers and distributed object management systems, through extension of its request methods, error codes and headers [47]. A feature of HTTP is the typing and negotiation of data representation, allowing systems to be built independently of the data being transferred. HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as "HTTP/1.1", and is an update to RFC 2068 [33]. Application-Layer Protocols Overview Application-layer protocols define:» The types of messages exchanged» The syntax and semantics of messages» The rules for when and how messages are sent Public protocols (defined in RFCs)» HTTP, FTP, SMTP, POP, IMAP, DNS Proprietary protocols» RealAudio, RealVideo» Skype» Institutional 3 4

Application-Layer Protocols Overview Application developers write programs that:» Run on (different) end systems» Communicate over Note: developers don t need to write code for -core devices» Network devices do not run user s or layer protocols regional ISP Application-Layer Protocols Outline The architecture of distributed systems» Client/Server computing» Peer-to-Peer computing» Content delivery s The programming model used in constructing distributed systems» Socket programming Institutional Institutional 5 6

Application-Layer Protocols Outline Example client/server systems and their -level protocols:» The World-Wide Web (HTTP)» Reliable file transfer (FTP)» E-mail (SMTP & POP)» Internet Domain Name System (DNS) Example p2p s systems:» BitTorrent Other protocols and systems:» Streaming media DASH» Content delivery s (CDNs) Institutional The Application Layer The client-server paradigm Typical has two pieces: client and server Client:» Initiates contact with server ( speaks first )» Requests service from server» For Web, client is implemented in browser; for e-mail, in mail reader Server:» Provides requested service to client» Always running» May also include a client interface» A server may be a logical machine» Implemented by one of thousands of servers in a data center Client reply request Server Institutional 7 8

The Application Layer The peer-to-peer-paradigm No always-on server Arbitrary end systems directly communicate» Peers request service from other peers, provide service in return to other peers Self scalability new peers bring new service capacity, as well as new service demands Peers are intermittently connected and change IP addresses Complex management Institutional Application-Layer Protocols Outline Example client/server systems and their -level protocols» The World-Wide Web (HTTP)» Reliable file transfer (FTP)» E-mail (SMTP & POP)» Internet Domain Name System (DNS) Protocol design issues:» In-band vs. out-of-band control signaling» Push vs. pull protocols» Persistent vs. non-persistent connections Client/server service architectures» Contacted server responds vs. forwards request Institutional 9 10

Client/Server Paradigm Socket programming Sockets are the fundamental building block for client/server systems Sockets are created and managed by s» Strong analogies with files a host-local, created/released, OS-controlled interface into which an process can both send and receive messages to/from another (remote or local) process Two types of services are available via the API:» UDP s: unreliable, datagram-oriented communications» TCP s: reliable, stream-oriented communications Client/Server Paradigm A quick aside on processes A process is the OS term for a program running within a host On the same host, two processes communicate using inter-process communication» A service defined by the OS Processes on different hosts communicate by exchanging messages» By using some protocol! clients, servers client process: the executing program that initiates the communication server process: the executing program waits to be contacted 11 12

Client/Server Paradigm Socket-programming using TCP A is an created, OS-controlled interface into which an can both send and receive messages to and from another» A door between processes and end-to-end protocols Client/Server Paradigm Addressing processes To receive messages, a process must have an identifier» How does a client identify a server process We know that a host device has unique 32-bit IP address controlled by developer controlled by operating system process TCP with buffers, variables Host (end system) Internet process TCP with buffers, variables Host (end system) controlled by developer controlled by operating system But does the IP address of host suffice for identifying the destination process?» No! Many processes can be (and are!) running on the same host Institutional app1 app9 13 14

Client/Server Paradigm Addressing processes Processes are identified by a port number» Sort of like a identifier The server identifier includes both an IP address and port numbers associated with the server process on the host Example port numbers:» HTTP server: 80» mail server: 25 For a browser to send an HTTP message to www.cs.unc.edu the request is addressed to IP address 152.2.131.244 and port 80 Institutional app1 app9 15 Socket-programming using TCP TCP programming model A TCP provides a reliable, bi-directional, byte-stream communications channel from one process to another» A pair of pipes abstraction write read Process Host (end system) bytes Internet bytes Process read write Host (end system) 16

Socket-programming using TCP Network addressing for s Sockets are addressed using an IP address and port number Socket-programming using TCP Socket programming in Python process TCP with buffers, variables End System Internet domain name of host e.g., classroom.cs.unc.edu Local port numbers (e.g., 6500) Internet addresses of hosts (e.g., 152.2.131.245) DNS process TCP with buffers, variables End System write read Client bytes Client creates a local TCP specifying the host and port number of server process» Python resolves host names to IP addresses using DNS Client contacts server» Server process must be running» Server must have created that welcomes client s contact Internet bytes Server read write When the client creates a, the client s TCP establishes connection to server s TCP When contacted by a client, server creates a new for server process to communicate with client» This allows the server to talk with multiple clients 17 18

Socket-programming using TCP Socket creation in the client-server model Socket-programming using TCP Simple client-server example process client host or server Client Client Internet process welcoming connection Server stdin stdout Client client Server welcoming connection The client reads a line of text from standard input and sends the text to the server via a The server receives the line of text from the client and converts the line of characters to all uppercase The server sends the converted line back to the client The client receives the converted text and writes it to standard output 19 20

Socket programming with TCP Example Client/server TCP interaction in Python Socket Programming with TCP Example Python client Server (running on swan.cs.unc.edu) create for incoming request (port=6789) serversocket = (...) wait for incoming TCP connection request connection setup connectionsocket = serversocket.accept() read request from connectionsocket write reply to connectionsocket close connectionsocket Client (running on classroom.cs...) create, connect to swan.cs.unc.edu, port=6789 = (...) write request using read reply from close program flow data flow 21 include Python s library create TCP to server on port 12000 get user keyboard input change text into a sequence of bytes before sending receive data from server in a buffer from import * servername = snapper.cs.unc.edu serverport = 12000 = (AF_INET, SOCK_STREAM).connect((serverName, serverport)) sentence = raw_input( Input lowercase sentence: ).send(sentence.encode()) modifiedsentence =.recv(1024) print ( From Server:, modifiedsentence.decode()).close() 23

Socket Programming with TCP Example Python server create TCP welcoming server begins listening for incoming TCP requests server waits on accept() for incoming requests, a new is created on return to server on port 12000 read bytes from close connection to this client (but not the welcoming ) from import * serverport = 12000 serversocket = (AF_INET,SOCK_STREAM) serversocket.bind((,serverport)) serversocket.listen(1) print The server is ready to receive while True: connectionsocket, addr= serversocket.accept() sentence = connectionsocket.recv(1024). decode() capitalizedsentence = sentence.upper() connectionsocket.send( capitalizedsentence.encode()) connectionsocket.close() 26 Socket Programming with TCP Example Client/server TCP interaction in Python Server (running on snapper.cs.unc.edu) create for incoming request (port=6789) serversocket = (...) wait for incoming TCP connection request connection setup connectionsocket = serversocket.accept() read request from connectionsocket write reply to connectionsocket close connectionsocket Client (running on classroom.cs...) create, connect to snap.cs.unc.edu, port=6789 = (...) write request using read reply from close program flow data flow 27

Socket-programming using UDP UDP programming model Socket programming with UDP Example Client/server UDP interaction in Python A UDP provides an unreliable bi-directional communication channel from one process to another» A datagram abstraction Server (running on 152.2.131.245) create for incoming request (port=9876) serversocket = (AF_INET,SOCK_DGRAM) Client create, = (AF_INET,SOCK_DGRAM) write read Process Host (end system) bytes Internet bytes Process read write Host (end system) read request from serversocket write reply to serversocket specifying client IP address and port number create address (152.2.131.245, port = 9876) and send datagram using read reply from close program flow data flow 28 29

Socket Programming with UDP Example Python client Socket Programming with UDP Example Python server create UDP to server on port 12000 attach server name/port to message & send into read reply chars from server into string from import * servername = hostname serverport = 12000 = (AF_INET, SOCK_DGRAM) message = raw_input( Input lowercase sentence: ).sendto(message.encode(), (servername, serverport)) modifiedmessage, serveraddress =.recvfrom(2048) print modifiedmessage.decode().close() create UDP to server on port 12000 read from UDP into message, getting client s address (IP & port number) send upper string back to this client from import * serverport = 12000 serversocket = (AF_INET, SOCK_DGRAM) serversocket.bind(('', serverport)) print ( The server is ready to receive ) while True: message, clientaddress = serversocket.recvfrom(2048) modifiedmessage = message.decode().upper() serversocket.sendto( modifiedmessage.encode(), clientaddress) 31 33

Socket Programming Services provided by Internet protocols TCP service:» connection-oriented: setup required between client, server» reliable between sending and receiving process» flow control: sender won t overwhelm receiver» congestion control: throttle sender when overloaded» does not provide: timing, minimum bandwidth guarantees 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? 34