
Application layer is the highest level of internet protocal layers.
1. Principles of Network Applications
Network applications are programs that are run on hosts and communicate over network.
1-1. Classic Structure 1: Client Server Architecture (C/S)
- Server offers service to the client,
- Client requests service from the server.
1-2. Classic Structure 2: P2P Architecture
- Example: Bit Torrent
- Peers acts as both the server and the client.
- A peer downloads one application data from another peer, then simultaneously upload the data to another peer.
- The more peers in demand for the files, the faster the process is.
- Self-scalability: new peers bring new service capacity, as well as new service demands.
- However, P2P architecture is a bit harder to manage than the C/S structure.
- Users may join and leave at anytime,
- so the P2P software needs to keep track of it.
1- 3. Application Requirements:

- For phone calls, data integrity is not so important,
- packet loss are still tolerable because we can ask to repeat what they said.
- Throughput can be important to movie streaming apps.
- Maybe not for movie downloading apps, because it can take as much as it wants and we can work on other things.
- Timing can be important for games (low latency)
- Security can be important for online shopping.
1-4. Application Layer Defines...:

- Open protocols means that it is openly accessible and implementable.
1-5. Transport Layer Protocols: TCP/UDP

- TCP when data should not be lost,
- UDP when data can be lost - like multimedia applications.
2. Web and HTTP
2-1. The Web?:
- Web is one of many applications in the internet.
2-2. HTTP:
- Language used by web server to communicate with clients and web server.

2-3. HTTP Over TCP

- On port 80.
- TCP Connection is requested first, then HTTP messages are exchanged. After successful transmission, connection is closed.
- HTTP determines what type of message to be sent, TCP determines how it is transmitted.

- t1-t0: transmission delay
- t2-t1: propagation delay
- The TCP connection requests are sent in packets.
- After successful HTTP transaction, the TCP connection is closed.
2-3-1. Timeline for Non-persistent HTTP Connection (http 1.0)


- The browser would initiate a TCP connection request to the server.
- Server accept the TCP connection request.
- Client sends HTTP request packet,
- Server sends back the requested HTML with HTTP response message attached to it.
- Client receives html file, parses it, then notices JPEG object.
- The connection is already closed, so the client does step 1-5 again for requesting JPEG object.
- One object per connection.
- HTTP 1.1 supports multiple objects transmission by not closing the TCP connection after every object transmitted like HTTP 1.0.

- RTT (Round Trip Time)
- 2 * RTT + file transmission time
2-4. Persistent HTTP

- HTTP 1.0 (b) is when HTTP requests for objects are sent back-to-back to decrease the time it takes to receive (pipelining).
- HTTP 1.1 (b) also pipelines so that after parsing the html files and noticing the objects, the http requests for objects are sent back-to-back.

- The first two lines of header lines are compulsory.
- keep-alive for HTTP 1.1.
- The last line is blank (\r\n)to indicate the end of header lines.

- format of htttp requests.
- cr: carriage return (returns to the start of the line)
- lf: line feed (pulls up to the next line)

- head asks server to get information about a document without retrieving the document itself.


- curl -I downloads only the header file.
- The status code is 301 because the requested objects moved from http to https.
Cookie

Conditional GET (If-modified-since)

- if there is no modified object, just use locally cached data for the requested objects.