1. Trang chủ
  2. » Công Nghệ Thông Tin

Chapter 2 v7 01

107 1 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 107
Dung lượng 3,53 MB

Nội dung

©1996-2016, J.F Kurose and K.W Ross Computer Networks Lectured by: Nguyen Le Duy Lai (lai@hcmut.edu.vn) Computer Networking: A Top Down Approach 7th Edition, Global Edition Jim Kurose, Keith Ross Pearson April 2016 Introduction 1-1 ©1996-2016, J.F Kurose and K.W Ross Chapter Application Layer Computer Networking: A Top Down Approach 7th Edition, Global Edition Jim Kurose, Keith Ross Pearson April 2016 Application Layer 2-2 Chapter 2: outline 2.1 principles of network applications 2.2 Web and HTTP 2.3 electronic mail ©1996-2016, J.F Kurose and K.W Ross • SMTP, POP3, IMAP 2.4 DNS 2.5 P2P applications 2.6 video streaming and Content Distribution Networks (CDNs) 2.7 socket programming with UDP and TCP Application Layer 2-3 Chapter 2: application layer ©1996-2016, J.F Kurose and K.W Ross our goals: ▪ conceptual, implementation aspects of network application protocols • transport-layer service models • client-server paradigm • peer-to-peer (P2P) paradigm • content distribution networks (CDNs) ▪ learn about protocols by examining popular application-level protocols • • • • HTTP FTP SMTP / POP3 / IMAP DNS ▪ creating network applications ã socket API Application Layer 2-4 â1996-2016, J.F Kurose and K.W Ross Some network apps e-mail web text messaging remote login P2P file sharing multi-user network games ▪ streaming stored video (YouTube, Hulu, Netflix) ▪ ▪ ▪ ▪ ▪ ▪ ▪ voice over IP (e.g., Skype) ▪ real-time video conferencing ▪ social networking ▪ search ▪ … ▪ … Application Layer 2-5 Creating a network app write programs that: application transport network data link physical ©1996-2016, J.F Kurose and K.W Ross ▪ run on (different) end systems ▪ communicate over network ▪ e.g., web server software communicates with browser software no need to write software for network-core devices ▪ network-core devices not run user applications ▪ applications on end systems allows for rapid app development, propagation application transport network data link physical application transport network data link physical Application Layer 2-6 Application architectures ©1996-2016, J.F Kurose and K.W Ross possible structure of applications: ▪ client-server ▪ peer-to-peer (P2P) Application Layer 2-7 Client-server architecture server: ▪ always-on host ▪ permanent IP address ▪ data centers for scaling ©1996-2016, J.F Kurose and K.W Ross clients: client/server ▪ communicate with server ▪ may be intermittently connected ▪ may have dynamic IP addresses ▪ not communicate directly with each other Application Layer 2-8 ©1996-2016, J.F Kurose and K.W Ross P2P architecture ▪ no always-on server (peer) ▪ arbitrary end systems directly communicate ▪ peers request service from other peers, and 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 peer-peer Application Layer 2-9 Processes communicating ©1996-2016, J.F Kurose and K.W Ross process: program running within a host ▪ within same host, two processes communicate using inter-process communication (defined by OS) ▪ processes in different hosts communicate by exchanging messages clients, servers client process: process that initiates communication server process: process that waits to be contacted ▪ aside: applications with P2P architectures have client processes & server processes Application Layer 2-10 CDN content access: a closer look Bob (client) requests video http://netcinema.com/6Y7B23V ▪ video stored in CDN at http://KingCDN.com/NetC6y&B23V Bob gets URL for video http://netcinema.com/6Y7B23V from netcinema.com web page ©1996-2016, J.F Kurose and K.W Ross request video from KINGCDN server, streamed via HTTP resolve http://netcinema.com/6Y7B23V via Bob’s local DNS netcinema’s DNS returns URL http://KingCDN.com/NetC6y&B23V netcinema.com netcinema’s authoratative DNS KingCDN.com Bob’s local DNS server 4&5 Resolve http://KingCDN.com/NetC6y&B23 via KingCDN’s authoritative DNS, which returns IP address of KingCDN server with video KingCDN authoritative DNS Application Layer2-93 Case study: Netflix Amazon cloud ©1996-2016, J.F Kurose and K.W Ross Netflix registration, accounting servers Bob browses Netflix video upload copies of multiple versions of video to CDN servers Manifest file returned for requested video CDN server CDN server 1 Bob manages Netflix account CDN server DASH streaming Application Layer2-94 Chapter 2: outline 2.1 principles of network applications 2.2 Web and HTTP 2.3 electronic mail ©1996-2016, J.F Kurose and K.W Ross • SMTP, POP3, IMAP 2.4 DNS 2.5 P2P applications 2.6 video streaming and content distribution networks 2.7 socket programming with UDP and TCP Application Layer 2-95 Socket programming goal: learn how to build client/server applications that communicate using sockets socket: door between application process and end-end transport protocol ©1996-2016, J.F Kurose and K.W Ross application process socket application process transport transport network network link physical Internet link controlled by app developer controlled by OS physical Application Layer 2-96 Socket programming ©1996-2016, J.F Kurose and K.W Ross Two socket types for two transport services: • UDP: unreliable datagram • TCP: reliable, byte stream-oriented Application Example: client reads a line of characters (data) from its keyboard and sends data to server server receives the data and converts characters to uppercase server sends modified data to client client receives modified data and displays line on its screen Application Layer 2-97 Socket programming with UDP UDP: no “connection” between client & server ©1996-2016, J.F Kurose and K.W Ross ▪ no handshaking before sending data ▪ sender explicitly attaches IP destination address and port # to each packet ▪ receiver extracts sender IP address and port # from received packet UDP: transmitted data may be lost or received outof-order Application viewpoint: ▪ UDP provides unreliable transfer of groups of bytes (“datagrams”) between client and server Application Layer 2-98 Client/server socket interaction: UDP server (running on serverIP) ©1996-2016, J.F Kurose and K.W Ross create socket, port= x: serverSocket = socket(AF_INET,SOCK_DGRAM) read datagram from serverSocket write reply to serverSocket specifying client address, port number client create socket: clientSocket = socket(AF_INET,SOCK_DGRAM) Create datagram with serverIP and port=x; send datagram via clientSocket read datagram from clientSocket close clientSocket Application 2-99 Example app: UDP client Python UDPClient include Python’s socket library ©1996-2016, J.F Kurose and K.W Ross create UDP socket for server get user keyboard input Attach server name, port to message; send into socket read reply characters from socket into string print out received string and close socket from socket import * serverName = ‘hostname’ serverPort = 12000 clientSocket = socket(AF_INET, SOCK_DGRAM) message = raw_input(’Input lowercase sentence:’) clientSocket.sendto(message.encode(), (serverName, serverPort)) modifiedMessage, serverAddress = clientSocket.recvfrom(2048) print modifiedMessage.decode() clientSocket.close() Application Layer 2-100 Example app: UDP server Python UDPServer create UDP socket bind socket to local port number 12000 ©1996-2016, J.F Kurose and K.W Ross loop forever read from UDP socket into message, getting client’s address (client IP and port) send upper case string back to this client from socket import * serverPort = 12000 serverSocket = socket(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) Application Layer 2-101 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 ©1996-2016, J.F Kurose and K.W Ross client contacts server by: ▪ creating 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 that particular 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 byte-stream transfer (“pipe”) between client and server Application Layer 2-102 Client/server socket interaction: TCP server (running on hostid) client create socket, port=x, for incoming request: serverSocket = socket() ©1996-2016, J.F Kurose and K.W Ross wait for incoming TCP connection request connectionSocket = connection serverSocket.accept() read request from connectionSocket write reply to connectionSocket close connectionSocket setup create socket, connect to hostid, port=x clientSocket = socket() send request using clientSocket read reply from clientSocket close clientSocket Application Layer 2-103 Example app: TCP client Python TCPClient ©1996-2016, J.F Kurose and K.W Ross create TCP socket for server, remote port 12000 No need to attach server name, port from socket import * serverName = ’servername’ serverPort = 12000 clientSocket = socket(AF_INET, SOCK_STREAM) clientSocket.connect((serverName,serverPort)) sentence = raw_input(‘Input lowercase sentence:’) clientSocket.send(sentence.encode()) modifiedSentence = clientSocket.recv(1024) print (‘From Server:’, modifiedSentence.decode()) clientSocket.close() Application Layer 2-104 Example app: TCP server Python TCPServer create TCP welcoming socket server begins listening for incoming TCP requests ©1996-2016, J.F Kurose and K.W Ross loop forever server waits on accept() for incoming requests, new socket created on return read bytes from socket (but not address as in UDP) close connection to this client (but not welcoming socket) from socket import * serverPort = 12000 serverSocket = socket(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() Application Layer 2-105 Chapter 2: summary ©1996-2016, J.F Kurose and K.W Ross our study of network apps now complete! ▪ application architectures • client-server • P2P ▪ application service requirements: • reliability, bandwidth, delay ▪ Internet transport service model • connection-oriented, reliable: TCP • unreliable, datagrams: UDP ▪ specific protocols: • HTTP: Web • SMTP, POP, IMAP: Mail • DNS • P2P: BitTorrent ▪ video streaming, CDNs ▪ socket programming: TCP, UDP sockets Application Layer 2-106 Chapter 2: summary ©1996-2016, J.F Kurose and K.W Ross most importantly: learned about protocols! ▪ typical request/reply message exchange: • client requests info or service • server responds with data, status code ▪ message formats: • headers: fields giving info about data • data: info(payload) being communicated important themes: ▪ control vs messages • in-band, out-of-band ▪ centralized vs decentralized ▪ stateless vs stateful ▪ reliable vs unreliable message transfer ▪ “complexity at network edge” Application Layer 2-107

Ngày đăng: 11/04/2023, 09:47