CS代写 SEHH2238 Computer Networking

Lecture 12
Network Applications and Sockets
Textbook: Ch. 26
SEHH2238 Computer Networking

Copyright By PowCoder代写 加微信 powcoder

SEHH2238 Lecture 12 1

SEHH2238 Computer Networking
WORLD WIDE WEB AND HTTP (26.1)
FTP (26.2)
Sockets (25)
􏰁 Browser 􏰁 HTTP
􏰁 Connections Emails (26.3)
􏰁 Sending and retrieving DNS (26.6)
􏰁 Name Spaces 􏰁 Resolution
Main Topics
SEHH2238 Lecture 12 2

SEHH2238 Computer Networking
A. World Wide Web
􏰀 Consists of webpages with various items 􏰁Text, image, video, etc.
􏰀 Consider the main document (file A) of a webpage contains a reference to an image file (file B) and a reference to a text file (file C)
􏰁File A and file B are in Site I 􏰁File C is in Site II
Site I : A and B Site II: C
SEHH2238 Lecture 12

SEHH2238 Computer Networking
Web pages linking to multiple sites
Figure 26.1: Example 26.1 SEHH2238 Lecture 12 4

SEHH2238 Computer Networking
􏰀 It allows them to view content via the web in its graphic form rather than HTML code, the primary language used by a website’s designers to place the varying elements of a website
Figure 26.2: Browser
SEHH2238 Lecture 12 5

SEHH2238 Computer Networking
Uniform Resource Identifier (URL)
􏰀 URL format
􏰀 protocol://host/path used most of the time
􏰀 protocol://host:port/path used when port number is needed
􏰀 The URL http://www.mhhe.com/compsci/forouzan/ defines the web page related to one of the computer in the McGraw-Hill company
􏰀 Thecomputer(host)nameiswww.mhhe.com 􏰀 The three letters www are part of the host name.
􏰀 The path is compsci/forouzan/, which defines Forouzan’s web
page under the directory compsci.
SEHH2238 Lecture 12 6

SEHH2238 Computer Networking
HyperText Transfer Protocol
􏰀 The HyperText Transfer Protocol (HTTP) is used to define how the client-server programs can be written to retrieve web pages from the W eb.
􏰁An HTTP client sends a request; an HTTP server returns a response.
􏰁The server uses the port number 80; the client uses a temporary port number.
􏰁HTTP uses the services of TCP.
SEHH2238 Lecture 12 7

SEHH2238 Computer Networking
Connection Persistence
􏰀 Non-persistent connection 􏰁For example:
􏰀 The client needs to access a file that contains one link to an image. The text file and image are located on the same server. Here we need two connections.
􏰀 For each connection, TCP requires at least three handshake messages to establish the connection, but the request can be sent with the third one.
􏰀 After the connection is established, the object can be transferred.
􏰀 After receiving an object, another three handshake messages are
needed to terminate the connection 􏰁Used in HTTP 1.0
SEHH2238 Lecture 12 8

SEHH2238 Computer Networking
Figure 26.3:
Non-persistent connection
SEHH2238 Lecture 12 9

SEHH2238 Computer Networking
Persistent connection
􏰀 Only one connection establishment and connection termination is used, but the request for the image is sent separately.
􏰁Used in HTTP 1.1
Figure 26.4:
SEHH2238 Lecture 12 10

SEHH2238 Computer Networking
Figure 26.6 SEHH2238 Lecture 12 11

SEHH2238 Computer Networking
Example 26.6
This example retrieves a document (see Figure
26.6). We use the GET method to retrieve an image
with the path /usr/bin/image1.
􏰀 Therequestlineshowsthemethod(GET),theURL,and the HTTP version (1.1).
􏰀 Theheaderhastwolinesthatshowthattheclientcan accept images in the GIF or JPEG format.
􏰀 Therequestdoesnothaveabody.
􏰀 Theresponsemessagecontainsthestatuslineandfour lines of header. The header lines define the date, server, content encoding (MIME version, which will be described in electronic mail), and length of the document.
􏰀 Thebodyofthedocumentfollowstheheader.
SEHH2238 Lecture 12 12

SEHH2238 Computer Networking
Common HTTP Methods
Method Action
GET Requests a document from the server
Requests information about a document but not the document itself
PUT Sends a document from the client to the server
Sends some information from the client to the server
DELETE Removes a document from the server
SEHH2238 Lecture 12 13

SEHH2238 Computer Networking
Figure 26.10: FTP
SEHH2238 Lecture 12 14
File Transfer Protocol (FTP) is the standard protocol provided by TCP/IP for copying a file from one host to another.
Control connection
Data connection

SEHH2238 Computer Networking
Two Connections
􏰀 Two connections in FTP
􏰀 The control connection (port 21)
􏰀 remains connected during the entire interactive FTP session.
􏰀 The data connection (port 20)
􏰀 is opened and then closed for each file transfer
􏰀 It opens each time commands that involve transferring files are used, and it closes when the file is transferred.
SEHH2238 Lecture 12

SEHH2238 Computer Networking
Data Connection
The data connection uses the well-known port 20 at the server site. However, the creation of a data connection is different from the control connection. The following shows the steps:
1. The client, not the server, issues a passive open using an ephemeral port.
2. Using the PORT command the client sends this port number to the server.
3. The server receives the port number and issues an active open using the well-known port 20 and the received ephemeral port number.
SEHH2238 Lecture 12

SEHH2238 Computer Networking
Figure 26.11: Example 26.12 SEHH2238 Lecture 12 17

SEHH2238 Computer Networking
Example 26.10
Figure 26.11 shows an example of using FTP for retrieving only one file.
􏰀 The control connection remains open all the time, but the
data connection is opened and closed repeatedly.
􏰀 After all records have been transferred, the server control
process announces that the file transfer is done.
􏰀 Since the client control process has no file to retrieve, it issues the QUIT command, which causes the service
connection to be closed.
SEHH2238 Lecture 12 18

SEHH2238 Computer Networking
Example 26.11
The following shows an actual FTP session that lists the directories.
SEHH2238 Lecture 12 19

SEHH2238 Computer Networking
C. ELECTRONIC MAIL
􏰀 Electronic mail (or e-mail) allows users to exchange messages.
􏰀 E-mail is a one-way transaction
􏰀 The email system needs two user agents (UA), two pairs of Mail Transfer Agent (MTAs) (client and server), and a pair of Mail Access Agent (MAAs) (client and server).
Figure 26.14: E-mail address
SEHH2238 Lecture 12 20

SEHH2238 Computer Networking
Figure 26.12: Common scenario
SEHH2238 Lecture 12
Email Architecture

SEHH2238 Computer Networking
Email Sending
1. User Agent (UA) provides service to the user to create email.
2. UA sends the mail to the mail server by Simple mail transfer protocol (SMTP).
3. The mail server at sending site use a queue (spool) to store messages
4. The message is waiting to be sent.
5. Mail Transfer Agent (MTA) client in the sending site sends the mail to receiver’s mail server, by SMTP .
SEHH2238 Lecture 12 22

SEHH2238 Computer Networking
Email Reading
6. MTA server in the receiving site store the mail in the reserving users’ mailbox.
7. Receiving user connects to the mail server (login)
8. Then, the mail is delivered by POP or IMAP
protocol by Mail Access Agent (MAA).
Figure 26.15: Protocols used in electronic mail

SEHH2238 Computer Networking
D. DOMAIN NAME SYSTEM (DNS)
􏰀 The Internet needs to have a directory system that can map a name to an address.
􏰀 The names must be unique because the addresses are unique.
􏰀 A name space that maps each address to a unique name.
SEHH2238 Lecture 12 24

SEHH2238 Computer Networking
Flow of Domain Name to IP
Figure 26.28: Purpose of DNS
SEHH2238 Lecture 12 25

SEHH2238 Computer Networking
Domain names and labels
Figure 26.30: Domain names and labels
SEHH2238 Lecture 12 26

SEHH2238 Computer Networking
Resolution
􏰀 Mappinganametoanaddressiscalledname-addressresolution.
􏰀 DNSisdesignedasaclient-serverapplication.
􏰀 The resolver accesses the closest DNS server with a mapping request.
􏰁 If the server has the information, it satisfies the resolver;
􏰁 otherwise, it either refers the resolver to other servers or asks other
servers to provide the information.
Figure 26.32: Hierarchy of name servers
SEHH2238 Lecture 12 27

SEHH2238 Computer Networking
Query for the IP address of engineering.mcgraw-hill.com
Figure 26.36: Recursive resolution
SEHH2238 Lecture 12
Recursive resolution

SEHH2238 Computer Networking
Query for the IP address of engineering.mcgraw-hill.com
Figure 26.37: Iterative resolution
SEHH2238 Lecture 12 29
Iterative resolution

SEHH2238 Computer Networking
E. Sockets
􏰀 There are different types of application programs 􏰀 Using a common set of lower layer protocols in
TCP/IP protocol suite, usually provided by OS 􏰀 Need a socket for such interaction
􏰁 Analogy: Different electric appliances use the same electricity supply network via electric socket
SEHH2238 Lecture 12 30

SEHH2238 Computer Networking
transport network
transport network
link physical
transport network
link physical
link physical
Socket Address
􏰀 A host can run multiple applications, each has a socket for communication.
application
application
􏰀 The combination of an IP address and a port number is called a socket address.
application
SEHH2238 Lecture 13

SEHH2238 Computer Networking
Application programming interface (API)
􏰀 Howcanaclientprocesscommunicatewithaserver process?
􏰀 We need a set of instructions to tell the lowest four layers of the TCP/IP suite to
􏰀 open the connection,
􏰀 send and receive data from the other end, and
􏰀 close the connection.
􏰁 A set of instructions of this kind is normally referred to as an application programming interface (API).
SEHH2238 Lecture 13 32

SEHH2238 Computer Networking
Socket Programming
􏰀 A component of application design that involves network connection.
􏰀 Write programs to… (refer to appendix for details) 􏰁create socket depends on TCP or UDP is used 􏰁read and write data from the socket
􏰁perform necessary processing on the data
􏰀 Client initiates data transmission to a server.
􏰀 For server, the socket is always waiting (listening) for incoming data.
SEHH2238 Lecture 13 33

SEHH2238 Computer Networking
􏰀 Web: HTTP
􏰁Non-persistent (1.0) vs. persistent (1.1)
􏰀 File Transfer Protocol: FTP
􏰁Control and Data connection separated
􏰀 Email: SMTP, POP, IMAP 􏰀 Domain Name: DNS
􏰁Recursive vs. iterative resolution 􏰀 Sockets: Address, API
SEHH2238 Lecture 12 34

SEHH2238 Computer Networking
References
􏰀 Video on DNS
􏰁 http://www.youtube.com/watch?v=ZBi8GCxk7NQ
􏰀 Video on IMAP vs POP
􏰁 http://www.youtube.com/watch?v=BK4ng6Gcits
􏰀 Revision Quiz
􏰁 http://highered.mheducation.com/sites/0073376221/stud
ent_view0/chapter26/quizzes.html
SEHH2238 Lecture 12 35

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com