Download presentation
Presentation is loading. Please wait.
Published byFrederica Kennedy Modified over 7 years ago
1
CSS432 Applications Textbook Ch 9.1 and 9.3.1
Prof. Athirai Irissappane CSS432: Applications
2
Applications Client – Server Paradigm
Client: initiates contact with server Server: provides client with a response Applications use their corresponding protocol Defined in RFC by Internet Engineering Task Force ( Implemented on top of TCP or UDP Client Server outlook browser mail/web server SMTP, HTTP, FTP SMTP, HTTP, FTP socket socket TCP with buffers, variables TCP with buffers, variables Applications Protocol RFC Port Name service DNS 1035 53 SMTP IMAP 821 25 143 Web HTTP 2616 80 File transfer FTP 959 21 Remote terminal access telnet 854 23 RFC – document showing detailed description of the protocols Internet CSS432: Applications
3
The University of Adelaide, School of Computer Science
11 February 2018 DNS Domain Name System (DNS)—not an application that users normally invoke explicitly, but rather a service that almost all other applications depend upon. This is because the name service is used to translate host names into host addresses; the existence of such an application allows the users of other applications to refer to remote hosts by name rather than by address. Chapter 2 — Instructions: Language of the Computer
4
The University of Adelaide, School of Computer Science
11 February 2018 Name Service (DNS) While perfectly suited for processing by routers, addresses are not exactly user-friendly. It is for this reason that a unique name is also typically assigned to each host in a network. Host names differ from host addresses in two important ways. First, they are usually of variable length and mnemonic, thereby making them easier for humans to remember. Second, names typically contain no information that helps the network locate (route packets toward) the host. Addresses can have routing information embedded in them Chapter 2 — Instructions: Language of the Computer
5
The University of Adelaide, School of Computer Science
11 February 2018 Name Service (DNS) We first introduce some basic terminology. First, a name space defines the set of possible names. A name space can be either flat (names are not divisible into components), or it can be hierarchical (Unix file names are an obvious example). Second, the naming system maintains a collection of bindings of names to values. The value can be anything we want the naming system to return when presented with a name; in many cases it is an address. Finally, a resolution mechanism is a procedure that, when invoked with a name, returns the corresponding value. A name server is a specific implementation of a resolution mechanism that is available on a network and that can be queried by sending it a message. Chapter 2 — Instructions: Language of the Computer
6
Name Service Hosts cheltenham.cs.princeton.edu 192.12.69.17
DNS Name Server Value System-provided fixed value Location dependent Name Variable length and mnemonic Location independent Hosts cheltenham.cs.princeton.edu :23:A8:33:5B:9F A Unix filesystem is a collection of files and directories that has the following properties − It has a root directory (/) that contains other files and directories. Each file or directory is uniquely identified by its name, the directory in which it resides, and a unique identifier, typically called an inode. CSS432: Applications
7
The University of Adelaide, School of Computer Science
11 February 2018 DNS Uses a hierarchical name space the DNS hierarchy can be visualized as a tree, where each node in the tree corresponds to a domain, and the leaves in the tree correspond to the hosts being named DNS names are processed from right to left and use periods as the separator Chapter 2 — Instructions: Language of the Computer
8
Domain Naming System Hierarchy Name DNS
uw bothell.washington.edu (Currently, uw uwb.edu) edu com washington … mit u cs uw medusa bothell cisco yahoo nasa nsf arpa navy acm ieee gov mil org net uk fr homer goodall CSS432: Applications
9
The University of Adelaide, School of Computer Science
11 February 2018 Hierarchy implementation The complete domain name hierarchy exists only in the abstract. We now turn our attention to the question of how this hierarchy is actually implemented. The first step is to partition the hierarchy into subtrees called zones. Each zone can be thought of as corresponding to some administrative authority that is responsible for that portion of the hierarchy. For example, the top level of the hierarchy forms a zone that is managed by the Internet Corporation for Assigned Names and Numbers (ICANN). Each zone implemented by two or more name servers Each name server, in turn is a program that can be accessed over the internet Name server: mantains DNS and provides translation services Chapter 2 — Instructions: Language of the Computer
10
Name Servers Partition hierarchy into zones
DNS Name Servers administrative unit Partition hierarchy into zones Network Information Center manages edu com washington … mit u cs uw medusa bothell cisco yahoo nasa nsf arpa navy acm ieee gov mil org net uk fr homer goodall Managed by UW C&C Root name server washington Cisco bothell cs … Each zone implemented by two or more name servers Find the root server Find Washington server Find cs server Retrieve the ip address of lab systems CSS432: Applications
11
DNS Resource Records Each name server maintains a collection of resource records (Name, Value, Type, Class, TTL) Name/Value: not necessarily host names to IP addresses Type A: Value returns IP address NS: Value returns the corresponding name server’s name CNAME: Value returns aliases, canonical name for hosts MX: Value returns the domain name of this host’s which runs a mail server Class: IN (Internet class) TTL: how long the resource record is valid (servers can cache records) CSS432: Applications
12
Name Resolution Client
DNS Name Resolution Root name server Princeton CS Local Client 1 cicada.cs.princeton.edu 8 princeton.edu, cicada.cs.princeton.edu, cs.princeton.edu, 2 3 4 5 6 7 Client Initialized with its local name server’s address appends its domain name to a given name before a submission. Local server needs to know root at only one place (not each host). caches recent responses from remote servers. CSS432: Applications
13
(1) Every client knows its local name server’s address
DNS (1) Every client knows its local name server’s address Every local name server knows one or more root servers (2)The local name server then queries the remote root servers on the client’s behalf (3) the root server replies back with the closest matching name record which can be a NS (4) the princeton NS is queried replies back with NS of CS (5) the CS NS is queried for a specific record and replies with IP CSS432: Applications
14
Name Servers From Root to Bottom Level
DNS Name Servers From Root to Bottom Level Use dig command to query Name servers options name type ..) dig edu ns (find a name server for name=edu) edu a.gtld-server.net NS IN a.gtld-server.net A IN Find uwb.edu’s name servers uwb.edu ns (find NS with name=uwb.edu) uwb.edu, dns2.uwb.edu NS IN uwb.edu, dns4.uwb.edu NS IN dns2.uwb.edu A dns4.uwb.edu A Find metis.uwb.edu metis.uwb.edu A metis.uwb.edu A Dig: use servers listed in in /etc/resolv.conf search example.com local.lan nameserver nameserver nameserver nameserver
15
Electronic Mail (SMTP, MIME, IMAP)
user agents (client) a.k.a. “mail reader” composing, editing, reading mail messages e.g., Eudora, Outlook, elm, Netscape Messenger, Thunderbird mail servers (server) outgoing, incoming messages stored on server mail server outgoing mail queue User mailbox user agent SMTP/TCP SMTP IMAP CSS432: Applications
16
The University of Adelaide, School of Computer Science
11 February 2018 In the early days of the Internet, host had the mailbox resided, and the mail reader they invoked was a local application program that extracted messages from the file system. Today, of course, mailbox resides at the server, users remotely access their mailbox from their laptop or smartphone using yet another protocol, such as the Post Office Protocol (POP) or the Internet Message Access Protocol (IMAP); in many cases the mail traverses one or more mail gateways on its route from the sender’s host to the receiver’s host. SMTP is sometimes called a "Push" protocol--it pushes the message to its next destination and assumes that a user at the destination will "signon" and read their mail directly– POP/IMAP is a "Pull" protocol, in that the user's mail client pulls down the message to their work station Chapter 2 — Instructions: Language of the Computer
17
The University of Adelaide, School of Computer Science
11 February 2018 POP – downloads mails to local storage, IMAP – maintains copy of mails in the server even after download Both are PULL protocols: Poll the server for new mails periodically or when active Why pull? If push, Host must stay up to receive mail IMAP has notifications feature: Notify receiver for new mails then pulls the actual mails Nowadays, the protocol used is ActiveSync which supports Push operations Mails notified when received and can be downloaded instantly Chapter 2 — Instructions: Language of the Computer
18
SMTP TCP port 25 – Persistent connection Email sending protocol
From User agent to his/her local mail server From a local to an intermediate/destination mail server (direct transfer) From an intermediate to a destination server (relay) Three phases of transfer Handshaking: HELO Transfer of messages: MAIL FROM, RCPT TO, and DATA Closure: QUIT Command/response interaction Commands: ASCII text Response: status code and phrase Keep alive is a method to allow the same tcp connection for HTTP conversation instead of opening a new one with each new request. More simply put, it is a communication between the web server and the web browser that says "you can grab more than just one file at a time". if the sending mail server has several messages to send to the same receiving mail server, it can send all of the messages over the same TCP connection. For each message, the client begins the process with a new HELO crepes.fr and only issues QUIT after all messages have been sent. CSS432: Applications
19
SMTP Example Email [css432@uw1-320-20]$ telnet smtp.washington.edu 25
Trying … Connected to smpt.washington.edu ( ). Escape character is ‘^]’. 220 smtp.washington.edu ESMTP Sendmail UW04.02/ UW04.02; Sat, 21 Feb :00: HELO 250 smtp.washington.edu Hello UW bothell.washington.edu [ ] , pleased to meet you MAIL Sender ok RCPT Recipient ok DATA 354 Enter mail, end with “.” on a line by itself Blah blah blah… …etc. etc. etc. . i1M40uc Message accepted from delivery QUIT smtp.washington.edu closing connection Connection closed by foreign host. _ CSS432: Applications
20
RFC 822 Message Format Header Body ASCII characters only.
Header a series of <CRLF>-terminated lines. (<CRLF> stands for carriage-return+ line-feed, ASCII control characters for end of a line) Each header line contains a type and value separated by a colon Body ASCII characters only. Then, what about multimedia information? RFC 822 extended: MIME Header To: Subject: Date: From: Received: Body A blank line The RFC series contains technical and organizational documents about the Internet, including the specifications and policy documents produced by four streams: the Internet Engineering Task Force (IETF), the Internet Research Task Force (IRTF), the Internet Architecture Board (IAB), and Independent Submissions. CSS432: Applications
21
The University of Adelaide, School of Computer Science
11 February 2018 MIME allow messages to carry many different types of data: audio, video, images, PDF documents, and so on. Message Format MIME consists of three basic pieces. collection of additional header lines MIME-Version: (the version of MIME being used), Content-Description: (a human-readable description of what’s in the message, analogous to the Subject: line), Content-Type: (the type of data contained in the message), and Content-Transfer- Encoding (how the data in the message body is encoded). Chapter 2 — Instructions: Language of the Computer
22
The University of Adelaide, School of Computer Science
11 February 2018 MIME Definitions for a set of content types (and subtypes). For example, Type:image; SubType: image/gif and image/jpeg Type:text; SubType: text/plain, text/richtext (markup, special fonts); Type:application; SubType:application/postscript, application/msword, representing output of different application programs. Type:Mutltipart; how messages carrying more than 1 data type are structured SubType:Multipart/mixed (set of independent data pieces, each piece has separate header describing its content type) Way to encode the various data types so they can be shipped in an ASCII message Base64 encoding Every 3 bytes of original binary data into 4 ASCII charcters Group binary data into 24 bit units (3 bytes) Break each unit into 4, 6-bit pieces Map each 6-bit piece into 1 ASCII character Man is TWFu. Encoded in ASCII, the characters M, a, and n are stored as the bytes 77, 97, and 110, which are the 8-bit binary values , , and These three values are joined together into a 24-bit string, producing Groups of 6 bits 6 bits have a maximum of 26 = 64 different binary values) are converted into individual numbers from left to right (in this case, there are four numbers in a 24-bit string), which are then converted into their corresponding Base64 character values , , , represent 19, 22, 54, 6. In the 64 index table (choose 64 from ASCII based on certain criteria) T, W, F, u Hence man becomes TWFu Chapter 2 — Instructions: Language of the Computer
23
MIME MIME: multimedia mail extension, RFC 2045, 2056
MIME: multimedia mail extension, RFC 2045, 2056 Additional lines in msg header declare MIME content type MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=“ CA6E2DE4ABCAFBC5” From: To: Subject: CSS432- MIME Sample Date: Wed, 08 Feb :59: CA6E2DE4ABCAFBC5 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi all, Attached is the jpeg and draft report. Cheers! athirai Content-Type: image/jpeg Content-Transfer-Encoding: base64 … Unreadable encoding of a jpeg figure Content-Type: application/postscript; name=“draft.ps” … Readable encoding of a postscript document Carry more than one data type Type of the data How the data is encoded 3bytes = 3 * 8bits = 24bits = 4 * 6bit-chars, each mapped onto one of 64 ASCII chars (A~Z,a~z,0~9,+,/) Postscript, as the name sort of suggests, is actually a Turing-complete programming language. Directions are written out in a human-readable way, and communicated to the printer, which creates the high quality art from the instructions. SMTP, by definition (RFC 821), limits mail to lines of 1000 characters of 7 bits each. That means that none of the bytes you send down the pipe can have the most significant ("highest-order") bit set to "1". The content that we want to send will often not obey this restriction inherently. Think of an image file, or a text file that contains Unicode characters: the bytes of these files will often have their 8th bit set to "1". SMTP doesn't allow this, so you need to use "transfer encoding" to describe how you've worked around the mismatch. The values for the Content-Transfer-Encoding header describe the rule that you've chosen to solve this problem. 7bit simply means "My data consists only of US-ASCII characters, which only use the lower 7 bits for each character." You're basically guaranteeing that all of the bytes in your content already adhere to the restrictions of SMTP, and so it needs no special treatment. You can just read it as-is. Note that when you choose 7bit, you're agreeing that all of the lines in your content are less than 1000 characters in length Definitions for content types
24
Mail Reader – IMAP (persistent connection)
TCP to 143 Connection established Server greeting Server: OK Server: PREAUTH Server: BYE Not authenticated Client LOGOUT Client: LOGIN or AUTHENTICATE Authenticated Client: CLOSE Client LOGOUT Client SELECT or EXAMINE Selected Client: FETCH, STORE, DELETE, EXPUNGE Client LOGOUT Logout Both sides close the connection CSS432: Applications
25
File Transfer Protocol
FTP local file system remote FTP server client user interface TCP port 20 for data transfer (not persistent) TCP port 21 for control (persistent) CSS432: Applications
26
FTP Commands FTP FTP: Control connection (TCP)- commands and responses, data connection (TCP) – data transfer ACTIVE MODE: client establishes the command channel, server establishes the data channel Client opens up command channel from client port 35762 to server port 21. Client sends PORT 35763 to server and server acknowledges on command channel. Server opens up data channel from server port 20 to client port 35763 Client acknowledges on data channel. Passive mode: the client establishes both channels Client opens up command channel from client port 35763 to server port 21 Client issues PASV command Server sends back (on command channel) port number 46005 after starting to listen on that port. Client opens up data channel from client to server port Server acknowledges on data channel. Port 20/21 are used traditionally, i.e., 21 for command channel and 20 for data channel CSS432: Applications
27
FTP Commands <CRLF> delimits each command (and reply).
Commands consist of four uppercase ASCII characters, some with optional arguments: USER username : sends a user identification to server. PASS password : sends the user password to the server. PASV: requests the server to send back its IP and port on which it listens to a data TCP connection from the user. LIST : ask the server to send back its current directory contents through the data connection. RETR filename : gets a file from the current remote directory. STOR filename : stores a file into the current remote directory. Each command is followed by a reply: 331 Username OK, password required 125 Data connection already open; transfer starting 425 Can't open data connection 452 Error writing file CSS432: Applications
28
FTP Example FTP [css432@uw1-320-20]$ telnet ftp.tripod.com 21
Trying … Connected to ftp.tripod.com ( ). Escape character is ‘^]’. 220 Welcome to Tripod FTP. USER css432w17 331 Username set to css432. Now enter your password. PASS ******** 230 User ‘css432w17’ logged on. LIST 425 Can’t open data connection for LIST. PASV 227 Entering Passiv Mode (209,202,252,54,127,31) // Open another xterm and telnet (=127*256+31) // Trying … // Connected to ftp.tripod.com ( ). // Escape character is ‘^]’. 150 Opening ASCII mode data connection for LIST. 226 Transfer complete. // -rw-r--r css432w17 Tripod Feb 10 17:29 index.htm // drwxr-xr-x 1 css432w17 Tripod Feb 10 17:39 cgi-bin // drwxr-xr-x 1 css432w17 Tripod Feb 10 17:54 project // Connection closed by foreign host. QUIT 221 Goodbye Connection closed by foreign host. _ CSS432: Applications
29
FTP passive mode FTP client FTP server
TCP port 21 for control (persistent) Client request: connect( ), USER, PASS, LIST Server Reply: 220 server ready, 331 send password, 230 login ok, 425 connection timeout TCP port 20 for data transfer (one time) FTP client FTP server TCP port 21 for control (persistent) SYST: displays system name, TYPE, ie. Type of file to be transfered UNIX Type: L8 ; FTP clients use this information to correctly interpret and display server response. Different server’s can have different response code An FTP server reply is an acknowledgement sent from an FTP server to user in response to FTP commands. A reply is composed of a 3-digit reply code followed by a text string. Different implementations of FTP server can supply different text string for the same reply code, since it is usually intended for human users. RETR: RETR remote-filename Begins transmission of a file from the remote host. Must be preceded by either a PORT command or a PASV command to indicate where the server should send data. STOR remote-filename Begins transmission of a file to the remote site. Must be preceded by either a PORT command or a PASV command so the server knows where to accept data from. PROXY Execute an ftp command on a secondary control connec- tion. This command allows simultaneous connection to two remote ftp servers for transferring files between the two servers. Close: closes the current FTP connection with server but still leaves you within the FTP environment. Quit: to exit the FTP environment Client request: connect( ), USER, PASS, PASV, LIST Server Reply: 220 server ready, 331 send password, 230 login ok, 227 Entering Passive Mode (140,142,12,173,195,54), 226 complete TCP port 195* = for data transfer (one time) data CSS432: Applications
30
FTP proxy command / FTP client (Transfer files from s2 to s1)
(3’) 227 Entering Passive Mode (140,142,12,173,195,54) FTP client (1) USER, PASS, SYST (2) USER, PASS, SYST (3) TYPE I, PASV (4) TYPE I, PORT (140,142,12,173,195,54), (6)RETR file (7) QUIT (5) STOR file (8) QUIT ftp> open server1 ftp> proxy open server2 ftp> proxy put file ftp>quit …(1) …(2) …(3)~(6) …(7)~(8) FTP Server 1 FTP Server 2 SYST: displays system name, TYPE, ie. Type of file to be transferred UNIX Type: L8 RETR: RETR remote-filename Begins transmission of a file from the remote host. Must be preceded by either a PORT command or a PASV command to indicate where the server should send data. RETR filename gets file from server in the data connection (Retrieve/gets a file from the server, fork a child and start reading the file before sending the retr command) STOR remote-filename Begins transmission of a file to the remote site. Must be preceded by either a PORT command or a PASV command so the server knows where to accept data from. “There is a file which is going to be transmitted to you. Open a file with the “remote-filename”, get the contents being transmitted after this command and store it in the opened file” PROXY Execute an ftp command on a secondary control connec- tion. This command allows simultaneous connection to two remote ftp servers for transferring files between the two servers. TYPE:Sets the transfer mode (ASCII/Binary). A - ASCII text E - EBCDIC text I - image (binary data) L - local format Close: closes the current FTP connection with server but still leaves you within the FTP environment. Quit: to exit the FTP environment PORT Syntax: PORT a1,a2,a3,a4,p1,p2 Specifies the host and port to which the server should connect for the next file transfer. This is interpreted as IP address a1.a2.a3.a4, port p1*256+p2. Close only -> send QUIT and return Close & come out of ftp -> send TCP port 195* = for data transfer (one time) data CSS432: Applications
31
World Wide Web - HTTP Web /public_html HTTP server Netscape TCP port 80 (one-time connection) IE HTTP request HTTP response Hypertext Transfer Protocol: one-time TCP port 80 connection for each response/reply client: Browser requests, receives, and displays Web objects server: Web server sends objects in response to the request CSS432: Applications
32
HTTP Commands Web HTTP The core idea of hypertext is that one document can link to another document, and the protocol (HTTP) and document language (HTML) were designed to meet that goal. URL They provide information that allows objects on the Web to be located, and they look like the following: If you opened that particular URL, your Web browser would open a TCP connection to the Web server at a machine called and immediately retrieve and display the file called index.html. CSS432: Applications
33
HTTP Commands Web Client
Initiates a TCP connection to a server on port 80. Sends an HTTP request over this TCP connection OPTIONS: request information about available options GET: retrieve document identified in URL HEAD: retrieve document metainformation in URL POST: give information (annotation, servlet invocation) to server PUT: store document under specified URL DELETE, TRACE, CONNECT Receives an HTTP response Server Accepts a TCP connection from a client on port 80. Receives an HTTP request Returns an HTTP response and disconnects the connection. 1xx: Informational 2xx: success 3xx: Redirection 4xx: Client error 5xx: Server error By design, the POST request method requests that a web server accept the data enclosed in the body of the request message, most likely for storing it.[1] It is often used when uploading a file or when submitting a completed web form. In contrast, the HTTP GET request method retrieves information from the server. As part of a GET request, some data can be passed within the URL's query string, specifying (for example) search terms, date ranges, or other information that defines the query. As part of a POST request, an arbitrary amount of data of any type can be sent to the server in the body of the request message. A header field in the POST request usually indicates the message body's Internet media type. The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line The PUT method requests that the enclosed entity be stored under the supplied Request-URI. The DELETE method requests that the origin server delete the resource identified by the Request-URI. The TRACE method is used to invoke a remote, application-layer loop- back of the request message. TRACE allows the client to see what is being received at the other end of the request chain and use that data for testing or diagnostic information. The OPTIONS method represents a request for information about the communication options available on the request/response chain identified by the Request-URI. On the server CSS432: Applications
34
HTTP Example Web [css432@uw1-320-20]$ telnet www.washington.edu 80
Trying Connected to ( ). Escape character is '^]'. GET HTTP/ OK Date: Sun, 22 Feb :06:17 GMT Server: Apache/ (Unix) PHP/4.3.3 mod_perl/1.29 mod_backhand/1.2.2 Connection: close Content-type: text/html <!doctype html public “-//W3C/DTD HTML 4.0 Transitional//EN”> <html><head> … </body></html> Connection closed by foreign host. _ CSS432: Applications
35
The University of Adelaide, School of Computer Science
11 February 2018 HTTP 1.0 TCP Connections The original version of HTTP (1.0) established a separate TCP connection for each data item retrieved from the server HTTP 1.0 behavior Chapter 2 — Instructions: Language of the Computer
36
The University of Adelaide, School of Computer Science
11 February 2018 Persistent Connection the client and server can exchange multiple request/response messages over the same TCP connection. Reduces latency, can avoid slow start each time due to TCP’s congestion window mechanism HTTP 1.1 behavior with persistent connections Chapter 2 — Instructions: Language of the Computer
37
Performance Improvement in Web
Persistent TCP connections Advantages Eliminate the connection setup overhead Eliminate repetitions of slow start phase Disadvantages Need to know the time period of connection – server times out the connection. Caching Recently access pages can be cached at browsers and ISPs Reduce the number of HTTP accesses Need to purge out-of-date version of pages – use expiration date and cache directives to cache or not to cache a given page Server assigns an expiration date when it sends back a page to the client after which it can no longer be cached CSS432: Applications
38
Exercises: try the following example by yourself.
Reviews RFC Naming service: DNS SMTP, MIME, and IMAP File transfer: FTP WWW: HTTP Exercises: try the following example by yourself. FTP CSS432: Applications
39
HW4 NAT: Network Address Translation a network device, usually a firewall, assigns a public address to a computer (or group of computers) inside a private network when connecting to an external network such as internet Dynamic Host Configuration Protocol (DHCP) is a network protocol that enables aserver to automatically assign an IP address to a computer from a defined range of numbers (i.e., a scope) configured for a given network The main use of NAT is to limit the number of public IP addresses an organization or company must use, for both economy and security purposes CSS432: Applications
40
Similar to linux FTP client
Project: FTP client Similar to linux FTP client ftp ftp.tripod.com ls, open, close, quit commands Map to the functions specified by RFC 959 E.g., ls PASV + LIST Establish TCP connection with server Use read and write commands User issues ls, client should send PASV, LIST command to server and read back the response from server File Transfer issues CSS432: Applications
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.