# 2023-09-12

## Introduction

> **Summary**

> **keywords**\
> architecture, socket, protocols, criteria in choosing protocols, TCP, UDP

> **TODO**

> **HW**\
> What is the default port number of HTTPS?

> **Exercise**\*

> **Next time**\
> HTTP request messages.

***

## Recap

Application layer

## Paradigms of network apps

### Client-Server paradigm

* Server
  * Always on host
  * permanent IP address
  * need to think about scaling, security.
  * Could be hosting on standalone, or on data center
  * Data center hosting is superior in scaling and security.
* Clients
  * maybe intermittently connected.
  * could be dynamic IP address. (DHCP)
  * **DO NOT** communicate direct with each other.

Protocols in Client-Server paradigm\
: HTTP, IMAP, FTP

### Peer-to-Peer paradigm

> Every device is server, and a client.

* no always-on server.
* peers request service from other peers, provide service in return.
* **Self scalability** : new peers bring new service capacity, along with the demands.
* complex.

> We'll only focus on Client-server paradigms & HTTP.

***

## Process Communicating

### What is a Process?

> program running within a host

Client process, server process\
inter-process communications : process (hosted in different devices) communicating by exchanging data.

### Socket

> Points where two things are connected.

### How do you identify the socket?

> IP + Port

By IP address (device) + Port (process inside the device)\
ex. http servers run on port 80, https servers run on port 443

Analogy. Envelope.\
Family members share a same home address (IP), and we have a name (port)

UDP socket, TCP socket.

> Google didn't like any of the transport layer.\
> So they made QUIC(Quick UDP Internet Connections)

> A browser (also) runs on a prot number

### Protocol defines..

* Types of messages (Res, Req)
* message syntax (How fields are delineated)
* message semantics (meaning of info)
* rules (when and how processes send & respond to messages)

### Open Protocols

defined in RFCs, everyone can read and use\
allows for interoperability\
ex, HTTP, SMTP

There also are (not-open) proprietary protocols.

### Transport service

What criteria should we care when **choosing** transport service for an application??\
\* data integrity (making sure the files are completely transferred)\
\* Okay if you can tolerate the data loss (Ex. audio format file)\
\* timing (low delay)\
\* Okay if the service is not live-streaming\
\* throughput (bandwidth of edge..)\
\* Okay if service is elastic.

!\[\[../images/20230912135617.png]]

### Properties of TCP & UDP

|                         | TCP | UDP |
| ----------------------- | --- | --- |
| transport reliability   | Y   | N   |
| flow control            | Y   | N   |
| Conjestion control      | Y   | N   |
| **connection-oriented** | Y   | N   |

TCP Do not provide:\
depends on the bandwidth. Cannot change throughput by itself.\
timing, minimum throughput guarantee, security

UDP Do not provide :\
reliability, flow control, congestion, control, timeing, throughput guarantee, security, connection setup..

throughput is not guarantee by any Protocols in this Internet.\
Security is not supported by TCP & UDP\
TCP cares about lost packets. UDP doesn't.\
TCP is connection-oriented. We should open and close a connection.

Q. Why use UDP?

> **UDP is much faster. Header is smaller.** less overhead.

!\[\[../images/20230912135815.png]]

### Securing TCP

* TCP, UDP has no encryption
* cleartext. human-readable.

We use TLS (Transport Layer Security, Originally called SSL)\
\* There are TLS libraries you can use in application layer.

***

## Web, HTTP

The idea is "Sending meaningful objects through internet"

* URL : includes information about the target device & what you want

### HTTP

> Hypertext transfer protocol

* **application layer protocol**
* browser is the interpreter(of the HTTP packets) + displayer(of the object).

> **HTTP uses TCP**.**HTTP is stateless.** : state information is implemented by cookies.**HTTP nowadays (HTTP 1.1) are Persistent.** : 1 connection can be used for multiple objects sending. before closed. You choose how long, how many.

Non-persistent HTTP has high RTT (round trip time)\
\#todo : problems of Non-persistent HTTP
