Major Internet services & protocols Application layer File transfer Ping Info retrieval FTP Traceroute Remote login Web Search in DBs E-mail WAIS SMPT gopher HTTP TELNET News NNTP TCP ICMP IP Data link protocol Network media DNS UDP ARP, RARP, IGMP IEEE IEEE IEEE IEEE 802.3 802.4 802.5 802.11 etc. 1 DNS Domain Name System (a distributed DB used by TCP/IP applications to map between hostnames and IP addresses). DNS name space Unnamed root arpa com edu gov int mil net org tr . . . uk edu emu emu.edu.tr domain metu cmpe ander …….. ander.cmpe.emu.edu.tr host name domain name 2 An example: Using the local DNS server of EMU IP = 193.140.41.94 Local DNS server IP = 193.140.41.163 hilarion 4 IP=193.140.41.163 hilarion 5 3 resolv. conf. 6 LAN daytime: . . . 1 2 mesarya helium% telnet hilarion daytime Trying 193.140.41.163 Connected . . . . ..... helium% more /etc/resolv.conf nameserver 193.140.41.94 3 An example of resolution of a name in DNS Given: a fully qualified name ftp.dd.edu Required: IP address for this name. Your host Start appl. with ftp.dd.edu Application Resolver Now use IP=192.3.4.5 IP of ftp.dd.edu? ftp.dd.edu? See edu name root name server Unnamed root server at 138.4.7.2 edu name See dd.edu name server ftp.dd.edu? DB IP addresses of root name servers There are 13 root name servers in the Internet… edu server at 155.1.20.2 ftp.dd.edu? ftp.dd.edu is 192.3.4.5 Local name server (193.140.41.94 in EMU) dd name server dd ftp (192.3.4.5) 4 Protocols in a Web client-server system Appl. program Select link Web browser page GET Disconnect (from server) OK connect IP of host TCP Looking up host UDP IP Data link & Physical Network Web server DNS server 5 HTTP protocol It uses 2 types of messages: request (client server) response (server client) A request request Web client response Web server A response Request line Response line General header General header Request header Response header Entity header Entity header Entity body Entity body Request line = Method URL HTTPversion GET|PUT|HEAD|POST|DELETE|. . . Response line = HTTPversion Status code Reason Examples: A request: GET http://www.w3.org/project.html HTTP/1.0 Request line only... A response: HTTP/1.0 200 Document follows MIME-Version: 1.0 Server: CERN/3.0 Content-type: text/html Content-length: 8 000 Resp. line General header Response header Entity header Entity header 6 A very simple Web server #define WEBPORT 7777 /* non-standard port */ main (void) { struct sockaddr_in abc; … s = socket(…); abc.sin_family = AF_INET; abc.sin_addr.s_addr = htonl (INADDR_ANY); abc.sin_port = htons (WEBPORT); bind(s, (struct sockaddr *)&abc, …); listen(s,5); loop: ns = accept(s, …); recv(ns, buf, …); /* Analysis of received request in buf is done here */ … /* Prepare the standard HTTP header for the reply */ strcpy(buf, “HTTP/1.0 200 OK\r\n”); send(ns, buf, …); strcpy(buf, “SIMPLE SERVER 1.0 \r\n”); send(ns, buf, …); /* other lines of reply header are sent here */ … fd = open (“index.html”, …);/* open a file for the reply*/ while(read(fd, buf, …) > 0) send (ns, buf, …); close(fd); strcpy(buf, “\r\n”); /* the last(blank) line */ send(ns, buf,…); close(ns); goto loop; } 7 A web client-server system Host www.abc.com HTML text: . . .......... www.abc.com .......... .......... Link to www.abc.com Web client (browser) Page A ......... www.x.com ......... Web server Network(internet) Web server Host www.x.com Page B ......... . . . . . . ......... Link to www.x.com 8 Timing diagram for a web client-server system What you see: User: Select link www.abc.com Connect: looking up host www.abc.com IP addr . Connect: contacting host www.abc.com Web DNS Host Host client server(s) www.abc.com www.x.com UDP TCP:connect IP=. . OK. Connect: host www.abc.com contacted. Waiting for reply. GET pageA.html Response Page A.html ......... www.x.com ......... User: Select link www.abc.com Connect: looking up host www.abc.com IP addr . Connect: contacting host www.abc.com Disconnect UDP TCP:connect IP=. . Time 9 Uniform Resource Locator (URLs) of Web as pointers to resources in Internet Type General form Example http http://host:port/path http://www.abc.com/pagea.html ftp ftp://host /dir/file ftp://ftp.mit.edu/pub/readme telnet telnet://host:port telnet://kantara gopher gopher://host:port/path gopher://gopher.mit.edu/ 11/labraries news news: newsgroup news: comp.os.unix or news:newsarticle news:abcd@comp.os.unix mailto mailto:address mailto: murata@cs.ui.edu local file path name /usr/prog.c wais wais://host:port/dbase wais://abc.mit.edu/computers nntp nntp://host:port/ nntp://kantara/comp.os.unix/127 (network newsgroup/articlenumb news transfer protocol) 10