计算机网络层

计算机网络 (网络层,链路层) 归纳提纲 适合复习《自定而下的方法》时使用_anditty的博客-CSDN博客 

https://blog.csdn.net/qq_43210583/article/details/115290976?spm=1001.2014.3001.5501

 

第四章 网络层 (data plane)
4.1 网络层概览
在端中是第三层,在router里是最高层
在send side做封装segment into datagrams
router通过IP报文投决定如何去传输
两个重要的网络层函数

forwarding(data plane):把packets从router的input转移到合适的output
local, per-router
routing(control plane):决定route的选择
network-wide,·决定要经过哪些router
两种方式
traditional:由每一个router自己决定
control plane:去计算出一个forwarding table
data plane:按照这个表格去转发
software-defined(SDN):服务器决定
control plane:其中每个router会收集信息,让server去决定forwarding table
Link layer保证不了任何事情,除了best effort

4.2 Router
Input port


其中网络层需要做的事情有 使用报文头按照table做转发
两种转发方式:

destination-based forwarding:根据目的IP


longest prefix matching:按照匹配到的最长的目的IP去匹配

generalized:根据headre里的其他信息

三种不同类型的switching fabrics


output


也需要一个buffer,防止丢包,但是如果队列满了也会丢datagram

排队方式:选择下一个要发的datagram
FIFO
如果队列满了怎么办?
tail drop
priority drop
random
priority
维护一个高优先和低优先队列,优先选择高优先队列发
RR round robin
高优先和低优先交替发
Weighted Fair Queuing (WFQ):
按照某个weight在不同队列中选择的发
4.3 IP
1.IP的 fragmentation和reassembly
MTU(max transfer size):最大的frame(分片)size

例子:

2.IPv4 addressing
subnet:位于相同网络号的一组网络,不需要router可以physically的连接
例子:下图有六个子网


addressing方式: CIDR: Classless InterDomain Routing


如何获得IP地址?

hard-code 系统管理员定义
DHCP: Dynamic Host Configuration Protocol
一个应用层协议,在UDP之上(udp封装在IP之上)
四个步骤
DHCP discover
DHCP offer
DHCP request
DHCP ack
除了iP还能返回:
client下一个router地址
DNS的name和IP
子网掩码
层次编址

ISP从ICANN: Internet Corporation for Assigned Names and Numbers获得地址区间

NAT (network address translation)
不需要ISP提供的地址范围:所有设备只需一个IP地址
可以改变本地网络中设备的地址,而不需要通知外界
可以改变ISP,而不需要改变本地网络中设备的地址
本地网络中的设备无法明确寻址,外界可以看到(安全上的优势)
NAT要做什么
发出数据报:将每个发出的数据报的(源IP地址,端口号)替换为(NAT IP地址,新端口号远程客户端/服务器将使用(NAT IP地址,新端口号)作为目标地址进行响应。

记住(在NAT翻译表中)每一个(源IP地址,端口号)到(NAT IP地址,新端口号)的翻译对。


传入数据报:将每个传入数据报的 dest 字段中的 (NAT IP 地址,新端口号) 替换为存储在 NAT 表中的相应 (源 IP 地址,端口号)。

4.IPv6
对比v4

地址更多
取消checksum
用next header代替options
ICMPv6
tunneling
把v6作为v4的payload


一个例子(重点)


4.4 Generalized Forward and SDN
结构:


Openflow
pattern:匹配数据包头中的数值。
action:对于匹配的数据包:丢弃、转发、修改、匹配的数据包或发送匹配的数据包到控制器。
priority:消除重叠pattern的歧义。
counters。#bytes和#packets
因此,我们可以非常自由的用软件去定义router的功能:

 

 

第五章 网络层 (control plane)
两种control plane:

Per-router control plane:每个router自己用算法去算出table来
Logically centralized control plane:由控制器去统一控制多个CA
5.1 routing协议
用一张graph去描述网络;

怎么定义cost? 找最大用倒数,找最小不用倒数

cost could always be 1, or inversely related to bandwidth, or inversely related to congestion
算法的分类

global or decentralized
global:所有router有完整的信息
decentralized:router只知道一部分邻居的信息
static or dymantic
1. link state
Dijkstra


重点是之后还要根据这个图画出每个router的table呢:


算法的复杂度是O(n^2)

2. distance vector
Bellman-Ford equation (dynamic programming)


5.2 intra-AS routing in the Internet: OSPF
定义AS

把router聚合成小的区域:autonomous systems (AS)
Gateway router: at “edge” of its own AS, has link(s) to router(s) in other AS
Interior router: no link to other AS
intra-AS routing (Interior gateway protocol, IGP)

同一个AS的router必须run相同的routing
常见的协议
RIP(distance)
OSPF(link state)
IS-IS 和OSPF本质上一样
IGRP
inter-AS routing(boarder gateway protocol, BGP)

gateway router像intra—AS那样运行inter-AS routing
还必须把这个信息告诉AS里的所有router
OSPF

基于IP协议(不是TCP或者UDP)

安全性:所有OSPF报文经过认证(防止恶意入侵)。

允许多条同价路径(RIP中只有一条路径)。

集成的单播和多播支持。

多播OSPF(MOSPF)使用与OSPF相同的拓扑数据库。
Hierarchical OSPF


两层结构,只在area中做link-state advertisements
area border routers: “summarize” distances to nets in own area, advertise to other Area Border routers.
backbone routers: run OSPF routing limited to backbone.
boundary routers: connect to other AS’es.
5.4 routing among the ISPs:BGP
BGP提供两个功能:

获得周围的AS的reachability信息:eBGP
把这些信息传给AS的内部router:iBGP
根据可到达性信息和策略确定通往其他网络的 "好 "路线
基础知识

两个BGP router通过TCP交流信息,终点(NEXT-HOP)作为前缀加到路线(AS-PATH)上去


但是我们会根据policy,决定去接受或者拒绝这条路径,也可以决定是否去advertise这条路径(各怀鬼胎)

有时我们会收到多条到某个点的路径

.本地偏好值属性:策略决定。(例如一般联通不会把他的某条路径告诉移动,这样移动就能不用花费走这条路)
最短的AS-PATH
选择到达自己网关最近的router:烫手山芋路由。
补充标准
之后我们要去生成forward table


5.5 The SDN control plane


5.6 ICMP Internet Control Message Protocol
used by hosts & routers to communicate network level information
carried in IP datagrams
5.7 Network management and SNMP (simple network management)


SNMP


第六章 连接层和LANs
术语:

host and routers:node
links
frame
server

rdt between nodes:为什么要同时具备链路级和终端可靠性?因为链路上可能发生的错误导致重传代价大
framing,link access
flow control
error detection and correction
全双工和半双工
6.2 error
二维检测

CRC

6.3 multiple access protocols
两种类型的link

point-to-point
broadcast(share wire or medium):802.11,HFC
目标:

when one node wants to transmit, it can send at rate R.
当M个节点要传输时,每个节点可以以平均速率R/M发送。
fully decentralized:
没有特别的节点来协调传输
时钟、槽位不同步
简单
三类MAC协议

channel partitioning (DMA division multiple access)

TDMA
FDMA:划分channel
CDMA
random access

slotted ALOHA:完全随机,效率差0.37
ALOHA:更随机 0.18
CSMA:在传输之前线监听,空闲才传输,但是还是又可能有碰撞
CSMA/CD(只适合有线网络 Ethernet):
NIC收到frame
NIC发现信道空闲去发包
如果NIC发现了另一个人也在传,那么立即停止
NIC开始等待,在m次碰撞后,等待的时间从{0,1,2, …, 2^m-1}中选择,NIC选择K*512bits的时间,然后回到步骤2(binary exponential bakkoff)
CSMA/CA(802.11)
taking turns

polling:
Masetr去按照顺序邀请一些nodes去传输,如果有就传polling overhead,latency,single point of failure (master)
token passing:


polling overhead,latency,single point of failure (master)

6.4 LANs
1.ARP address resolution protocol
Mac地址(LAN address)是48bit的
每个node会维护一张table:


ARP会发送一个目的地MAC全是F的包去查询,所有的node都会接收到这个包,然后对应的nodeB,会把自己的IP信息send回去,A会保存这个信息直到超时.

ARP被包含在IP中

一个例子:

 


2.Ethernet
局域有线网络技术
物理拓扑:


connectionless
unreliable
CSMA/CD
802.3 Ethernet standards
3.switches
store, forward Ethernet frames
CSMA/CD
transparent
plug-and-play, self-learning
每个switch有一个swtich table,记录Mac地址,interface,TTL;
Switch通过记录来者的各项信息维持这个转发表,当switch收到一个包不知道发给谁的时候,他会发给周围所有人,看谁接受了,记录下来.

switch vs routers
router是网络层的 vs switch是link层的设备
routers使用routing 算法和ip address vs switch使用flooding,learning,MAC address
4.vLAN Virtual Local Area Network
port-based VLAN
traffic isolation:只能同一个vlan交流
dynamic membership
forwarding between VLANS: done via routing
MAC-based VLAN
trunk port:


6.6 data center
multiple applications, each serving massive numbers of clients
managing/balancing load, avoiding processing, networking, data bottlenecks
load balancer: application-layer routing
————————————————
版权声明:本文为CSDN博主「anditty」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_43210583/article/details/115290976

posted @ 2021-04-14 08:59  常给自己加个油  阅读(323)  评论(0编辑  收藏  举报