880 likes | 1.06k Views
Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri. Application Layer.
E N D
Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. AlirezaAbdollahpouri
ApplicationLayer لایه کاربرد مستقیما با کاربر (برنامه ها یا اشخاص) در ارتباط است. این لایه از طریق پروتکلهاي مختلفی که در اختیار دارد، خدمات مورد نیاز کاربران را فراهم میآورد. هر کدام از پروتکلهاي این لایه بسته به نوع و ماهیت آنها از یکی از پروتکلهاي TCPیا UDPدر لایه پایینتر استفاده میکنند. 2
Application-Layer Protocols مشهورترین پروتكلهاي اين لايه عبارتند از: FTP: پروتكلي براي انتقال فايل HTTP: پروتكلي براي دسترسي به صفحات وب DNS: پروتكلي براي ترجمه نامهاي نمادين به آدرسهاي IP Telnet: پروتكلي براي ورود به سيستم از راه دور SMTP و POP3: پروتكلهايي براي ارسال و دريافت E-mail 4
Application: communicating, distributed processes e.g., e-mail, Web, P2P file sharing, instant messaging running in end systems (hosts) exchange messages to implement application Application-layer protocols one “piece” of an app define messages exchanged by apps and actions taken use communication services provided by lower layer protocols (TCP, UDP) modem modem application transport network data link physical application transport network data link physical application transport network data link physical Applications and Application-Layer Protocols 5
Typical network app has two pieces: client and server modem modem applicatio transport network data link physical applicatin transport network data link physical Client-Server Paradigm Client: • initiates contact with server (“speaks first”) • typically requests service from server, • Web: client implemented in browser; e-mail: in mail reader request Server: • provides requested service to client • e.g., Web server sends requested Web page, mail server delivers e-mail reply 6
process process Processes Communicating Across Network • process sends/receives messages to/from its socket • socket analogous to door • sending process pushes message out door • sending process assumes transport infrastructure on other side of door which brings message to socket at receiving process host or server host or server controlled by app developer socket socket TCP with buffers, variables TCP with buffers, variables Internet controlled by OS 7
Data loss some apps (e.g., audio) can tolerate some loss other apps (e.g., file transfer, telnet) require 100% reliable data transfer Timing some apps (e.g., Internet telephony, interactive games) require low delay to be “effective” What transport service does an app need? Bandwidth • some apps (e.g., multimedia) require minimum amount of bandwidth to be “effective” • other apps (“elastic apps”) make use of whatever bandwidth they get 8
TCP service: connection-oriented: setup required between client and server processes reliable transport between sending and receiving process flow control: sender won’t overwhelm receiver congestion control: throttle sender when network overloaded no guarantee on: timing, minimum bandwidth UDP service: unreliable data transfer between sending and receiving process does not provide: connection setup, reliability, flow control, congestion control, timing, or bandwidth guarantee Internet Transport Protocols Services 10
Server IP Address & Port Number1 Server IP Address & Port Number2 Client IP Address & Port Number Sockets Client process Server process Welcoming socket Three-way handshake send write read read bytes Connection socket Client socket 14
Domain Name System (DNS) 15
در اولين سالهاي راه اندازي شبكه اينترنت، راه حل بسيار سادهاي براي ترجمه نامهاي نمادين به آدرسIP وجود داشت و آن تعريف تمام نامها و آدرسهايIP معادل، در يك فايل بنامhosts.txt بود. اين فايل داراي دو ستون بود كه در يك طرف آدرس نمادين و در طرف ديگر آدرسIP معادل آن نوشته شده بود. به دليل اينكه در آن تاريخ تعداد آدرسها زياد نبود، حجم چنين فايلي چندان بزرگ نميشد و هر ماشين ميزبان ميتوانست يك نسخه از اين فايل را در اختيار داشته باشد و سـاعت 24 هر شب اين فايل را از روي فايل مرجع تازهسازي و بهروز ميكرد تا هر گونه تغيير احتمالي و تعريف آدرسهاي جديد اعمال شود. بديهي است كه امروزه با حجم ميليوني آدرسها در اينترنت، داشتن يك فايل متمركز و قرار دادن تمام آدرسها و معادل آدرسIP در آن، امكان پذير نيست. راه حل: استفاده از یک پایگاه داده سلسله مراتبی توزیع شده
Hierarchical Distributed Name Space Root Server تعداد 13 عدد سرویس دهنده ریشه وجود دارد 17
Domains 20
DNS in the Internet The inverse domain is used to map an IP address to a name 21
Country domains پژوهشگاه دانشهای بنیادی در تهران مسئولیت کنترل دامنهirو زیر دامنه های آن را به عهده دارد http://www.nic.ir/ 23
Recursive resolution پرس و جوي تکراري قسمت اعظم تلاش براي تبدیل یک نام برعهده سرویس دهنده محلی است 24
DNS Protocol: Forward Lookup Query IP Address of www.icann.org is 142.12.01.23 Root Name Server Authorized name server for org. zone “ .” ir. org. com. edu. ac.ir. uok.ac.ir. Local Name Server www.icann.org. Client Forward Lookup Query: What is IP Address of www.icann.org 25
Iterative resolution پرس و جوي بازگشتی 26
Note: DNS can use the services of UDP or TCP, using the well-known port 53. 28
HTTP and WWW وب جهان گستر و پروتکل انتقال صفحات ابرمتن 29
World Wide Web Distributed services 30
Hypertext 31
Browser architecture Interpreter 32
Web and HTTP • Web pageconsists of objects • Object can be HTML file, JPEG image, Java applet, audio file,… • Web page consists of base HTML-file which includes several referenced objects • Each object is addressable by a URL • Example URL: eng.uok.ac.ir/abdollahpouri/index.html host name path name 37
HTTP: hypertext transfer protocol Web’s app layer protocol client/server model client: browser that requests, receives, “displays” Web objects server: Web server sends objects in response to requests HTTP 1.0: RFC 1945 HTTP 1.1: RFC 2068 HTTP Overview Server running Apache Web server HTTP request PC running Explorer HTTP response HTTP request Storage contents: base files, objects HTTP response Mac running Navigator 38
Note: HTTP uses the services of TCP on well-known port 80. 39
Uses TCP: client initiates TCP connection (creates socket) to server, port 80 server accepts TCP connection from client HTTP messages (application-layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server) TCP connection closed HTTP is “stateless” server maintains no information about past client requests HTTP Overview (cont.) 40
Nonpersistent HTTP At most one object is sent over a TCP connection. HTTP/1.0 uses nonpersistent HTTP Persistent HTTP Multiple objects can be sent over single TCP connection between client and server. HTTP/1.1 uses persistent connections in default mode HTTP Connections 41
Suppose user enters URL www.uok.ac.ir/computer/home.html 1.HTTP client initiates TCP connection to HTTP server (process) at www.uok.ac.ir on port 80 Non-persistent HTTP (contains text, references to 10 jpeg images) 2. HTTP server at host www.uok.ac.irwaiting for TCP connection at port 80. “accepts” connection, notifying client time 3.HTTP client sends HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants object Computer/home.html 4.HTTP server receives request message, forms response message containing requested object, and sends message into its socket 42
5. HTTP client receives response message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects Non-persistent HTTP (cont.) 4. … 6.HTTP server closes TCP connection. time 7.Steps 1-6 repeated for each of 10 jpeg objects 43
Response Time Modeling Response time: • one RTT to initiate TCP connection • one RTT for HTTP request and first few bytes of HTTP response to return • file transmission time total = 2RTT+transmit time initiate TCP connection RTT request file time to transmit file RTT file received time time 44
Nonpersistent HTTP issues: requires 2 RTTs per object OS must work and allocate host resources for each TCP connection but browsers often open parallel TCP connections to fetch referenced objects Persistent HTTP server leaves connection open after sending response subsequent HTTP messages between same client/server are sent over connection Persistent without pipelining: client issues new request only when previous response has been received one RTT for each referenced object Persistent with pipelining: default in HTTP/1.1 client sends requests as soon as it encounters a referenced object as little as one RTT for all the referenced objects Persistent HTTP 45
Request line خط درخواست Status line خط وضعیت هر سطر سرآیند به این فرمت است
انواع دیگر درخواست: OPTIONS, PATCH, COPY, MOVE, LINK, UNLINK, TRACE, 48
HTTP Request Message - example HTTP request message: ASCII (human-readable format) request line (GET, POST, HEAD commands) GET /somedir/page.html HTTP/1.1 Host: www.someschool.edu User-agent: Mozilla/4.0 Connection: close Accept-language:fr If-modified-since:Sat, 2 Nov 2002 13:45:12 (carriage return, line feed) header lines Carriage return, line feed indicates end of message 49
Example 1 This example retrieves a document. We use the GET method to retrieve an image with the path /usr/bin/image1. The request line shows the method (GET), the URL, and the HTTP version (1.1). The header has two lines that show that the client can accept images in GIF and JPEG format. The request does not have a body. The response message contains the status line and four lines of header. The header lines define the date, server, MIME version, and length of the document. The body of the document follows the header (see next slide). 50