Information Network I: The Application Layer Doudou Fall Internet Engineering Laboratory Nara Institute of Science and Technique
Outline Domain Name System World Wide Web and HTTP Content Delivery Networks 2
OSI vs. TCP/IP Layers Application Presentation Application Session Transport Transport Network Internet Data Link Physical Network Access 3
Applications Application Programs that make use of the Internet: DNS, HTTP, SMTP, FTP, etc. Transport Network Data Link Physical 4
Domain Name System 5
Domain Name System (DNS) Addresses are hard for human beings to remember Never ending updates in case a machine changes its IP address The organization's web server will be known as www.naist.jp regardless of the IP address Mechanisms to map names into numerical address Host.txt; not scalable Domain Name System (DNS) to the rescue, 1983 6
Initial problem Every device connected to the Internet has a unique Internet Protocol address How to resolve human-friendly machine names into IP addresses 7
Initial Solution /etc/hosts Periodical downloads from Network Information Center (NIC) at the Stanford Research Institute (SRI) Not sustainable with millions of host in the Internet Does not scale 8
DNS: RFCs 1034, 1035, 2181 Hierarchical, domain-based naming Distributed database system Name onto IP address mapping procedure: A program calls the resolver by passing the name as a parameter The resolver sends a query containing the name to a local DNS server The later retrieves the name and return a response containing the IP address to the resolver The resolver forwards the response to the caller 9
DNS Name Space Hierarchical system borrowed from postal services ICANN (Internet Corporation for Assigned Names and Numbers) Generic Countries com org net gov edu jp th ro us sn ac co 10
Top Level Domains cctld: country-code domains e.g.,.jp,.sn, IDN cctld: internationalized country-code domains e.g., 中国, gtld: generic top-level domains E.g.,.org,.com,.edu, Internet Assigned Numbers Authority (IANA) 1,239 top-level domains 11
Shared Registration Domain name registry: database Keeps track of all domain names registered in a top-level domain Domain name registry operator: organization that runs the DB Network information Center (NIC) Keeps the DB of domain names Domain name registrar: Company used for domain name registration 12
Domain Resource Records Format: Domain_name Time_to_live Class Type Value Type Meaning Value SOA Start of Authority Parameters for this zone A IPv4 address of a host 32-bit integer AAAA IPv6 address of a host 128-Bit integer MX Mail exchange Priority, domain willing to accept email NS Name server Name of a server for this domain CNAME Canonical name Domain name PTR Pointer Alias for an IP address SPF Sender policy framework Text encoding of mail sending policy SRV Service Host that provides it TXT Text Descriptive ASCII text 13
Name Servers Problems with a centralized approach Single point of failure Hard to maintain Does not scale Problems with a distributed approach Partial mapping for each server Multiple servers may handle queries Hard to update 14
Types of DNS Servers Authoritative Name Servers Sure to be able to perform a name-address translation for a particular zone Root Name Servers Caching Name Servers Ask queries and keep them in cache for later use Non authoritative 15
Root Servers https://www.iana.org/domains/root/servers 16
DNS Queries Finding the IP address for a given hostname is called resolution and is done with the DNS protocol. Resolution computer request local name server to resolve Local name server asks the root name server Root returns the name server for a lower zone Continue down zones until name server can answer DNS protocol Runs on UDP port 53, retransmits lost messages Caches name server answers for better performance 17
DNS Queries 2 3 Root DNS Server 1 4 8 5 Requesting host Local DNS Server 6 TLD DNS Server 7 Authoritative DNS Server 18
DNS Protocol 12 bytes Identification No. of Questions No. of Authority RRs Flags No. of Answer RRs No. of Additional RRs Name, type fields for a query RRs in response to query Records for authoritative servers Additional helpful info that may be used Questions (variable number of answers) Answers (variable number of resource records) Authority (variable number of resource records) Additional Info (variable number of resource records) 19
Hands-on dig naist.jp ; <<>> DiG 9.8.3-P1 <<>> naist.jp ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7644 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0 ;; QUESTION SECTION: ;naist.jp. IN A ;; AUTHORITY SECTION: naist.jp. 3600 IN SOA ns.naist.jp. noc.itc.naist.jp. 2016051902 10800 3600 604800 86400 ;; Query time: 2 msec ;; SERVER: 163.221.8.11#53(163.221.8.11) ;; WHEN: Mon May 23 16:29:11 2016 ;; MSG SIZE rcvd: 73 20
Hands-on dig +norecurse @m.root-servers.net ANY naist.jp ;; QUESTION SECTION: ;naist.jp. IN ANY ;; AUTHORITY SECTION: jp. 172800 IN NS e.dns.jp. jp. 172800 IN NS g.dns.jp. jp. 172800 IN NS c.dns.jp. jp. 172800 IN NS d.dns.jp. jp. 172800 IN NS a.dns.jp. jp. 172800 IN NS f.dns.jp. jp. 172800 IN NS b.dns.jp. 21
Hands-on dig +norecurse @e.dns.jp ANY naist.jp ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60809 ;; flags: qr; QUERY: 1, ANSWER: 0, AUTHORITY: 3, ADDITIONAL: 3 ;; QUESTION SECTION: ;naist.jp. IN ANY ;; AUTHORITY SECTION: naist.jp. 86400 IN NS naistdns.oist.jp. naist.jp. 86400 IN NS ns.naist.jp. naist.jp. 86400 IN NS ns.tokyo.wide.ad.jp. 22
Hands-on dig +norecurse @ns.tokyo.wide.ad.jp ANY naist.jp ;; ANSWER SECTION: naist.jp. 3600 IN SOA 2016051902 10800 3600 604800 86400 ns.naist.jp. noc.itc.naist.jp. naist.jp. 3600 IN ip6:2001:200:16a::/48 ~all" SPF "v=spf1 ip4:163.221.0.0/16 naist.jp. 3600 IN ip6:2001:200:16a::/48 ~all" TXT "v=spf1 ip4:163.221.0.0/16 naist.jp. 3600 IN MX 20 mailgate22.naist.jp. naist.jp. 3600 IN MX 10 mailgate21.naist.jp. naist.jp. 3600 IN NS ns.tokyo.wide.ad.jp. naist.jp. 3600 IN NS ns.naist.jp. naist.jp. 3600 IN NS naistdns.oist.jp. 23
Web and HTTP 24
World Wide Web 1989, CERN: Conseil Européen pour la Recherche Nucléaire W3C: World Wide Web Consortium, 1994 Collection of content in the form of webpages Hypertext: one page points to another page 25
Communication in the Internet Copyright 2015 Pearson Education 26
Client/server architecture Client (browser) Determine the protocol Ask DNS for the IP address of server Make a TCP connection to server Send request for the page; server sends it back Fetch other URLs as needed to display the page Close idle TCP connections 27
Client/server architecture Server Accepts a TCP connection from client Get page request and map it to a resource Get the resource Send contents of the resource to the client Release idle TCP connections 28
Dynamic Pages Web Applications Pages generated by programs running at the server and the client E.g., PHP at server, JavaScript at client Pages vary each time Web applications; set of technologies that work together: AJAX HTML: presnet information as pages DOM: change parts of the page while they are viewed XML: let programs exchange data with the server JavaScript as a language to bind all this together 29
HTTP Basics HyperText Transfer Protocol (RFC 2616) Application layer protocol of the web Client-server model TCP-based protocol Client connects to port 80 on the server HTTP messages are exchanged Client closes the connection HTTP is stateless Server does not store state on previous requests Design simplification: easier failure recovery, load balancing 30
Evolution of HTML Item HTML 1.0 HTML 2.0 HTML 3.0 HTML 4.0 HTML 5.0 Hyperlinks Images Lists Active maps & images Forms Equations Toolbars Tables Accessibility features Object embedding Style sheets Scripting Video and audio Inline vector graphics XML representation Background threats Browser storage Drawing canvas 31
Uniform Resource Locator (URL) RFC 1738 Requests for objects are URLs http://domain_name:port/path/path/object protocol server Port # Path to object object http https ftp file mailto rtsp sip about hypertext With security File transfer protocol Local file Sending email Streaming media Multimedia calls Browser information 32
Types of connections Non-persistent HTTP (HTTP 1.0) At most one object is sent over a TCP connection Request/response Persistent HTTP (HTTP 1.1) Multiple objects can be sent over a single connection 33
Non-persistent HTTP: response time Round-trip time (RTT) Time for a small packet to travel from the client to the server and back to the client Response time One RTT to initiate the connection One RTT for request and start of response File transmission time Total time = #objects*(2*rtt + transit_time) 34
Persistent HTTP: response time Server leaves connection open after sending response Subsequent HTTP messages are sent over the same open connection One RTT for each referenced object once the connection is setup Response time One RTT to initiate the connection One RTT for request and start of response per object File transmission time per object Total time = RTT + #objects*(rtt + transit_time) 35
HTTP Request Methods Method GET HEAD POST PUT DELETE TRACE CONNECT OPTIONS Function Read a Web page Read a Web page s header Append to a Web page Store a Web page Remove the Web page Echo the incoming request Connect through a proxy Query options for a page Human-readable ASCII text 36
HTTP Response Codes 200 OK Request succeeded; request object is in the message 301 Moved Permanently Requested object moved; new location specified in a location: header in the list of headers 400 Bad Request The server could not understand the request 404 Not Found The requested content is not found on the server 505 HTTP Version Not Supported Unsupported version 37
Hands-on Run telnet www.naist.jp 80 Type in a basic GET request GET /index.html HTTP/1.1 Look at the response 38
Cookies in HTTP HTTP is stateless Cookies provide a mechanism for Web servers to store Four components Cookie header line in the HTTP response message Cookie header line in subsequent HTTP request messages Cookie file stored on user s host and managed by browser Back-end database at the web server host 39
How to cookie rakuten.co.jp: 1984 Client HTTP request HTTP response Set-cookie: 1984 server rakuten.co.jp Creates an ID 1984 For the request HTTP request Cookie: 1984 Cookie-specific action DB Future session rakuten.co.jp: 1984 HTTP request Cookie: 1984 Cookie-specific action 40
Maintaining state with cookies Cookies help servers store: Shopping cart info Login name, authorization credentials Preferences Session state History of web pages First-party cookies Third-party cookies 41
Web Caches (proxy servers) User sets browser: web access via cache Browser sends all HTTP requests to cache Advantages: Reduce response time if proxy is closer/faster Reduce traffic on the web server Reduce traffic on the organization s link 42
HTTP Headers Function Browser capabilities (client -> server) Caching related (mixed directions) Browser context (client -> server) Content delivery (server -> client) Example Headers User-Agent, Accept, Accept-Charset, Accept-Encoding Accept-Language If-Modified-Since, If-None-Match, Date, Last-Modified, Expires, Cache-Control, ETag Cookie, Referer, Authorization, Host Content-Encoding, Content-Length, Content-Type, Content- Language, Content-Range, Set-Cookie 43
HTTP Conditional GET Request an object but do not send it if the cache has an up-to-date version HTTP Request GET /index.html HTTP/1.1 Host: somesite.sn HTTP Response HTTP/1.1 200 OK Date: Wed, 25 May 2016 11:05:15 JST Server: Apache/2.4 (CentOS) Last-Modified: Mon, 23 May 2016 09:36:49 JST ETag: 4d1658-28eg-5e59c778g4e11 Accept-Ranges: bytes Content-Length: 6111 Vary: Accept-Encoding Content-Type: text/html 44
Content Delivery Networks Miscellaneous 45
Content Delivery Delivery of content (video, image, audio, etc.) to users is a major component of Internet traffic. Content and Internet traffic Server farms Content delivery networks 46
Server Farms Server Farms enable large-scale Web servers Front-end load-balances requests over servers Server access the same backend database Internet Load balancer Front end Backend DB servers 47
Content Delivery Networks (CDNs) (1/3) CDNs scale Web servers by having clients get content from a nearby CDN node (cache) CDN origin server Distribution of content Beijing Tokyo Dakar Page fetch Clients 48
Content Delivery Networks (CDNs) (2/3) Directing clients to nearby nodes with DNS: Client query returns local CDN node as response Local CDN node caches content for nearby clients and reduces load on the origin server Tokyo CDN node 1: distribute content CDN origin server Dakar CDN node 4: fetch page 2: query DNS CDN DNS server Tokyo client 3: Contact Tokyo contact Dakar Dakar client 49
Content Delivery Networks (CDNs) (3/3) Origin server rewrites pages to serve content via CDN Traditional web page CDN configured page <html> <head> <title> Viral Videos </title> </head> <body> <h1> List of the videos </h1> <p> Click below for free samples </p> <a href= dancingcat.mpg > Cool cats </a> <a href= roflbaby.mpg > Baby laughing out loud </a> <a href= shootingmonkey.mpg > Monkey with AK47 </a> </body> </html> <html> <head> <title> Viral Videos </title> </head> <body> <h1> List of the videos </h1> <p> Click below for free samples </p> <a href= http://www.cdn.com/viralvideos/dancingcat.mpg >...</a> <a href= http://www.cdn.com/viralvideos/roflbaby.mpg > </a> <a href= http://www.cdn.com/viralvideos/shootingmonkey.mpg ></a> </body> </html> 50
More Applications Electronic Mail: SMTP Streaming audio and video Peer-to-peer applications IoT applications Al-Fuqaha, Ala, et al. "Internet of things: A survey on enabling technologies, protocols, and applications." Communications Surveys & Tutorials, IEEE 17.4 (2015): 2347-2376. 51
The End 52