计算机网络之应用层


Reference:

  • Computer Networking:A Top-Down Approach,7-th
  • PPT of NEU(lx)

在这里插入图片描述

1. Principles of Network applications

  • Application architectures
    在这里插入图片描述
  • Client-Server

    • Server:
      • Always-on host;
      • Permanent IP address;
      • Server farms for scaling (可扩展服务器池);
    • Cients:
      • Communicate with server;
      • May be intermittently connected;
      • May have dynamic IP addresses;
      • Do not communicate directly with each other;
  • Peer-to-peer (P2P):

    • No always-on server;
    • Arbitrary end systems directly communicate;
    • Peers are intermittently connected and change IP addresses;
    • Highly scalable but difficult to manage;
    • Example: BitTorrent\Skype
  • Hybrid of client-server and P2P

    • Napster

      • File transfer: P2P
      • File search centralized:
        • Peers register content at central server;
        • Peers query same central server to locate content;
    • Instant messaging (即时通信)

      • Chatting between two users is P2P;
      • Presence detection/location centralized:
        • User registers its IP address with central server when it comes online;
        • User contacts central server to find IP addresses of buddies;
  • Processes communicating

    1. Process: program running within a host;
    2. Within same host, two processes communicate using inter-process communication (defined by OS);
    3. Processes in different hosts communicate by exchanging messages;
    • Client and Server Processes

      • Client process: process that initiates communication;

      • Server process: process that waits to be contacted;

        Note: applications with P2P architectures have client processes & server processes;

    • The interface between the process and the computer network

      • Sockets
        • Process sends/receives messages to/from its socket;
        • Socket analogous to door:
          • Sending process shoves message out door;
          • Sending process relies on transport infrastructure on other side of door which brings message to socket at receiving process;
      • The application developer has control of everything on the application layer side of the socket but has little control of the transport-layer side of the socket;
      • The only control that the application developer has on the transport-layer side is
        • the choice of transport protocol;
        • perhaps the ability to fix a few transport-layer parameters;
    • Addressing processes:

      • For a process to receive messages, it must have an identifier;
      • A host has a unique32-bit IP address;
      • Identifier includes both the IP address and port numbers associated with the process on the host.
      • Example port numbers:
        • HTTP Server: 80;
        • Mail Server (using the SMTP protocol): 25;
  • Application-layer protocols

    • An application-layer protocol defines how an application’s processes, running on different end systems, pass messages to each other;
    • In particular, an application-layer protocol defines:
      • Types of messages exchanged, e.g., request & response messages;
      • Syntax of message types: what fields in messages & how fields are delineated;
      • Semantics of the fields, i.e., meaning of information in fields;
      • Rules for when and how processes send & respond to messages;
    • Public-domain protocols (开放性协议):
      • defined in RFCs;
      • allows for interoperability (允许互操作性);
      • e.g HTTP\SMTP
    • Proprietary protocols (专用协议):
      • e.g KaZaA
  • What transport service does an app need?

    • Data loss or not (Reliable Data Transfer)
      • 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”;
    • Bandwidth (Throughtput)
      • some apps (e.g., multimedia) require minimum amount of bandwidth to be “effective”;
      • other apps (“elastic apps”) make use of whatever bandwidth they get;
    • Security
  • Internet transport protocols service:

    • TCP

    • UDP

    • Both of them don’t provide timing and minimun bandwidth guarantees;

      ApplicationApplication-Layer ProtocolUnderlying Tranport Protocol
      Electronic mailSMTPTCP
      Remote Terminal AccessTelnetTCP
      WebHTTPTCP
      File TransferFTPTCP
      Streaming MultimediaProprietaryTCP or UDP
      Internet telephonyProprietaryUDP

2. The Web and HTTP

  • First some jargon (术语)

    • Web page consist of objects;
      • Web page consists of base HTML-file which includes several referenced objects;
      • Object can be HTML file, JPEG image, Java applet, audio file,…
      • Each object is addressable by a URL;
  • HTTP (hypertext transfer protocol)

    • Web’s application layer protocol;

    • Client/Server model

      • Client: Browser that requests, receives, “displays” Web objects;
      • Server: Web server sends objects in response to requests;
    • 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”: maintains no information about past client requests;

      Protocols that maintain “state” are complex!

      • past history (state) must be maintained;
      • if server/client crashes, their views of “state” may be inconsistent, must be reconciled
    • HTTP request message:

      • ASCII (Human-readable format)

      • Format

    • HTTP response message:

      • Format

        在这里插入图片描述

      • status codes phrases: indicate the result of the request

        • 200 OK: Request succeeded and the information is returned in the response.
        • 400 Bad Request: This is a generic error code indicating that the request could not be understood by the server.
        • 301 Moved Permanently: Requested object has been permanently moved; the new URL is specified in Location : header of the response message. The client software will automatically retrieve the new URL.
        • 404 Not Found: The requested document does not exist on this server.
        • 505 HTTP Version Not Supported: The requested HTTP protocol version is not supported by the server.
    • User-Server Interaction: cookies

      Many major Web sites use cookies

      • Four components:

        • cookie header line of HTTP response message;
        • cookie header line in HTTP request message
        • cookie file kept on user’s host, managed by user’s browser;
        • back-end database at Web site;
      • Example:

        Suppose Susan, who always accesses the Web using Internet Explorer from her home PC, contacts Amazon.com for the first time.

        Let us suppose that in the past she has already visited the eBay site. When the request comes into the Amazon Web server, the server creates a unique identification number and creates an entry in its backend database that is indexed by the identification number. The Amazon Web server then responds to Susan’s browser, including in the HTTP response a Set-cookie: header, which contains the identification number.

        For example, the header line might be——Set-cookie: 1678

        When Susan’s browser receives the HTTP response message, it sees the Set-cookie: header. The browser then appends a line to the special cookie file that it manages. This line includes the hostname of the server and the identification number in the Set-cookie: header. Note that the cookie file already has an entry for eBay, since Susan has visited that site in the past.

        As Susan continues to browse the Amazon site, each time she requests a Web page, her browser consults her cookie file, extracts her identification number for this site, and puts a cookie header line that includes the identification num-ber in the HTTP request.Specifically, each of her HTTP requests to the Amazon server includes the header line——Cookie: 1678.

        In this manner, the Amazon server is able to track Susan’s activity at the Amazon site. Although the Amazon Web site does not necessarily know Susan’s name, it knows exactly which pages user 1678 visited, in which order, and at what times! Amazon uses cookies to provide its shopping cart service—Amazon can maintain a list of all of Susan’s intended purchases, so that she can pay for themcollectively at the end of the session.

        If Susan returns to Amazon’s site, say, one week later, her browser will continue to put the header line Cookie: 1678 in the request messages. Amazon also recommends products to Susan based on Web pages she has visited at Amazon in the past. If Susan also registers herself with Amazon—providing full name, email address, postal address, and credit card information—Amazon can then

        include this information in its database, thereby associating Susan’s name with her identification number (and all of the pages she has visited at the site in the past!). This is how Amazon and other e-commerce sites provide “one-click shopping”—when Susan chooses to purchase an item during a subsequent visit,

        she doesn’t need to re-enter her name, credit card number, or address.

    • Web Caching (Proxy server, 代理服务器)

      Goal: Satisfy client request without involving origin server;

      • A Web cache is a network entity that satisfies HTTP requests on the behalf of an origin Web server.
      • The Web cache has its own disk storage and keeps copies of recently requested objects in this storage.

      A user’s browser can be configured so that all of the user’s HTTP requests are first directed to the Web cache. Once a browser is configured, each browser request for an object is first directed to the Web cache.

      • Example:suppose a browser is requesting the object http://www.someschool.edu/campus.gif
        1. The browser establishes a TCP connection to the Web cache and sends an HTTP request for the object to the Web cache.
        2. The Web cache checks to see if it has a copy of the object stored locally. If it does, the Web cache returns the object within an HTTP response message to the client browser.
        3. If the Web cache does not have the object, the Web cache opens a TCP connection to the origin server, that is, to www.someschool.edu . The Web cache then sends an HTTP request for the object into the cache-to-server TCP connection. After receiving this request, the origin server sends the object within an HTTP response to the Web cache.
        4. When the Web cache receives the object, it stores a copy in its local storage and sends a copy, within an HTTP response message, to the client browser (over the existing TCP connection between the client browser and the Web cache).

3. FTP(文件传输协议)

  • FTP: The file transfer protocol

    • transfer file to/from remote host;
    • client/server model:
      • client: side that initiates transfer (either to/from remote);
      • server: remote host;
    • ftp server: port 21;
  • FTP: separate control, data connections

    • FTP client contacts FTP server at port 21, specifying TCP as transport protocol(以 21 为端口号,TCP为传输层协议);
    • Client obtains authorization (授权) over control connection (“out of band”, 带外连接);
    • Client browses remote directory by sending commands over control connection;
    • When server receives a command for a file transfer, the server opens a TCP data connection to client;
    • After transferring one file, server closes connection;

    FTP server maintains “state”: current directory, earlier authentication;

    Server opens a second TCP data connection to transfer another file;

  • FTP commands, responses

    • Sample commands: sent as ASCCII text over control channel
      • USER username;
      • PASS password;
      • LIST (return list of file in current directory);
      • RETR filename (retrieves (gets) file);
      • STOR filename (stores (puts) file onto remote host);
    • Sample return codes: staatus code and phrase
      • 331 Username OK, password required.
      • 125 data connection already open; transfer starting.
      • 425 Can’t open data connection.
      • 452 Error writing file.

4. Electronic Mail: SMTP、POP3、IMAP

  • SMTP,Simple mail transfer protocol
  • POP3
  • IMAP

5. DNS(域名服务器)

  • DNS: Domain Name System

    • People: Many identifiers
      • SSN, name, passport #;
    • Internet hosts, routers:
      • IP address (32 bit) - used for addressing datagrams;
      • “name”, e.g., ww.yahoo.com - used by humans;

    Q: Map between IP addresses and names?

    • Distributed database implemented in hierarchy of many name servers;

      Why not centralize DNS (only one DNS)?

      • Single point of failure:

        • If the DNS server crashes, so does the entire Internet!
      • Traffic volume (通信量):

        • A single DNS server would have to handle all DNS queries (for all the HTTP requests and e-mail messages generated from hundreds of millions of hosts).
      • Distant centralized database:

        • Significant delays.
      • maintenance:

        • The single DNS server would have to keep records for all Internet hosts. Not only would this centralized database be huge, but it would have to be updated frequently to account for every new host.
    • 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”;
  • DNS Services

    • Hostname to IP address translation;
    • Host aliasing (别名): Canonical () and alias (别名) names;
      • A host with a complicated hostname can have one or more alias names.
      • Alias hostnames, when present, are typically more mnemonic than canonical host-names.
      • DNS can be invoked by an application to obtain the canonical (权威的) hostname for a supplied alias hostname as well as the IP address of the host.
    • Mail server aliasing:
      • DNS can be invoked by a mail application to obtain the canonical hostname for a supplied alias hostname as well as the IP address of the host.
    • Load distribution:
      • Replicated Web servers (冗余的Web服务器): a set of IP addresses is associated with one canonical hostname.
  • A Distributed, Hierarchical Database:

    • Root DNS Servers

      • There are over 400 root name servers scattered all over the world;
      • These root name servers are managed by 13 different organizations;
      • Root name servers provide the IP addresses of the TLD servers;
    • Top-level domain (TLD) servers

      For each of the top-level domains — top-level domains such as com, org, net, edu, and gov, and all of the country top-level domains such as uk, fr, ca, and jp — there is TLD server (or server cluster).

      • The network infrastructure supporting a TLD can be large and complex

      • TLD servers provide the IP addresses for authoritative DNS servers.

    • Authoritative DNS servers

      Every organization with publicly accessible hosts (such as Web servers and mail ser-vers) on the Internet must provide publicly accessible DNS records that map the names of those hosts to IP addresses. An organization’s authoritative DNS server houses these DNS records.

      An organization can choose to implement its own authoritative DNS server to hold these records; alternatively, the organization can pay to have these records stored in an authoritative DNS server of some service provider.

      Most universities and large companies implement and maintain their own primary and secondary (backup) authoritative DNS server.

  • Interaction of the various DNS servers

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值