CSE 124 Networked Services Fall 2009
-
Upload
cassidy-drake -
Category
Documents
-
view
19 -
download
0
description
Transcript of CSE 124 Networked Services Fall 2009
CSE 124Networked Services
Fall 2009B. S. Manoj, Ph.D
http://cseweb.ucsd.edu/classes/fa09/cse124
10/6/2009 1CSE 124 Networked Services Fall 2009
Some of these slides are adapted from various sources/individuals including but not limited to the slides from the text books by Kurose and Ross and Tanenbaum, and Google.com. Use of these slides other than for pedagogical purpose for CSE 124, may require explicit permissions from the respective sources.
Reminders• Week1-Homework
– Due by the Thursday, 8th October
• Programming Project-1 – Due by the Thursday, 23rd October
• Programming Project-2– Start thinking now– What services you might want – Not existing or not popularly existing today– Novel variations of existing protocols, architectures,
and services10/6/2009 2CSE 124 Networked Services Fall 2009
Application Layer Services: Domain Name System
• Provides many services including the name-to-address translation
• Why DNS– Names are easy for human reading, however, IP addresses are
required for Internet routers
• In original ARPANET,– hosts.txt file contained host-to-address translation– A central server maintained and managed the changes in
hosts.txt file– Hosts downloaded the hosts.txt file periodically (e.g., midnight )
• With the growth of ARPANET, the above method proved unscalable
10/6/2009 3CSE 124 Networked Services Fall 2009
Domain Name System• One of the most important application layer
protocol– Every other application layer protocol needs DNS
• Provides many services• Name to address resolution
– Host name to IP address translation• Name aliasing
– Host name aliasing• Service aliasing
– Mail services aliasing • Information services• Performance optimization
– Traffic load distribution, Improving response time, and Improving scalability10/6/2009 4CSE 124 Networked Services Fall 2009
Name to Address resolution• Translation from human-readable name to router-readable address• Example:
# nslookup > cseweb.ucsd.eduServer: 132.239.0.252Address: 132.239.0.252#53
Name: cseweb.ucsd.eduAddress: 132.239.51.6> > serverDefault server: 132.239.0.252Address: 132.239.0.252#53Default server: 128.54.16.2Address: 128.54.16.2#53
10/6/2009 5CSE 124 Networked Services Fall 2009
Domain Name
IP address
Primary Local DNS server
Secondary Local DNS server
Host Name aliasing • Translation from complex canonical names to simple mnemonic names• e.g., cluster0028.asia.microsoft.com • Relay8951.cluster392.utopia.com
# nslookup> docs.google.comServer: 132.239.0.252Address: 132.239.0.252#53
Non-authoritative answer:docs.google.com canonical name = writely.l.google.com.Name: writely.l.google.comAddress: 66.102.7.139>PING google.com (74.125.67.100) 56(84) bytes of data.64 bytes from gw-in-f100.google.com (74.125.67.100): icmp_seq=1 ttl=46 time=88.9 ms64 bytes from gw-in-f100.google.com (74.125.67.100): icmp_seq=2 ttl=46 time=88.8 ms
10/6/2009 6CSE 124 Networked Services Fall 2009
Mnemonic domain name
Canonical domain name
Service Aliasing• DNS can also be used for service aliasing
– e.g., mail services aliasing– IP address aliasing– SRV extensions
• Mail services are typically not provided by the web server
• Web server is more popular than mail servers (www.microsoft.com) – It is better served when associated with the same server name for both– [email protected] is better than
• The DNS uses a special record to provide the domain name of the mail server associated with a domain name
• Helps multiple services such as web and mail using same domain name10/6/2009 7CSE 124 Networked Services Fall 2009
Features of DNS
• A hierarchical naming system• e.g., cseweb.ucsd.edu
• A distributed, federated, hierarchically organized, server system
• An application layer protocol – Simple, Query-Reply-based, On UDP
10/6/2009 8CSE 124 Networked Services Fall 2009
Features of DNS
• A hierarchical naming system• e.g., cseweb.ucsd.edu
10/6/2009 9CSE 124 Networked Services Fall 2009
Hierarchical naming/server system13 root domain servers(10 in US, 2 in Europe, 1 in Asia)Top Level
Domains (TLD) (> 258)
TLD for country domains
Sub domain 10/6/2009 10CSE 124 Networked Services Fall 2009
Examples of Generic Top Level Domains (gTLDs)
• .aero Aviation • .asia Asia • .biz Business Organizations • .cat
Catalan language and culture • .com Commercial • .coop
Co-Operative Organizations • .edu Education • .gov US Government • .info Open TLD • .int International
Organizations • .jobs Jobs • .mil US Department of
Defense
• .mobi Mobile devices • .museum Museums • .name Personal • .net Networks • .org Organizations • .pro Credentialed
professionals and related entities
• .tel Publishing of contact data
• .travel Travelling
10/6/2009 11CSE 124 Networked Services Fall 2009
DNS Server Hierarchy• Root DNS (rDNS) servers
– 13 of them (10 in US, 2 in Europe, and 1 in Asia), each is a collection of servers– Do not maintain A records– Maintain records for locating Top level DNS servers
• Top level domain (TLD) DNS servers– Do not maintain A records– Responsible for the top level domains such as .com, .org, .edu etc – Also responsible for the country level domains such as .us, .uk, .no, .jp, .cn, etc. – More than 258 domains exist today, (likely to grow even further)
• Authoritative DNS server– Provided by the organization which hosts the web servers and hosts– Maintains A record for many hosts (in some cases there may be hierarchy of aDNS
servers)– Either hosted within the organization or through a DNS service provider
• Local DNS server– Plays the intermediary role between client and the hierarchy of DNS servers– Not part of the hierarchy of the DNS
10/6/2009 12CSE 124 Networked Services Fall 2009
How DNS works• A client calls resolver function
– A software library that implements the DNS client in an end-user machine
– Resolver sends a DNS query message to its local DNS (LDNS) server
– LDNS replies immediately if it has a cached information available
– If LDNS does not have the IP address, then it tries• First the root DNS servers• Then the general TLD servers• Then one or more of the authoritative DNS servers
10/6/2009 13CSE 124 Networked Services Fall 2009
DNS APIs• For unix-based systems, the client calls
– struct hostent *gethostbyname(const char *name); • returns a structure of type hostent for the given host name.• Name is a character array contains the host name
– struct hostent *gethostbyaddr(const char *addr, int len, int type);
• Used for reverse lookup (IP address to hostname)
– struct hostent { char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* host address type */ int h_length; /* length of address */ char **h_addr_list; /* list of addresses */ } 10/6/2009 14CSE 124 Networked Services Fall 2009
A client side code example……int sfd;struct sockaddr_un addr; char host_name[256]; struct hostent *host_addr;sprintf(host_name,”www.google.com”); /* copies the name to the host_name array*/
host_addr = gethostbyname(host_name);If(!host_addr){
fprintf(stderr,”Unknown host: %s\n”,host_name);exit(1);
} sfd = socket(AF_UNIX, SOCK_STREAM, 0); /* socket is opened*/
if (sfd == -1) { perror("socket"); exit(EXIT_FAILURE); }
memset(&addr, 0, sizeof(struct sockaddr_un)); /* Clear structure */ addr.sun_family = AF_UNIX; strncpy(addr.sun_path, MY_SOCK_PATH, sizeof(addr.sun_path) - 1);10/6/2009 15CSE 124 Networked Services Fall 2009
How DNS works
Enterprise/Campus/
Local Network
Local DNS (lDNS) server
The Internet
1
2
3
4
5
6
8
7
Root DNS(rDNS) servers
General Top Level Domain (gTLD) DNS servers
Authoritative DNS(aDNS) servers
10/6/2009 16CSE 124 Networked Services Fall 2009
docs.google.com
docs.google.com
NS: .com
docs.google.com
NS: dns.google.com
A: 66.102.7.113 and …..
66.102.7.113 and …..
DNS resource record types• A Resource Record (RR) is a basic data element in a DNS database• DNS server stores different types of RRs• Each RR corresponds to a set of information for a particular service
DNS provides• A record consists of multiple values that contains {Name, TTL, Class,
Type, Value}
10/6/2009 17CSE 124 Networked Services Fall 2009
DNS record types• Record: {Name, Value, Class, Type, TTL}
• Type A: Name=Hostname, Value= IP address, TTL=time to live– Type A record gives hostname-to-address resolution– E.g; {cseweb.ucsd.edu, 132.239.51.6, A, 19800}
• Type NS: Name=domain (e.g., google.com), Value = address of the authoritative DNS (aDNS) server – aDNS server can help with resolution of hostnames in the domain
• Type CNAME: Name=hostname, Value=canonical host name for hostname– Provides hostname aliasing service– e.g., {docs.google.com, writely.l.google.com, CNAME}
• Type MX: Name=hostname, Value=canonical name of the mail server associated with the hostname– e.g., {ucsd.edu, mail-jsoe.ucsd.edu, MX}10/6/2009 18CSE 124 Networked Services Fall 2009
An estimate of DNS queries (2003)
• Organizations managing rDNS servers report 100s of millions of queries per day
• Traces from F-root server– San Francisco and Palo Alto– 4 root server machines– 152 million queries/24 hours
10/6/2009 19CSE 124 Networked Services Fall 2009Source: D. Wessels and M. Fomenkov, “WoW, That’s a lot of packets,” ACM PAM 2003
CSE 124 Networked Services Fall 2009 20
DNS protocol, messagesDNS protocol : query and reply messages, both with same message format
msg headeridentification: 16 bit # for
query, reply to query uses same #
flags: query or reply recursion desired recursion available reply is authoritative
10/6/2009
CSE 124 Networked Services Fall 2009 22
DNS protocol, messages
Name, type fields for a query
RRs in responseto query
records forauthoritative servers
additional “helpful”info that may be used
10/6/2009
CSE 124 Networked Services Fall 2009 23
Inserting records into DNS• example: new startup “Network Utopia”• register name networkuptopia.com at DNS registrar (e.g.,
Network Solutions)– provide names, IP addresses of authoritative name server (primary
and secondary)– registrar inserts two RRs into com TLD server:
(networkutopia.com, dns1.networkutopia.com, NS)(dns1.networkutopia.com, 212.212.212.1, A)
• Similarly, create authoritative server Type A record for www.networkuptopia.com; Type MX record for networkutopia.com
10/6/2009
DNS Performance optimization services
• Not originally intended • However, today it is a very important service• Main performance optimization– Load Distribution– Provisioning Reliability– Content Distribution network services• Load distribution – DNS is used to provide load balancing among multiple servers that serve
the same domain– Many popular web servers use server replication– A set of IP addresses is associated with a canonical name– When a client queries, DNS server replies with the entire set of IP
addresses– Each client makes use of the first IP address in the set– The set of IP addresses is rotated in order when subsequent request– Therefore, the load is almost equally balanced among the set of servers
10/6/2009 24CSE 124 Networked Services Fall 2009
An example >docs.google.comServer: 132.239.0.252Address:
132.239.0.252#53
Non-authoritative answer:docs.google.com canonical
name = writely.l.google.com.
Address: 66.102.7.113Address: 66.102.7.138Address: 66.102.7.139Address: 66.102.7.100Address: 66.102.7.101Address: 66.102.7.102
> docs.google.comServer: 132.239.0.252Address:
132.239.0.252#53
Non-authoritative answer:docs.google.com canonical
name = writely.l.google.com.
Address: 66.102.7.102Address: 66.102.7.113Address: 66.102.7.138Address: 66.102.7.139Address: 66.102.7.100Address: 66.102.7.101
> docs.google.comServer: 132.239.0.252Address:
132.239.0.252#53
Non-authoritative answer:docs.google.com canonical
name = writely.l.google.com.
Address: 66.102.7.139Address: 66.102.7.100Address: 66.102.7.101Address: 66.102.7.102Address: 66.102.7.113Address: 66.102.7.138
1 2 3
10/6/2009 25CSE 124 Networked Services Fall 2009
Content Distribution Network services
• DNS is effectively used to provide content distribution services
• When a client queries for an address of a host, the DNS server provide the name of a CDN
• The CDN’s DNS replies with the address of the web cache nearest to the client’s location
• The client receives content from a nearby Web cache than the main web server– Quick response– Better load balancing– High server scalability10/6/2009 26CSE 124 Networked Services Fall 2009
CDN example
origin server (www.cnn.com)• distributes HTML• replaces: http://www.cnn.com/sports.ruth.gif
with
http://www.cdn.com/www.cnn.com/sports/ruth.gif
HTTP request for
www.cnn.com/sports/sports.html
DNS query for www.cdn.com
HTTP request for
www.cdn.com/www.cnn.com/sports/ruth.gif
1
2
3
origin server
CDN’s authoritative DNS server
CDN server near client
CDN company (cdn.com)• distributes gif files• uses its authoritative
DNS server to route redirect requests
client
10/6/2009 27CSE 124 Networked Services Fall 2009
Additional sources• Domain names are sold by domain name registrars
– Very competitive business models exist for domain names– Domain names are one of the most sought after real-estates in the
web today– Some simple names are worth several millions
• Business.com: $8 million• Wine.com: $2.9 million• Drugs.com: $830,000
• Important– When you register valuable names, register for longer duration
• Internet Corporation of Assigned Names and Numbers (ICANN)– Responsible for accrediting various domain name registrars
• http://www.internic.net/– For the list of accredited registrars
10/6/2009 28CSE 124 Networked Services Fall 2009
Attacks on DNS• Distributed Denial of Service
– Bandwidth flooding or resource consumption– Flooding Ping messages
• Distributed DNS query attack
• Man-in-the middle attack– Capture DNS queries and generate bogus DNS replys
• DNS poisoning– Erroneously populate the DNS caches by originating bogus replys
• Reflection attacks against hosts by – Generate spoofed DNS queries and thus create large number of replys– Targetting a host with DSN replys – Querys can be ANY? So that replys will be bigger packets
10/6/2009 29CSE 124 Networked Services Fall 2009