Part II Application Layer
Web caches (proxy server) client origin server client origin server Application Layer
More about Web caching why Web caching? Application Layer
If-modified-since: <date> If-modified-since: <date> Conditional GET client server Goal: don’t send object if cache has up-to-date cached version HTTP request msg If-modified-since: <date> object not modified before <date> HTTP response HTTP/1.0 304 Not Modified 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.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Origin: http://example.com Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 13 Application Layer
Servrer Response HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-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: the file transfer protocol user interface client FTP server user at host remote file system local file system ftp: RFC 959 https://tools.ietf.org/html/rfc959 ftp server: port 21 Application Layer
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
FTP commands, responses sample commands: sample return codes 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
Electronic mail User Agent Three major components: outgoing user mailbox outgoing message queue Three major components: User Agent mail server user agent Application Layer
Electronic mail: mail servers mailbox message queue SMTP protocol user agent mail server user agent SMTP mail server user agent SMTP SMTP user agent mail server user agent user agent Application Layer
Electronic Mail: SMTP [RFC 2821] 1 ) 2) 3) 4) Application Layer
Scenario: Alice sends message to Bob user agent user agent mail server mail server 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
SMTP: final words comparison with HTTP & FTP: Application Layer
Mail message format SMTP: header RFC 822: : header lines, e.g., different Body: header blank line body Application Layer
Mail access protocols SMTP: delivery/storage to receiver’s server user agent SMTP SMTP user agent sender’s mail server (e.g., POP, IMAP) receiver’s mail server SMTP: delivery/storage to receiver’s server mail access protocol: retrieval from server POP: IMAP: HTTP: Application Layer
POP3 protocol authorization phase transaction phase, client: C: list S: +OK POP3 server ready C: user bob S: +OK C: pass hungry S: +OK user successfully logged on authorization phase client commands: : . server responses transaction phase, client: C: list S: 1 498 S: 2 912 S: . C: retr 1 S: <message 1 contents> C: dele 1 C: retr 2 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