Chapter 2 outline. 2.1 Principles of app layer protocols

Similar documents
Chapter 2 Application Layer

Communication in Distributed Systems: Sockets Programming. Operating Systems

Chapter 2 Application Layer

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

Introduction to Sockets 9/25/14

Computer Networks. 2.Application Layer. László Böszörményi Computer Networks Application Layer - 1

CPSC 441 UDP Socket Programming. Department of Computer Science University of Calgary

Part 2: Application Layer

Computer Networking Introduction

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

Chapter 2: Application Layer last updated 22/09/03

CSCD 330 Network Programming Spring 2018

Application Layer. Application Layer 1. By Mikkel Christiansen for NA mm7 Spring 2004

CPSC 441 Tutorial - 11 UDP Socket Programming Department of Computer Science University of Calgary

CSCD 330 Network Programming Spring 2018

CS 355. Computer Networking. Wei Lu, Ph.D., P.Eng.

Lecture 3. Java Socket Programming. TCP, UDP and URL

CSCD 330 Network Programming Winter 2019

Layer 4 - Transport Layer. What do we need a Transport Layer for? Transport Protocols in the TCP/IP Reference Model. The Transport Layer TCP and UDP

Layer 4 - Transport Layer

Computer Networks Unit II Transport layer (2012 pattern)

Chapter 2 Application Layer. Lecture 5 DNS. Computer Networking: A Top Down Approach. 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012

Process Communication COMPUTER NETWORKING Part 2

Lecture 05: Application Layer (Part 02) Domain Name System. Dr. Anis Koubaa

Chapter 2 Application Layer

Chapter 2 APPLICATIONS

Chapter 2 Application Layer

Chapter 2 Application Layer. 2: Application Layer 1

Client/Server Computing & Socket Programming

Chapter 2 Application Layer

Computer Networks 1 (Mạng Máy Tính 1) Lectured by: Dr. Phạm Trần Vũ

JAVA SOCKET PROGRAMMING

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

Chapter 2 Application Layer

Chapter 2 Application Layer

Chapter 2 Application Layer

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

Chapter 2 Application Layer

55:134/22C:178 Computer Communications Lecture Note Set 2 Summer 2004

Chapter 2 Application Layer

Chapter 2 Application Layer

Chapter 2 Application Layer

COMP 3331/9331: Computer Networks and Applications

TCP and UDP Socket Programming in JAVA TCP Socket Programming 1. Write code for Client and save in GreetingClient.java

Section 2: Application layer

A note on the use of these ppt slides:

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

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

COMP 211 Chapter 2 Application Layer

COMPUTER NETWORKS CHAP 2 : APPLICATION LAYER

Chapter 2 Application Layer

Chapter 2 APPLICATIONS

Data Communications & Networks. Session 2 Main Theme Application Layer. Dr. Jean-Claude Franchitti

Data Communications & Networks. Session 2 Main Theme Application Layer. Dr. Jean-Claude Franchitti

Lecture 6 Application Layer. Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it

Chapter 2: Application layer

Domain Name Service. DNS Overview. October 2009 Computer Networking 1

CSCI Computer Networks Spring 2017

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

Computer Networks. Application Layer

Domain Name System (DNS) 김현철 ( 화 ) 정보통신융합서울대학교컴퓨터공학부

Chapter 2: Application layer. Computer Networks. Application Layer. Chapter 2: Application Layer. Some network apps. Bu-Ali Sina University, Hamedan

CC451 Computer Networks

Πρωτόκολλα Διαδικτύου (ΨΣ-326 DS151)

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

Computer Networking Introduction

Application Layer. Goals: Service models. Conceptual aspects of network application protocols Client server paradigm

Chapter 2 Application Layer

SE322 Software Design and Architecture

Chapter 2 Application Layer

Application Layer. Goals:

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

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

Chapter 2 Application Layer. 2: Application Layer 1

Application Layer: , DNS

Lecture 7: Application Layer Domain Name System

Computer Communication Networks Socket Programming

Chapter 2 part B: outline

Unit 1 Java Networking

Lecture 7 Application Layer. Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it

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

CS 3516: Advanced Computer Networks

CSEN 404 Introduction to Networks. Mervat AbuElkheir Mohamed Abdelrazik. ** Slides are attributed to J. F. Kurose

Chapter 2a SOCKET PROGRAMMING

Telematics Chapter 8: Transport Layer

Application-layer Protocols

CSEN 503 Introduction to Communication Networks

Tommy Färnqvist, IDA, Linköping University

Tonight. Communication. Middleware Protocols. Remote Procedure Call (RPC) Several common communication mechanisms RPC RMI Sockets Next week: HTTP,

Internet Services & Protocols. Application Layer and its Services

Java Network Programming

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

Computer Networks and Applications. Application Layer ( , DNS, P2P, Socket Programming)

CS 43: Computer Networks. 10: Naming and DNS September 24, 2018

Telematics 1. Chapter 9 Internet Application Layer. Principles of network applications Important application protocols Socket programming

Application Layer Chapter 2

Operating Systems CS 571

Introduction to Computer Networking. Guy Leduc. Chapter 2 Application Layer. Chapter 2: outline

Foundations of Telematics

Chapter II: Application Layer

Transcription:

Chapter 2 outline 2.1 Principles of app layer protocols clients and servers app requirements 2.2 Web and HTTP 2.3 FTP 2.4 Electronic Mail SMTP, POP3, IMAP 2.5 DNS 2.6 Socket programming with TCP 2.7 Socket programming with UDP 2.8 Building a Web server 2.9 Content distribution Network Web caching Content distribution networks P2P file sharing 2: Application Layer 1

DNS: Domain Name System People: many identifiers: SSN, name, passport # Internet hosts, routers: IP address (32 bit) - used for addressing datagrams name, e.g., gaia.cs.umass.edu - used by humans Q: map between IP addresses and name? Domain Name System: distributed database implemented in hierarchy of many name servers application-layer protocol host, routers, name servers to communicate to resolve names (address/name translation) note: core Internet function, implemented as application-layer protocol complexity at network s edge 2: Application Layer 2

DNS name servers Why not centralize DNS? single point of failure traffic volume distant centralized database maintenance doesn t scale! no server has all nameto-ip address mappings local name servers: each ISP, company has local (default) name server host DNS query first goes to local name server authoritative name server: for a host: stores that host s IP address, name can perform name/address translation for that host s name 2: Application Layer 3

DNS: Root name servers contacted by local name server that can not resolve name root name server: contacts authoritative name server if name mapping not known gets mapping returns mapping to local name server a NSI Herndon, VA c PSInet Herndon, VA d U Maryland College Park, MD g DISA Vienna, VA h ARL Aberdeen, MD j NSI (TBD) Herndon, VA k RIPE London i NORDUnet Stockholm m WIDE Tokyo e NASA Mt View, CA f Internet Software C. Palo Alto, CA b USC-ISI Marina del Rey, CA l ICANN Marina del Rey, CA 13 root name servers worldwide 2: Application Layer 4

Simple DNS example root name server host surf.eurecom.fr wants IP address of gaia.cs.umass.edu 2 5 3 4 1. contacts its local DNS server, dns.eurecom.fr 2. dns.eurecom.fr contacts root name server, if necessary 3. root name server contacts authoritative name server, dns.umass.edu, if necessary local name server dns.eurecom.fr 1 6 requesting host surf.eurecom.fr authorititive name server dns.umass.edu gaia.cs.umass.edu 2: Application Layer 5

DNS example root name server Root name server: may not know authoritative name server may know intermediate name server: who to contact to find authoritative name server 2 local name server dns.eurecom.fr 1 8 requesting host surf.eurecom.fr 7 3 6 intermediate name server dns.umass.edu 4 5 authoritative name server dns.cs.umass.edu gaia.cs.umass.edu 2: Application Layer 6

DNS: iterated queries root name server recursive query: puts burden of name resolution on contacted name server heavy load? iterated query: contacted server replies with name of server to contact I don t know this name, but ask this server 2 local name server dns.eurecom.fr 1 8 requesting host surf.eurecom.fr 3 4 7 iterated query intermediate name server dns.umass.edu 5 6 authoritative name server dns.cs.umass.edu gaia.cs.umass.edu 2: Application Layer 7

DNS: caching and updating records once (any) name server learns mapping, it caches mapping cache entries timeout (disappear) after some time update/notify mechanisms under design by IETF RFC 2136 http://www.ietf.org/html.charters/dnsind-charter.html 2: Application Layer 8

DNS records DNS: distributed db storing resource records (RR) RR format: (name, value, type,ttl) Type=A name is hostname value is IP address Type=NS name is domain (e.g. foo.com) value is IP address of authoritative name server for this domain Type=CNAME name is alias name for some cannonical (the real) name www.ibm.com is really servereast.backup2.ibm.com value is cannonical name Type=MX value is name of mailserver associated with name 2: Application Layer 9

DNS protocol, messages DNS protocol : query and reply messages, both with same message format msg header identification: 16 bit # for query, reply to query uses same # flags: query or reply recursion desired recursion available reply is authoritative 2: Application Layer 10

DNS protocol, messages Name, type fields for a query RRs in reponse to query records for authoritative servers additional helpful info that may be used 2: Application Layer 11

Chapter 2 outline 2.1 Principles of app layer protocols clients and servers app requirements 2.2 Web and HTTP 2.3 FTP 2.4 Electronic Mail SMTP, POP3, IMAP 2.5 DNS 2.6 Socket programming with TCP 2.7 Socket programming with UDP 2.8 Building a Web server 2.9 Content distribution Network Web caching Content distribution networks P2P file sharing 2: Application Layer 12

Socket programming Goal: learn how to build client/server application that communicate using sockets Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm two types of transport service via socket API: unreliable datagram reliable, byte streamoriented socket a host-local, application-created, OS-controlled interface (a door ) into which application process can both send and receive messages to/from another application process 2: Application Layer 13

Socket-programming using TCP Socket: a door between application process and endend-transport protocol (UCP or TCP) TCP service: reliable transfer of bytes from one process to another controlled by application developer controlled by operating system process socket TCP with buffers, variables internet process socket TCP with buffers, variables controlled by application developer controlled by operating system host or server host or server 2: Application Layer 14

Socket programming with TCP Client must contact server server process must first be running server must have created socket (door) that welcomes client s contact Client contacts server by: creating client-local TCP socket specifying IP address, port number of server process When client creates socket: client TCP establishes connection to server TCP When contacted by client, server TCP creates new socket for server process to communicate with client allows server to talk with multiple clients source port numbers used to distinguish clients (more in Chap 3) application viewpoint TCP provides reliable, in-order transfer of bytes ( pipe ) between client and server 2: Application Layer 15

Stream jargon A stream is a sequence of characters that flow into or out of a process. An input stream is attached to some input source for the process, eg, keyboard or socket. An output stream is attached to an output source, eg, monitor or socket. 2: Application Layer 16

Socket programming with TCP Example client-server app: 1) client reads line from standard input (infromuser stream), sends to server via socket (outtoserver stream) 2) server reads line from socket 3) server converts line to uppercase, sends back to client 4) client reads, prints modified line from socket (infromserver stream) Client Process process input stream output stream keyboard infromuser outtoserver monitor infromserver client TCP clientsocket socket input stream TCP socket to network from network 2: Application Layer 17

Client/server socket interaction: TCP Server (running on hostid) create socket, port=x, for incoming request: welcomesocket = ServerSocket() wait for incoming connection request connectionsocket = welcomesocket.accept() read request from connectionsocket write reply to connectionsocket close connectionsocket TCP connection setup Client create socket, connect to hostid, port=x clientsocket = Socket() send request using clientsocket read reply from clientsocket close clientsocket 2: Application Layer 18

Example: Java client (TCP) import java.io.*; import java.net.*; class TCPClient { Create input stream Create client socket, connect to server Create output stream attached to socket public static void main(string argv[]) throws Exception { String sentence; String modifiedsentence; BufferedReader infromuser = new BufferedReader(new InputStreamReader(System.in)); Socket clientsocket = new Socket("hostname", 6789); DataOutputStream outtoserver = new DataOutputStream(clientSocket.getOutputStream()); 2: Application Layer 19

Example: Java client (TCP), cont. Create input stream attached to socket Send line to server Read line from server BufferedReader infromserver = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); sentence = infromuser.readline(); outtoserver.writebytes(sentence + '\n'); modifiedsentence = infromserver.readline(); System.out.println("FROM SERVER: " + modifiedsentence); clientsocket.close(); } } 2: Application Layer 20

Example: Java server (TCP) import java.io.*; import java.net.*; class TCPServer { Create welcoming socket at port 6789 Wait, on welcoming socket for contact by client Create input stream, attached to socket public static void main(string argv[]) throws Exception { String clientsentence; String capitalizedsentence; ServerSocket welcomesocket = new ServerSocket(6789); while(true) { Socket connectionsocket = welcomesocket.accept(); BufferedReader infromclient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); 2: Application Layer 21

Example: Java server (TCP), cont Create output stream, attached to socket Read in line from socket DataOutputStream outtoclient = new DataOutputStream(connectionSocket.getOutputStream()); clientsentence = infromclient.readline(); capitalizedsentence = clientsentence.touppercase() + '\n'; Write out line to socket } } } outtoclient.writebytes(capitalizedsentence); End of while loop, loop back and wait for another client connection 2: Application Layer 22

Chapter 2 outline 2.1 Principles of app layer protocols clients and servers app requirements 2.2 Web and HTTP 2.3 FTP 2.4 Electronic Mail SMTP, POP3, IMAP 2.5 DNS 2.6 Socket programming with TCP 2.7 Socket programming with UDP 2.8 Building a Web server 2.9 Content distribution Network Web caching Content distribution networks P2P file sharing 2: Application Layer 23

Socket programming with UDP UDP: no connection between client and server no handshaking sender explicitly attaches IP address and port of destination to each packet server must extract IP address, port of sender from received packet application viewpoint UDP provides unreliable transfer of groups of bytes ( datagrams ) between client and server UDP: transmitted data may be received out of order, or lost 2: Application Layer 24

Client/server socket interaction: UDP Server (running on hostid) Client create socket, port=x, for incoming request: serversocket = DatagramSocket() read request from serversocket create socket, clientsocket = DatagramSocket() Create, address (hostid, port=x, send datagram request using clientsocket write reply to serversocket specifying client host address, port number read reply from clientsocket close clientsocket 2: Application Layer 25

Example: Java client (UDP) keyboard monitor Client Process process Output: sends packet (TCP sent byte stream ) input stream UDP packet infromuser sendpacket receivepacket client UDP clientsocket socket UDP packet UDP socket Input: receives packet (TCP received byte stream ) to network from network 2: Application Layer 26

Example: Java client (UDP) import java.io.*; import java.net.*; Create input stream Create client socket Translate hostname to IP address using DNS class UDPClient { public static void main(string args[]) throws Exception { BufferedReader infromuser = new BufferedReader(new InputStreamReader(System.in)); DatagramSocket clientsocket = new DatagramSocket(); InetAddress IPAddress = InetAddress.getByName("hostname"); byte[] senddata = new byte[1024]; byte[] receivedata = new byte[1024]; String sentence = infromuser.readline(); senddata = sentence.getbytes(); 2: Application Layer 27

Example: Java client (UDP), cont. Create datagram with data-to-send, length, IP addr, port Send datagram to server Read datagram from server } DatagramPacket sendpacket = new DatagramPacket(sendData, senddata.length, IPAddress, 9876); clientsocket.send(sendpacket); DatagramPacket receivepacket = new DatagramPacket(receiveData, receivedata.length); clientsocket.receive(receivepacket); String modifiedsentence = new String(receivePacket.getData()); System.out.println("FROM SERVER:" + modifiedsentence); clientsocket.close(); } 2: Application Layer 28

Example: Java server (UDP) import java.io.*; import java.net.*; Create datagram socket at port 9876 Create space for received datagram Receive datagram class UDPServer { public static void main(string args[]) throws Exception { DatagramSocket serversocket = new DatagramSocket(9876); byte[] receivedata = new byte[1024]; byte[] senddata = new byte[1024]; while(true) { DatagramPacket receivepacket = new DatagramPacket(receiveData, receivedata.length); serversocket.receive(receivepacket); 2: Application Layer 29

Example: Java server (UDP), cont Get IP addr port #, of sender String sentence = new String(receivePacket.getData()); InetAddress IPAddress = receivepacket.getaddress(); int port = receivepacket.getport(); Create datagram to send to client Write out datagram to socket } } String capitalizedsentence = sentence.touppercase(); senddata = capitalizedsentence.getbytes(); DatagramPacket sendpacket = new DatagramPacket(sendData, senddata.length, IPAddress, port); serversocket.send(sendpacket); } End of while loop, loop back and wait for another datagram 2: Application Layer 30

Building a simple Web server handles one HTTP request accepts the request parses header obtains requested file from server s file system creates HTTP response message: header lines + file sends response to client after creating server, you can request file using a browser (eg IE explorer) see text for details 2: Application Layer 31