# RFC 1115
***==《欽定古今文獻集目錄堪用篇》==***
- ==作業 2020 A 1==
- ==考古 2020 A M==
- ==考古 2020 B M==
- 考古 2019 A M ?
- 考古 2018 A M
- 考古 2018 B M {=}
- ==考古 2018 A F==
***==《欽定助教語錄期中插座篇》==***
- ==**Socket Programming**==
- [**Tutorial**](https://github.com/davidleitw/socket)
- **Functions**
Include **`<sys/socket.h>`**
- [**socket()**](https://man7.org/linux/man-pages/man2/socket.2.html)
- Create an endpoint for communication
- [**bind()**](https://man7.org/linux/man-pages/man2/bind.2.html)
- Bind a name to a socket
- ==Attaches a local address to a socket.==
- [**listen()**](https://man7.org/linux/man-pages/man2/listen.2.html)
- Listen for connections on a socket
- ==**`backlog`**==
- 允許進入 queue 的最大連線數量
在 server 端還沒有 accept 之前,最多能允許幾個 socket 申請 connect
- The maximum length to which the queue of pending connections for `sockfd` may grow
- [**accept()**](https://man7.org/linux/man-pages/man2/accept.2.html)
- Accept a connection on a socket
- [**connect()**](https://man7.org/linux/man-pages/man2/connect.2.html)
- Initiate a connection on a socket
- [**recvfrom()**](https://man7.org/linux/man-pages/man2/recv.2.html)
- Receive a message from a socket
- [**sendto()**](https://man7.org/linux/man-pages/man2/send.2.html)
- Send a message on a socket
- [**close()**](https://man7.org/linux/man-pages/man2/close.2.html)
- Close a file descriptor
- ==**DNS Records**==
- **Format**: **`(name, value, type, ttl)`**
- **Hostname**: name of end-point
**Domain**: name of network
- **`type`: `A`**
- `name`: hostname
- `value`: IP address
- **`type`: `NS`**
- `name`: domain
- `value`: hostname of authoritative name server for this domain
- **`type`: `CNAME`**
- `name`: alias name for some “canonical” (the real) name
- `value`: canonical name
- **`type`: `MX`**
- `value`: name of mailserver associated with `name`
- ==**DNS**==
- Hostname to IP address translation
- **Distributed** (**hierarchical**) database
Application-layer protocol
- Root name servers
Top-level domain (TLD) servers
Authoritative DNS servers
Local (default) DNS name server
- **Caches** when learning mapping
Out-of-date perhaps
- Insert Record
- **DNS registrar**
- Create A and NS record
- Attack DNS
- **DDoS**
- Root servers
- TLD
- **Redirect attack**
- **Exploit DNS for DDoS**
- ==**DNS resolution**==
- **Iterated query**
- Contacted server replies with name of server to contact
- **Recursive query**
- Puts burden of name resolution on contacted name server
- Heavy load at upper levels of hierarchy
- ==**Applications use TCP or UDP**==
- **TCP**
- E-mail: **SMTP**
- Remote terminal access: **Telnet**
- Web: **HTTP**
- File transfer: **FTP**
- **TCP** or **UDP**
- Streaming multimedia: **HTTP**, **RTP**
- Internet telephony: **SIP**, **RTP**, proprietary (Skype)
- **UDP**
- **SNMP**
- Wiki:
- **TCP**
- **HTTP**, **HTTPS**, **FTP**, **POP3**, **SMTP**, **TELNET**, **SSH**
- **UDP**
- **BOOTP**, **NTP**, **DHCP**
- **TCP** and **UDP**
- **DNS**, **ECHO**, **SNMP**, **ARP**
---
:::spoiler Contents (LONG)
[TOC]
:::
---
## 作業 2020 A 1
### 1. Throughput
> **Throughput**: Bottleneck rate between sender and receiver
### 2. Transmitting and Propagating delay
> $\text{Transmission Delay} = \frac{L}{R}$
> $\text{Propagate Delay} = \frac{d}{s}$
### 3. Queuing delay
### 4. Total average response time
> $\text{Average Access Delay} = \frac{\Delta}{1 - \text{Miss Rate} \times \Delta\beta}$
> $\text{Total Average Response Time}$
> $= \text{Miss Rate} \times (\text{Average Access Delay} + \text{Average Internet Delay})$
### 5. Server sockets in UDP and TCP
> **TCP**: 1 + N
> **UDP**: 1
## 考古 2020 A M
### 1. Packet delay
1. Four sources
2. average longest delay
> 1. Nodal processing delay
> Queuing delay
> Transmission delay
> Propagation delay
> 2. Queuing delay
### 2. TCP/IP model layers (des)
1. TCP/IP model layers
2. TCP/IP model & OSI model
> 1. App, trans, net, data link, phys
> 2. App
### 3. Security (des)
1. DDoS
2. IP spoofing
3. Packet sniffer
### 4. Packet (des)
1. Terms of packet
2. Encapsulation & decapsulation
> 1. Segment, datagram, frame
> 2. ...
### 5. Bandwidth-delay product calculate
> Bandwidth-delay product = $R \times \frac{d}{s}$
### 6. DNS
1. Iterated query DNS name resolution
2. Recursive query DNS name resolution
3. Pros & cons
> 3. burden
### 7. DNS resource record format
> A: name = hostname; value = IP address
> NS: name = domain; value = name of the authoritative name server of this domain
<!-- ### 8. CIDR
1. Subnetwork
2. Number of IP addresses -->
### 9. Full name (des)
1. DNS
2. HTTP
3. CDN
4. DASH
> 1. Domain name system: hostname to IP address translation
> 2. Hypertext transfer protocol: ==TODO==
> 3. Content distribution network:
> 4. Dynamic, adaptive streaming over HTTP:
### 10. TCP Socket programming flowchart
> - Server:
> - socket(), bind(), listen(), accept(), recvfrom(), sendto(), close()
> - Client:
> - socket(), connect(), sendto(), recvfrom(), close()
### 11. TCP socket identified (#4)
> [IP address | Port number] of [Source | Destinaiton]
### 12. Proxy server / web caches (#2)
> 1. Reduce response time
> 2. Reduce traffic on links
### 13. Client-server distribution & P2P distribution
- Min distribution time
> - **Client-server**:
> $D_{\text{C-S}} \ge \max{\{N\frac{F}{u_s},\ \frac{F}{d_{\text{min}}}\}}$
> - **P2P**:
> $D_{\text{P2P}} \ge \max{\{\frac{F}{u_s},\ \frac{F}{d_{\text{min}}},\ N\frac{F}{(u_s + \sum{u_i})}\}}$
### 14. End-to-end delay
> (10 + 1 + 1) + (1 * 10)
### 15. Average queuing delay
> 等差
## 考古 2020 B M
### 1. TCP/IP model layers {=}
### 2. Packet delay {=}
### 3. Bandwidth-delay product calculate {=}
### 4. IP spoofing {=}
<!-- ### 5. Go-back-n & Selective-repeat -->
### 6. Full name (des)
1. DNS {=}
2. HTTP {=}
3. CDN {=}
4. OTT
> 4. Over-the-top
### 7. DNS resource record format {=}
<!-- ### 8. Control plane & data plane (#2) -->
<!-- ### 9. CIDR {=} -->
## 考古 2018 A F
### 2. TCP retransmission
### 14. Traceroute program
### B.1.1. Packet loss
### B.1.2. Internet
### B.1.3. Web object Addressing
### B.1.4. P2P model pros
### B.1.5. DNS server hierarchy
### B.1.6. UDP usage
### B.1.7. HTTP methods
### B.1.8. HTTP condition GET
### B.1.9. DNS & HTTP & Proxy & CDN
### B.1.10. Cookies usage
### B.2. Packet delay {=}
### B.3. RDT 3.0