Presentation is loading. Please wait.

Presentation is loading. Please wait.

Network Applications: DNS, UDP Socket 1/24/2012. 2 Outline  Recap r DNS r Network application programming: UDP.

Similar presentations


Presentation on theme: "Network Applications: DNS, UDP Socket 1/24/2012. 2 Outline  Recap r DNS r Network application programming: UDP."— Presentation transcript:

1 Network Applications: DNS, UDP Socket 1/24/2012

2 2 Outline  Recap r DNS r Network application programming: UDP

3 3 Recap: The Big Picture of the Internet r Hosts and routers: m >850 mil. hosts (2011) m organized roughly hierarchical m backbone links 10~40Gbps r Software: m datagram switching with virtual circuit support at backbone m layered network architecture use end-to-end arguments to determine the services provided by each layer m the hourglass architecture of the Internet IP EthernetCable/DSLWireless TCP UDP Telnet Email FTPWWW SSL

4 4 Protocol Formats

5 5 Recap: Client-Server Paradigm application transport network data link physical application transport network data link physical request reply r The basic paradigm of network applications is the client-server (C-S) paradigm m a client/server is a process at a port number of a host r Key design questions of a C-S application: m protocol extensibility m scalability m robustness m security

6 6 Recap: Email App mail server user agent user agent user agent mail server user agent user agent mail server user agent SMTP POP3 or IMAP SMTP Some nice protocol extensibility design features separate protocols for different functions simple/basic (smtp) requests to implement basic control; fine- grain control through ASCII header and message body status code in response makes message easy to parse

7 Scalability/Robustness r High scalability and robustness fundamentally require multiple email servers to serve the same email address 7 client need a email server IP address mail server mail server mail server yale.edu 130.132.50.7 130.132.50.8130.132.50.9 mapping

8 8 Mapping Functions Design Alternatives r Map from an email address server name to IP address of email server mapping name (e.g., yale.edu) 1 IP mapping multiple IPs mapping multiple IPs name (e.g., yale.edu)

9 9 Mapping Functions Design Alternatives load balancer switch mapping name (e.g., yale.edu) 1 IP mapping name (e.g., yale.edu) 1 IP

10 10 DNS: Domain Name System r Function m map between (domain name, service) to value, e.g., (www.cs.yale.edu, Addr) -> 128.36.229.30 (cs.yale.edu, Email) -> netra.cs.yale.edu r Many benefits of introducing the mapping routers DNS Hostname, Service Address servers clients

11 11 Dummy Design r DNS itself can be considered as a client-server system as well r How about a dummy design: introducing one super Internet DNS server? THE DNS server of the Internet register resolve OK/used already IP address

12 12 DNS: Distributed Management of the Domain Name Space r A distributed database managed by authoritative name servers m divided into zones, where each zone is a sub-tree of the global tree m each zone has its own authoritative name servers m an authoritative name server of a zone may delegate a subset (i.e. a sub-tree) of its zone to another name server called a zone

13 13 Email Architecture + DNS mail server user agent user agent user agent mail server user agent user agent mail server user agent SMTP POP3 or IMAP SMTP DNS

14 14 Root Zone and Root Servers r The root zone is managed by the root name servers m 13 root name servers worldwide See http://root-servers.org/ for more detailshttp://root-servers.org/

15 15 Linking the Name Servers r Each name server knows the addresses of the root servers r Each name server knows the addresses of its immediate children (i.e., those it delegates) Top level domain (TLD) Q: how to query a hierarchy?

16 16 DNS Message Flow: Two Types of Queries Recursive query: r Puts burden of name resolution on contacted name server m the contacted name server resolves the name completely Iterated query: r Contacted server replies with name of server to contact m “I don’t know this name, but ask this server”

17 17 Two Extreme DNS Message Flows client cicada.cs.yale.edu root name server 1 2 3 authoritative name server 5 6 TLD name server 4 client cicada.cs.yale.edu root name server 1 6 2 authoritative name server 4 3 TLD name server 5 Issues of the two approaches?

18 18 Typical DNS Message Flow: The Hybrid Case requesting host cyndra.cs.yale.edu gaia.cs.umass.edu root name server 1 2 3 4 authoritative name server dns.cs.umass.edu 5 6 TLD name server 7 8 iterated query local name server 130.132.1.9 Host knows only local name server Local name server is learned from DHCP, or configured, e.g. /etc/resolv.conf Local DNS server helps clients resolve DNS names

19 19 Typical DNS Message Flow: The Hybrid Case requesting host cyndra.cs.yale.edu gaia.cs.umass.edu root name server 1 2 3 4 authoritative name server dns.cs.umass.edu 5 6 TLD name server 7 8 iterated query local name server 130.132.1.9 Host knows only local name server Local name server is learned from DHCP, or configured, e.g. /etc/resolv.conf Local DNS server helps clients resolve DNS names Benefits of local name servers simplifies client caches results

20 20 DNS Records DNS: distributed db storing resource records (RR) r Type=NS  name is domain (e.g. yale.edu)  value is the name of the authoritative name server for this domain RR format: (name, type, value, ttl) r Type=A  name is hostname  value is IP address r Type=CNAME  name is an alias name for some “canonical” (the real) name  value is canonical name r Type=MX  value is hostname of mail server associated with name r Type=SRV m general extension

21 21 DNS Protocol, Messages DNS protocol : typically over UDP (can use TCP); query and reply messages, both with the same message format DNS Msg header: r identification: 16 bit # for query, the reply to a query uses the same # r flags: m query or reply m recursion desired m recursion available m reply is authoritative

22 22 Observing DNS r Use the command dig:  force iterated query to see the trace: %dig +trace www.cnn.com see the manual for more details r Capture the messages m DNS server is at port 53

23 23 Evaluation of DNS Key questions to ask about a C-S application - extensible? - scalable? - robust? - security?

24 24 What DNS did Right? r Hierarchical delegation avoids central control, improving manageability and scalability r Redundant servers improve robustness m see http://www.internetnews.com/dev- news/article.php/1486981 for DDoS attack on root servers in Oct. 2002 (9 of the 13 root servers were crippled, but only slowed the network)http://www.internetnews.com/dev- news/article.php/1486981 r Caching reduces workload and improve robustness

25 25 Problems of DNS r Domain names may not be the best way to name other resources, e.g. files r Relatively static resource types make it hard to introduce new services or handle mobility r Although theoretically you can update the values of the records, it is rarely enabled r Simple query model makes it hard to implement advanced query r Early binding (separation of DNS query from application query) does not work well in mobile, dynamic environments m e.g., load balancing, locate the nearest printer

26 Outline r Recap r Email r DNS r Network application programming 26

27 27 Socket Programming Socket API r introduced in BSD4.1 UNIX, 1981 r Two types of sockets m Connectionless (UDP) m connection-oriented (TCP) an interface (a “door”) into which one application process can both send and receive messages to/from another (remote or local) application process socket

28 28 Services Provided by Transport r Transmission control protocol (TCP) m multiplexing/demultiplexing m reliable data transfer m rate control: flow control and congestion control r User data protocol (UDP) m multiplexing/demultiplexing Host A Hello Host B I am ready DATA ACK

29 29 Big Picture: Socket buffers, states buffers, states

30 30 UDP Java API buffers, states buffers, states

31 31 DatagramSocket(Java) r DatagramSocket() constructs a datagram socket and binds it to any available port on the local host r DatagramSocket(int lport) constructs a datagram socket and binds it to the specified port on the local host machine. r DatagramSocket(int lport, InetAddress laddr) creates a datagram socket and binds to the specified local port and laddress. r DatagramSocket(SocketAddress bindaddr) creates a datagram socket and binds to the specified local socket address. r DatagramPacket(byte[] buf, int length) constructs a DatagramPacket for receiving packets of length length. r DatagramPacket(byte[] buf, int length, InetAddress address, int port) constructs a datagram packet for sending packets of length length to the specified port number on the specified host. r receive(DatagramPacket p) receives a datagram packet from this socket. r send(DatagramPacket p) sends a datagram packet from this socket. r close() closes this datagram socket.

32 Connectionless UDP: Big Picture (Java version) close clientSocket Server (running on hostid ) read reply from clientSocket create socket, clientSocket = DatagramSocket() Client Create datagram using (serv host, x) as (dest addr. port), send request using clientSocket create socket, port= x, for incoming request: serverSocket = DatagramSocket( x ) read request from serverSocket write reply to serverSocket generate reply, create datagram using client host address, port number r Create socket with port number: DatagramSocket sSock = new DatagramSocket(9876); r If no port number is specified, the OS will pick one

33 33 Example: UDPClient.java r A simple UDP client which reads input from keyboard, sends the input to server, and reads the reply back from the server.

34 34 Example: Java client (UDP) import java.io.*; import java.net.*; class UDPClient { public static void main(String args[]) throws Exception { BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); String sentence = inFromUser.readLine(); byte[] sendData = new byte[1024]; sendData = sentence.getBytes(); DatagramSocket clientSocket = new DatagramSocket(); InetAddress sIPAddress = InetAddress.getByName(“servname"); Create input stream Create client socket Translate hostname to IP address using DNS

35 35 Example: Java client (UDP), cont. DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, sIPAddress, 9876); clientSocket.send(sendPacket); byte[] receiveData = new byte[1024]; DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); clientSocket.receive(receivePacket); String modifiedSentence = new String(receivePacket.getData()); System.out.println("FROM SERVER:" + modifiedSentence); clientSocket.close(); } Create datagram with data-to-send, length, IP addr, port Send datagram to server Read datagram from server

36 36 Example: UDPServer.java r A simple UDP server which changes any received sentence to upper case.

37 37 Example: Java Server (UDP) import java.io.*; import java.net.*; class UDPServer { public static void main(String args[]) throws Exception { DatagramSocket serverSocket = new DatagramSocket(9876); byte[] receiveData = new byte[1024]; byte[] sendData = new byte[1024]; while(true) { DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); serverSocket.receive(receivePacket); String sentence = new String(receivePacket.getData()); sendData = capitalizedSentence.getBytes(); Create datagram socket at port 9876 Create space for received datagram Receive datagram

38 38 UDP Connectionless Demux DatagramSocket serverSocket = new DatagramSocket(9876); Client IP:B P2 client IP: A P1 P3 server IP: S SP: 9876 DP: 9157 SP: 9157 DP: 9876 SP: 9876 DP: 5775 SP: 5775 DP: 9876 Source Port (SP) provides “return address”

39 39 Example: Java server (UDP), cont InetAddress IPAddress = receivePacket.getAddress(); int port = receivePacket.getPort(); DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, port); serverSocket.send(sendPacket); } Get IP addr port #, of sender Write out datagram to socket End of while loop, loop back and wait for another datagram Create datagram to send to client

40 Discussion r Are there any problems with the program? 40

41 Discussion r What are challenges in implementing DNS using UDP? 41

42 Discussion r Are there any problems with the program? 42

43 Backup Slides

44 44 UDP Provides Multiplexing/Demultiplexing server client UDP socket space address: {*:9876} snd/recv buf: 128.36.232.5 128.36.230.2 address: {128.36.232.5:53} snd/recv buf: UDP socket space address: {198.69.10.10:1500} snd/recv buf: address: {198.69.10.10:4343} snd/recv buf: 198.69.10.10 Packet demutiplexing is based on (dst address, dst port) at dst %netstat –u –n -a local address local port

45 45 UDP Port Provides Multiplexing/Demultiplexing server client UDP socket space address: {*:9876} snd/recv buf: 128.36.232.5 128.36.230.2 address: {128.36.232.5:53} snd/recv buf: UDP socket space address: {*:1500} snd/recv buf: address: {198.69.10.10:4343} snd/recv buf: 198.69.10.10 Packet demutiplexing is based on (dst address, dst port) at dst %netstat --udp –n -a local address local port


Download ppt "Network Applications: DNS, UDP Socket 1/24/2012. 2 Outline  Recap r DNS r Network application programming: UDP."

Similar presentations


Ads by Google