Applicationlayer

Application layer

http/smtp/dns/voip

Goals

  • relaiable data transfer
  • high throughput
  • timing guarantees

http

访问一个网址发生了什么

  1. The HTTP client process initiates a TCP connection to the server www.someSchool.edu on port number 80, which is the default port number for HTTP. Associated with the TCP connection, there will be a socket at the client and a socket at the server. 建立tcp

  2. The HTTP client sends an HTTP request message to the server via its socket. The request message includes the path name /someDepartment/home.index. (We will discuss HTTP messages in some detail below.) 发送请求

  3. The HTTP server process receives the request message via its socket, retrieves the object /someDepartment/home.index from its storage (RAM or disk), encapsulates the object in an HTTP response message, and sends the response message to the client via its socket. 返回请求

  4. The HTTP server process tells TCP to close the TCP connection. (But TCP doesn’t actually terminate the connection until it knows for sure that the client has received the response message intact.) 关闭tcp

  5. The HTTP client receives the response message. The TCP connection terminates. The message indicates that the encapsulated object is an HTML file. The client extracts the file from the response message, examines the HTML file, and finds references to the 10 JPEG objects. 关闭

  6. The first four steps are then repeated for each of the referenced JPEG objects.

message format

  • message format:
    • hypertext transfer protocol
    • web's appliation layer protocol
    • client/server model
    • 2 type: requests from client to server and responses
    • requests and response
    • startline:request line (Method SP Request-URI SP HTTP-Version CRLF) | status line
      • GET /index HTTP/1.1
      • HTTP/1.1 200 OK
    • zero or more headers: provide metadata about request or response:datas/times, application info,caching control,host must on requests
    • an empty line
    • message body
    • request methods:
    • GET: retrieve an object: conditional GET/ Partial GET
    • HEAD: retrieve metadata about object
    • OPTIONS: request info about the capabilities
    • POST: upload data to server
    • status code
    • 1XX informational
    • 2XX success
    • 3XX redirection
    • 4XX client error
    • 5XX server error
    • each request only retrieve one object

persistent http

  • persistent http
    • reuse existing transport connection,subsequent http message between same client/server sent over open connection
    • pipelining at application protocol level
    • without pipeline: one RTT for each referenced object RTT+transmission time(one object)
    • use pipeline: one RTT for all referenced objects
    • reduce transport-layer connection cost
    • reduce latency by avoid mulitple TCP slow-starts
    • avoid bandwidth wastage and reduce all congestion

DNS

  • mission: A directory service for the Internet
  • domain namespace: hierarchical structure
    • type of dns ns: root/top-level domain/ authoritative/ local

  • root server's job:
  • tld ns' job: ask cmu.edu ns
  • authoritative ns: provide authoritative hostname to ip
  • local ns: resolver: act as proxy
  • Load distribution across replicated servers

    • A name can map to multiple hosts
    • thus multiple addresses
    • DNS server returns all addresses
    • but rotates ordering
  • Simple query and reply mechanism, same message format, Resource Record

  • Runs over UDP

    • DNS did not need tcp retransmission when lost,try another ns
    • tcp take long set-up time, query and request time need to be short
  • data used as Resource Record (RR) in query and reply messages:

    • name(owner name), value, type, class (IN,internet), ttl
    • A = Address
    • ns = nameserver
    • cname = canonical name
    • mx = mail exchange
  • caching: once ns learns mapping, it caches mapping, timeout after ttl

tool

  • nslookup
  • dig
  • whois

Backlinks