300 likes | 316 Views
Part II. Web caches (proxy server). proxy server. client. origin server. client. origin server. why Web caching?. More about Web caching. Goal: don’t send object if cache has up-to-date cached version. HTTP response HTTP/1.0 304 Not Modified. Conditional GET. server. client.
E N D
Part II Application Layer
Web caches (proxy server) proxy server client origin server client origin server Application Layer
why Web caching? More about Web caching Application Layer
Goal: don’t send object if cache has up-to-date cached version HTTP response HTTP/1.0 304 Not Modified Conditional GET server client HTTP request msg If-modified-since: <date> object not modified before <date> HTTP request msg If-modified-since: <date> object modified after <date> HTTP response HTTP/1.0 200 OK <data> Application Layer
HTTP • Response response protocol but how can the server push updates to the client • Example instant messages • Does the client need to constantly resquest/ poll • Do you have a message for me • Answers full duplex websockets Application Layer
WebSocket's • Full duplex communication • Allows the webserver to send content without first being requested • Kind of new standardized in RFC 6455 in 2011 https://tools.ietf.org/html/rfc6455 Application Layer
Request a socket GET /chat HTTP/1.1 Host: server.example.comUpgrade: websocket Connection: Upgrade Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Origin: http://example.com Sec-WebSocket-Protocol: chat, superchatSec-WebSocket-Version: 13 Application Layer
Servrer Response HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: UpgradeSec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Sec-WebSocket-Protocol: chat dGhlIHNhbXBsZSBub25jZQ== + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" SHA1 Hash Base 64 encoding s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Application Layer
Subsequent Messages • Don’t follow frames/packets don’t follow standard framing: • There are 16 frame times 6 are use and 10 are reverse for the future. • Binary • Text • etc Application Layer
JavaScript example of WebSocket Application Layer
JavaScript webrequest Application Layer
Chapter 2: outline 2.1 principles of network applications app architectures app requirements 2.2 Web and HTTP 2.3 FTP 2.4 electronic mail SMTP, POP3, IMAP 2.5 DNS 2.6 P2P applications 2.7 socket programming with UDP 2.8 socket programming with TCP Application Layer
FTP user interface FTP client FTP server FTP: the file transfer protocol user at host remote file system local file system • ftp: RFC 959 https://tools.ietf.org/html/rfc959 • ftp server: port 21 Application Layer
FTP: separate control, data connections TCP control connection, server port 21 TCP data connection, server port 20 FTP client FTP server Application Layer
sample commands: sample return codes FTP commands, responses Application Layer
Chapter 2: outline 2.1 principles of network applications app architectures app requirements 2.2 Web and HTTP 2.3 FTP 2.4 electronic mail SMTP, POP3, IMAP 2.5 DNS 2.6 P2P applications 2.7 socket programming with UDP 2.8 socket programming with TCP Application Layer
A Story: The Inventor of email • Still Alive • Shiva Ayyadurai Application Layer
Three major components: User Agent user agent user agent user agent user agent user agent user agent mail server mail server mail server outgoing message queue user mailbox Electronic mail Application Layer
mail servers: mailbox message queue SMTP protocol user agent user agent user agent user agent user agent user agent SMTP SMTP SMTP mail server mail server mail server Electronic mail: mail servers Application Layer
1 ) 2) 3) 4) Electronic Mail: SMTP [RFC 2821] Application Layer
user agent user agent mail server mail server Scenario: Alice sends message to Bob Alice’s mail server Bob’s mail server Application Layer
Sample SMTP interaction S: 220 hamburger.edu C: HELO crepes.fr S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: <alice@crepes.fr> S: 250 alice@crepes.fr... Sender ok C: RCPT TO: <bob@hamburger.edu> S: 250 bob@hamburger.edu ... Recipient ok C: DATA S: 354 Enter mail, end with "." on a line by itself C: Do you like ketchup? C: How about pickles? C: . S: 250 Message accepted for delivery C: QUIT S: 221 hamburger.edu closing connection Application Layer
comparison with HTTP & FTP: SMTP: final words Application Layer
SMTP: RFC 822: : header lines, e.g., different Body: Mail message format header blank line body Application Layer
SMTP: delivery/storage to receiver’s server mail access protocol: retrieval from server POP: IMAP: HTTP: user agent user agent sender’s mail server Mail access protocols mail access protocol SMTP SMTP (e.g., POP, IMAP) receiver’s mail server Application Layer
authorization phase client commands: : . server responses : : transaction phase,client: : : : : POP3 protocol S: +OK POP3 server ready C: user bob S: +OK C: pass hungry S: +OK user successfully logged on C: list S: 1 498 S: 2 912 S: . C: retr 1 S: <message 1 contents> S: . C: dele 1 C: retr 2 S: <message 1 contents> S: . C: dele 2 C: quit S: +OK POP3 server signing off Application Layer
Application Layer Protocols IOT • MQTT: • Message Queuing Telemetry Transport • Application layer protocol implement ontop of TCP/IP • Why not UDP • Small footprint • Andy Stanford-Clark • First version of the protocol in 1999 (IBM) Application Layer
Why is MQTT interesting • This maybe one of the protocols that power the internet of things • Amazon has added MQTT support AWS and freeRTOS • https://docs.aws.amazon.com/iot/latest/developerguide/protocols.html http://mqtt.org/ Application Layer
How does MQTT work • Topics • There is no need to configure a topic, publishing on it is enough. • Topics are treated as a hierarchy • Temperature/roof Application Layer