Applications and Services DNS (Domain Name Service) File Transfer Protocol (FTP) Simple Mail Transfer Protocol (SMTP) Malathi Veeraraghavan Distributed database used to: DNS (Domain Name System) map between hostnames and IP addresses provide electronic routing information Unix implementation: resolver (user-level process) gethostbyname: takes a domain name and returns an IP address gethostbyaddr: takes an IP address and looks up a hostname DNS uses mainly UDP for its lookups except when the response is truncated, in which case resolver uses TCP Malathi Veeraraghavan 2
Hierarchical organization of the DNS unnamed root arpa com edu gov mil int net org ae... us... zw UAE country domains in-addr poly uconn Zimbabwe 35 8 03 photon 44 Each node has a label of up to 63 characters Root node has a null label Domain name of a node is the list of labels, starting at that node, working up to the root, using a period to separate the labels Network Information Center (NIC) maintains the top of the tree arpa is a special domain used for pointer queries to translate IP addresses into domain names. When a host name is added, e.g., photon.poly.edu, an entry also needs to be made under the arpa domain. If photon.poly.edu has an IP address of 35.8.03.44, then the structure shown in created under in-addr.arpa. Note it is backwards; A pointer query for 44.03.8.35.in-addr.arpa will yield the name photon.poly.edu Malathi Veeraraghavan 3 General format of DNS queries/responses 0 5 6 3 identification number of questions number of authority RRs flags number of answer RRs number of additional RRs questions answers (variable number of resource records) authority (variable number of resource records) additional information (variable number of resource records) 2 bytes (DNS header) Identification sent by the client and returned by the server lets client match responses Malathi Veeraraghavan 4
Flags: Fields in the DNS queries/responses QR opcode AA TC RD RA (zero) rcode 4 QR: 0 means the message is a query, means it s a response. opcode: 0 (standard query); (inverse query); 2 (server status request) AA: Authoritative Answer TC: Truncated - with UDP, total length of reply> 52 bytes and only first 52 bytes were returned; resolver usually reissues request using TCP RD: Recursion Desired - If it is set, name server handles it as a recursive query; If it is not set, and the requested name server does not have an authoritative answer, it returns a list of other name servers to contact (iterative query) RA: Recursion Available - If this is set to in the response, the name server supports recursion. rcode: return code - 0 (no error); 3 (name error). The name error is returned by the authoritative name server if the domain name specified in the query does not exist. 3 4 Malathi Veeraraghavan 5 Question portion of the DNS query message The query name is the name being looked up: sequence of one or more labels Each label begins with a -byte count that specifies the no. of bytes to follow Example: gemini.noc.poly.edu is represented as 6gemini3noc4poly3edu0 Query type in a question and each response has a type Name Numeric Value query name query type query class = 0 5 6 3 multiple bytes Description type? query type? A IP address NS 2 name server CNAME 5 canonical name PTR 2 pointer query HINFO 3 host info MX 5 mail exchange record AXFR 252 request for zone transfer * or any 255 request for all records Malathi Veeraraghavan 6
Resource record portion of DNS response domain name multiple bytes type class time-to-live resource data length resource data 0 5 6 3 Domain name: same as the query name Type and class: same as the query type and query class Time-to-live: number of seconds that the RR can be cached by the client (2 days) Resource data length: depends on the type of query; if type=a, resource data is 4 bytes long (IP address) Malathi Veeraraghavan 7 Applications FTP: File Transfer Protocol SMTP: Simple Mail Transfer Protocol SNMP: Simple Network Management Protocol Telnet, Rlogin: Remote login NFS: Network File System HTTP: HyperText Transfer Protocol (web browsing) Malathi Veeraraghavan 8
FTP client user at a terminal user interface user protocol interpreter control connection (FTP commands/ replies) server server protocol interpreter file system user data transfer function data connection server data transfer function file system FTP uses two TCP connections control connection: well-known port number at the server = 2 data connection: well-known port number at the server = 20 Malathi Veeraraghavan 9 Data representation File type ASCII, EBCDIC, Image (binary), Local Format control Nonprint, Telnet format control, Fortran carriage control Structure File structure, Record structure, Page structure Transmission mode Stream mode, block mode, compressed mode Common UNIX implementations of FTP ASCII or image type Nonprint format control only File structure only Stream mode transmission only Malathi Veeraraghavan 0
FTP commands Command Description ABOR Abort previous command and any file transfer LIST filelist List files or directories PASS password Password on server PORT n, n2, n3, n4, n5, n6 Client IP address (n.n2.n3.n4) and port ( n5 256 + n6 ) QUIT Logoff from server RETR filename Retrieve (get) a file STORE filename Store (put) a file SYST Server returns system type TYPE type Specify the file type: ascii or image USER username Username on server Malathi Veeraraghavan FTP replies Example replies (replies are 3 digit numbers: meaning of first two digits on page 424 in text book) 25 Data connection already open; transfer starting 200 Command OK 24 Help message 33 Username OK, password required 425 Can t open data connection 452 Error writing file 500 Syntax error (unrecognized command) 50 Syntax error (invalid arguments) 502 Unimplemented MODE type Malathi Veeraraghavan 2
FTP client port 73 port 74 IP addr 40.252.3.34 FTP client port 73 port 74 IP addr 40.252.3.34 Connection management PORT 40, 252, 3, 34, 4, 50\r\n 4x256 + 50 = 74 (control connection) FTP server port 2 FTP server port 2 port 20 SYN to 40.252.3.34 port 74 (active open) Control connection stays up for the duration of the client-server connection Creation of data connection is under control of client Client chooses an ephemeral port number on the client host for its end of the data connection. Client sends the PORT command to the server across the control connection Server receives the port number and issues an active open to that port on the client host. The server s end of the data connection always uses port 20. Multiple FTP sessions from multiple clients to the same FTP server Malathi Veeraraghavan 3 SMTP user at a terminal sender User agent queue of mail to be sent message transfer agent user at a terminal receiver User agent user mailboxes port 25 message transfer agent Communication between two MTAs uses NVT (network virtual terminal) ASCII SMTP commands Send mail: HELO, MAIL, RCPT, DATA, QUIT Malathi Veeraraghavan 4
sun% mail wallace@noao.edu To: wallace@noao.edu Subject: testing Example invokes user agent this is output by user agent, 2, 3. user agent adds one blank line;. this is body of message Sending letter to wallace@noao.edu verbose output from user agent following is output by MTA Connecting to mailhost via ether... Trying 40.252..54... connected. 220 noao.edu Sendmail 4... >>> HELO sun.tuc.noao.edu 250 noao.edu Hello sun.tuc.noao.edu Client does an active open to port 25 >>> MAIL From: <rstevens@sun.tuc.noao.edu> MAIL command identifies sender 250 <rstevens@sun.tuc.noao.edu> Sender OK >>> RCPT To: <wallace@noao.edu> RCPT command identifies recipient 250 <wallace@noao.edu> Recipient OK >>> DATA DATA command carries actual data 354 Enter mail, end with. on a line by itself Malathi Veeraraghavan 5 Example continued >>> QUIT terminates mail exchange 22 noao.edu delivering mail wallace@noao.edu... Sent sent. This is output by user agent Actual data sent: 393 bytes (for just the one line, 2, 3?) Received: by sun.tuc.noao.edu (4./SMI-4.) id AA00502; Mon, 9 Jul 93 2:47:32 MST Message Id: <9379947.AA00502@sun.tuc.noao.edu.> From: rstevens@sun.tuc.noao.edu (Richard Stevens) Date: Mon, 9 Jul 993, 2:47:2-0700 Reply-To: wallace@noao.edu X-Phone: X-Mailer: To: wallace@noao.edu Subject: testing, 2, 3. Malathi Veeraraghavan 6
Other SMTP commands RSET: aborts current mail transaction and causes both ends to reset VRFY: lets the client ask the sender to verify a recipient address without sending mail to the recipient NOOP command does nothing except make the server respond with a 200 OK reply code. Other optional commands Malathi Veeraraghavan 7 Envelopes, headers, body Electronic mail is composed of three pieces: Envelope: used by the MTA for delivery; MAIL, RCPT commands Headers: used by user agents. Nine header fields in example: Received, Message-Id, From, Date, Reply-To, X-Phone, X-Mailer, To, Subject Body: content of message (NVT ASCII text) Malathi Veeraraghavan 8