jasperzhong / cs-notes

CS认知体系
6 stars 0 forks source link

Udacity | Computer Networking #6

Open jasperzhong opened 3 years ago

jasperzhong commented 3 years ago

https://www.udacity.com/course/computer-networking--ud436

jasperzhong commented 3 years ago

Lesson 2: architecture and principles

problems of today's Internet

  1. running out of ipv4
  2. congestion control: 动态范围不够
  3. routing: BGP算法不够安全,很难收敛..
  4. security: 安全问题
  5. denied of service.

要解决这些问题需要对basic infrastructure有大改动. 后面提到的SDN能解决上述问题.

Internet Design Principles

来自这篇paper: The Design Philosophy of the DARPA Internet Protocols. 1988.

fundamental goal: multiplexed utilization of existing interconnected networks. 这里面有两个重点:

  1. sharing: packet switching
  2. interconnection: narrow waist

Packet switching

所有packet共享网络资源. 提供best effort服务. 缺点是这个shared resource会有delay. image

对比的是电话那种circuit switching方式, 有一条dedicated path.

Narrow waist

说的是IP层. 所有internet device都必须有IP层,也叫network layer. IP层上下层都有很多协议,但IP stack只有一个. goal: interconnect many existing networks, hide underlying technology from applications.

image

Other goals

而这篇paper没有提到:

end-to-end argument

这是篇重要的paper. 1981.

The function in question can completely and correctly be implemented only with the knowledge and help of the application standing at the end points of the communication system. Therefore, providing that questioned function as a feature of the communication system itself is not possible. (Sometimes an incomplete version of the function provided by the communication system may be useful as a performance enhancement.)

summary: Dumb network, intelligent endpoints

说实话,这段话没怎么看懂. 这里说的end指的是协议的最上层,一般是应用层. 知乎上有一篇解释文章: https://zhuanlan.zhihu.com/p/55311553

这个argument有一些violations: NAT, VPN, TCP splitting...

NAT

network address translation. 就是只有一个public ip,但是可以在内部网络分配很多private ip. 通过转换表实现,用端口对应机器.

image

NAT violates end-to-end argument.

jasperzhong commented 3 years ago

Lesson 3: Switching

ARP: address resolution protocol

LAN内p2p发送消息需要知道对方的MAC address. 但一般只知道ip地址,而不知道MAC地址,所以需要ARP协议来自动获得MAC地址. 每个网卡都有一个唯一的MAC地址. ff:ff:ff:ff:ff:ff是广播地址.

image

ARP原理:广播询问某个ip是谁的消息. 某个机器收到消息后发现是自己,就回复自己的MAC address. 收到这个MAC address后记录在ARP Table.

image

有了MAC address后,在数据链路层的包上填写src/dst MAC address. image

Hub

最简单连接LAN的方式就是用Hub,其特点是收到消息后会广播消息.

image

这样会导致

这种方式已经淘汰.

Switch: Traffic Isolation

实现转发功能. 需要switch table: 把MAC地址映射到port. 其实就是记录已经接收的packet来自于哪个端口. 如果表中找不到记录,就flooding.

image

但由于还是有broadcast. 如果拓扑中有环就会有问题.

对比switch和router:

switch的主要缺点是broadcast. 因为spanning tree topology和ARP queries的网络负载高.

Buffer Size

一个rule of thumb是Buffer size = 2 T C. T是RTT, C是带宽.

后面讲TCP的buffer size有点超出我的知识范围了...

TCP flow control:

Flow control: limits the rate a sender transfers data to guarantee reliable delivery. The receiver continually hints the sender on how much data can be received (controlled by the sliding window). When the receiving host's buffer fills, the next acknowledgment contains a 0 in the window size, to stop transfer and allow the data in the buffer to be processed.

注意TCP header有一个window size字段. 另外TCP还有window scaling option. 默认的max window size是65536(因为只有16Bytes).

TCP congestion control算法叫做AIMD (additive-increase/multiplicative-decrease).

The approach taken is to increase the transmission rate (window size), probing for usable bandwidth, until loss occurs.

image

rate = Window size / RTT.

大概意思是出现congestion的时候. Rate = W / (RTT + B / C) . B是buffer size. C是bandwidth. B / C是 queuing delay. 然后我们希望congestion前后的sender rate是一样的. 最后得到d的 B还是等于 2TC.

image

最后说了实际中由于有很多sender,sender是不同步的,所以出现的峰值是比较平滑的. 最后结论是所需要的是 2TC / sqrt(n). n是flow数量.


TCP - segment IP - datagram data link - frame

jasperzhong commented 3 years ago

Routing

From Cloudflare:

The Internet is a network of networks*, and autonomous systems are the big networks that make up the Internet. More specifically, an autonomous system (AS) is a large network or group of networks that has a unified routing policy. Every computer or device that connects to the Internet is connected to an AS.

image

https://www.cloudflare.com/learning/network-layer/what-is-an-autonomous-system/

Autonomous Systems (AS) 自治系统

Intra-AS Topology

AS一般包括

routing: where to forward messages

内部网关协议1 —— Distance Vector Routing

距离向量路由协议

problem: count to infinity..就是如果一条链路延迟很大(甚至断了),那么这个表会更新很缓慢. solution: poison reverse. wiki上有不错的解释. https://en.wikipedia.org/wiki/Split_horizon_route_advertisement

Example: routing information protocol (RIP) 路由信息协议

内部网关协议2——Link-State routing

目前用的更广. 每个node把自己的network map发给其他所有node. 然后每个node计算到其他所有点的最短路径. 用dijkstrta算法.

典型代表:

缺点是复杂度太高 O(N^3). N是节点数量.

应对办法是hierarchy,分成几个area. area内部算最短路径, area与area直接算最短路径. 所以可以看作是2-level的最短路径. 妙啊.

边界网关协议 —— BGP (border gateway protocol)

需要理解几个东西