程序代写代做代考 Java case study Discussion Session #4

Discussion Session #4
EE450: Computer Networks Topic: Network Applications (HTTP, SMTP & P2P)
1

Some network apps
e-mail/Text Messaging voice over IP web-based applications real-time video
Social Networking
Internet Search
P2P file sharing
multi-user network games
streaming stored video (YouTube, Hulu, Netflix)
conferencing cloud computing Etc…
2

Creating a network app
write programs that
 run on (different) end systems
 communicate over network
 e.g., web server software communicates with browser software
No need to write software for network-core devices
 network-core devices do not run user applications
 applications on end systems allows for rapid app development, propagation
application
transport
network
data link
physical
application
transport
network
data link
physical
application
transport
network
data link
physical
3

Processes communicating
client process: process that initiates communication
server process: process that waits to be contacted
process: program running within a host.
within same host, two processes communicate using inter-process communication (defined by OS).
processes in different hosts communicate by exchanging messages
aside: applications with P2P architectures have client processes & server processes
4

5

6

7

Web and HTTP
First, a review…
web page consists of objects
object can be HTML file, JPEG image, Java applet, audio file,…
web page consists of base HTML-file which includes several referenced objects
each object is addressable by a URL example URL:
www.someschool.edu/someDept/pic.gif
host name
path name
8

9

HTTP overview (continued)
Uses TCP:
 client initiates TCP connection (creates socket) toserver, port80
 server accepts TCP connection from client
 HTTP messages (application- layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server)
 TCP connection closed
HTTP is “stateless”
 server maintains no information about past client requests
aside
protocols that maintain “state”are complex!
 past history (state) must be maintained
 if server/client crashes, their views of “state”may be inconsistent, must be reconciled
10

11

Nonpersistent HTTP
suppose user enters URL:
www.someSchool.edu/someDepartment/home.index
(contains text, references to 10 jpeg images)
1a. HTTP client initiates TCP connection to HTTP server (process) at www.someSchool.edu on port 80
2. HTTP client sends HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants object someDepartment/home.index
time
1b. HTTP server at host www.someSchool.edu waiting for TCP connection at port 80. “accepts”connection, notifying client
3. HTTP server receives request message, forms response message containing requested object, and sends message into its socket
12

Nonpersistent HTTP (cont.)
time
5. HTTP client receives response message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects
6. Steps 1-5 repeated for each of 10 jpeg objects
4. HTTP server closes TCP connection.
13

Non-Persistent HTTP: Response time
definition of RTT: time for a small packet to travel from client to server and back.
response time:
one RTT to initiate TCP connection
one RTT for HTTP request and first few bytes of HTTP response to return
initiate TCP
connection
RTT
request file
RTT
file received
time
time to transmit file
time
file transmission time total = 2RTT+transmit time
14

Persistent HTTP
non-persistent HTTP issues:
 requires 2 RTTs per object  OS overhead for each TCP
connection
 browsers often open parallel TCP connections to fetch referenced objects
persistent HTTP
 server leaves connection open after sending response
 subsequent HTTP messages between same client/ server sent over open connection
 client sends requests as soon as it encounters a referenced object
 as little as one RTT for all the referenced objects
15

HTTP request message
two types of HTTP messages: request, response HTTP request message:
 ASCII (human-readable format)
carriage return character line-feed character
request line
(GET, POST, HEAD commands)
header lines
carriage return, line feed at start
of line indicates end of header lines
GET /index.html HTTP/1.1\r\n
Host: www-net.cs.umass.edu\r\n
User-Agent: Firefox/3.6.10\r\n
Accept: text/html,application/xhtml+xml\r\n Accept-Language: en-us,en;q=0.5\r\n Accept-Encoding: gzip,deflate\r\n Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n Keep-Alive: 115\r\n
Connection: keep-alive\r\n \r\n
16

HTTP response message
status line (protocol status code status phrase)
header lines
HTTP/1.1 200 OK\r\n
Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n Server: Apache/2.0.52 (CentOS)\r\n Last-Modified: Tue, 30 Oct 2007 17:00:02 GMT
\r\n
ETag: “17dc6-a5c-bf716880″\r\n Accept-Ranges: bytes\r\n Content-Length: 2652\r\n Keep-Alive: timeout=10, max=100\r\n Connection: Keep-Alive\r\n Content-Type: text/html;
charset=ISO-8859-1\r\n \r\n
data data data data data …
data, e.g., requested HTML file
17

HTTP response status codes
status code appears in 1st line in server->client response message.
some sample codes:
200 OK
 request succeeded, requested object later in this msg 301 Moved Permanently
 requested object moved, new location specified later in this msg (Location:)
400 Bad Request
 request msg not understood by server 404 Not Found
 requested document not found on this server 505 HTTP Version Not Supported
18

Trying out HTTP (client side) for yourself
1. Telnet to your favorite Web server:
telnet cis.poly.edu 80 opens TCP connection to port 80
(default HTTP server port) at cis.poly.edu.
anything typed in sent
to port 80 at cis.poly.edu
2. type in a GET HTTP request:
GET /~ross/ HTTP/1.1 Host: cis.poly.edu
by typing this in (hit carriage return twice), you send
this minimal (but complete) GET request to HTTP server
3. look at response message sent by HTTP server! (or use Wireshark!)
19

20

21

22

23

24


Variations of HTTP
Nonpersistent connections
• with serial connections
• with parallel connections
Persistent connections
• without pipelining
• with pipelining
Example: an HTML page with 2 objects (images)

25

Non-Persistent: Rough calculation for number of RTTS
Client
Web Page
Server
Image 1
Can we reduce the number of RTTS?
Image 2
Time delay in RTTs = 6
Delay due to connection request/handshake Delay Due to HTML Page Request
Delay Due to Object Request
26

Non-Persistent with Parallel Connections: Rough calculation
Client Server
Web page
Image1 & Image2
Time delay in RTTs = 4
Delay due to connection request/handshake Delay due to HTML page request
Delay due to object request
27

Persistent Connection without Pipelining: Rough calculation
Client Server
Web page
Image1 Image2
Time delay in RTTs = 4
Delay due to connection request/handshake Delay due to HTML page request
Delay due to object request
28

Persistent Connection with Pipelining: Rough calculation
Client Server
Web page
Image1 & Image2
Time delay in RTTs = 3
Delay due to connection request/handshake Delay due to HTML page request
Delay due to object request
29

Electronic Mail
Three major components:
user agent
SMTP SMTP
user agent
user agent
outgoing message queue
user mailbox
 user agents
 mail servers
 simple mail transfer protocol: SMTP
User Agent
 a.k.a. “mail reader”
 composing, editing, reading
mail messages
 e.g., Outlook, elm, Mozilla Thunderbird, iPhone mail client
 outgoing, incoming messages stored on server
mail server
SMTP
mail server
mail server
user agent
user agent
user agent
30

Electronic Mail: mail servers
Mail Servers
 mailbox contains incoming
messages for user
 message queue of outgoing (to be sent) mail messages
 SMTP protocol between mail servers to send email messages
 client: sending mail server
 “server”:receiving mail server
user agent
mail server
SMTP
SMTP
user agent
mail server
SMTP
mail server
user agent
user agent
user agent
user agent
31

Electronic Mail: SMTP [RFC 5321 ]
 uses TCP to reliably transfer email message from client to server, port 25
 direct transfer: sending server to receiving server  three phases of transfer
 handshaking (greeting)  transfer of messages  closure
 command/response interaction
 commands: ASCII text
 response: status code and phrase
messages must be in 7-bit ASCII
32

Scenario: Alice sends message to Bob
1) Alice uses UA to compose message and “to”
2) Alice’s UA sends message to her mail server; message placed in message queue
3) Client side of SMTP opens TCP connection with Bob’s mail server
4) SMTP client sends Alice’s message over the TCP connection
5) Bob’smail server places the message in Bob’s mailbox
6) Bob invokes his user agent to read message
1
user agent
2
mail server
user agent
mail
server 3
4
5
6
33

Try SMTP interaction for yourself:
telnet servername 25
see 220 reply from server
enter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands
above lets you send email without using email client (reader)
34

Mail access protocols
SMTP
sender’s mail server
SMTP
receiver’s mail server
The image cannot be displayed. Your compu ter may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then
insert itagain.
user agent
access protocol
 SMTP: delivery/storage to receiver’s server  mail access protocol: retrieval from server
 POP: Post Office Protocol [RFC 1939]
• authorization (agent <-->server) and download  IMAP: Internet Mail Access Protocol [RFC 3501]
• more features (more complex)
• manipulation of stored msgs on server  HTTP: gmail, Hotmail, Yahoo! Mail, etc.
Difference between POP & IMAP: https://help.aol.com/articles/what-is-the-difference-between-pop3- and-imap 235
user
agent

Pure P2P architecture
no always-on server arbitrary end systems
directly communicate
 peers are intermittently peer-peer connected and change IP addresses
Three topics:
 file distribution
 searching for information  case Study: Skype
36

File Distribution: Server-Client vs P2P
Question : How much time to distribute file from one server to N peers?
File, size F
d2
Network (with abundant bandwidth)
Server
us
dN uN
u1 d1 u2
us: server upload bandwidth
ui: peer i upload bandwidth
di: peer i download bandwidth
37

File distribution time: server-client
server sequentially sends N copies:
NF/us time
client i takes F/di time to download
Server
F
dN uN
ud 1 1
u2
d2
u
s
Network (with
abundant bandwidth)
Time to distribute F
to N clients using = dcs = max { NF/us, F/min(di) } client/server approach i
increases linearly in N (for large N)
238

File distribution time: P2P
Server
server must send one F copy: F/us time
client i takes F/di time to download
NF bits must be downloaded (aggregate)
u
s
u d u
1 1 2 d2
Network (with
abundant bandwidth)  fastest possible upload rate: us + ui
dN uN
dP2P = max { F/us, F/min(di)i, NF/(us + ui) }
39

Server-client vs. P2P: example
Client upload rate = u, F/u = 1 hour, us = 10u, dmin ≥ us
3.5 3 2.5 2 1.5 1 0.5 0
P2P Client-Server
0 5 10 15 20 25 30 35 N
40
Minimum Distribution Time

41

42

43