网络技术 - Q&A
网络技术以前有学过,现在要做作业了,但好多都忘记了,不过这个东西可以查RFC文档的,所以在此做一个记录吧。
其实吧,关于网络技术的很多知识描述特别多,但我们可以看英语,因为这些描述,比如思科的,华为的培训等都是通过翻译RFC文档来的,所以不管如何描述定义,意思都差不多,我们可以直接看RFC。
还有一点,不要太过于纠结术语,就像传输层,你可以叫运输层,但英文就是Transport layer。
1.试简单说明系列协议的作用
a IP协议
互联网协议实现了两个基本功能:寻址和分片
RFC:https://tools.ietf.org/html/rfc791
1.1. Motivation
The Internet Protocol is designed for use in interconnected systems of
packet-switched computer communication networks. Such a system has
been called a “catenet” [1]. The internet protocol provides for
transmitting blocks of data called datagrams from sources to
destinations, where sources and destinations are hosts identified by
fixed length addresses. The internet protocol also provides for
fragmentation and reassembly of long datagrams, if necessary, for
transmission through “small packet” networks.
1.2. Scope
The internet protocol is specifically limited in scope to provide the
functions necessary to deliver a package of bits (an internet
datagram) from a source to a destination over an interconnected system
of networks. There are no mechanisms to augment end-to-end data
reliability, flow control, sequencing, or other services commonly
found in host-to-host protocols. The internet protocol can capitalize
on the services of its supporting networks to provide various types
and qualities of service.
1.3. Interfaces
This protocol is called on by host-to-host protocols in an internet
environment. This protocol calls on local network protocols to carry
the internet datagram to the next gateway or destination host.
For example, a TCP module would call on the internet module to take a
TCP segment (including the TCP header and user data) as the data
portion of an internet datagram. The TCP module would provide the
addresses and other parameters in the internet header to the internet
module as arguments of the call. The internet module would then
create an internet datagram and call on the local network interface to
transmit the internet datagram.
In the ARPANET case, for example, the internet module would call on a
Internet Protocol
Introduction
local net module which would add the 1822 leader [2] to the internet
datagram creating an ARPANET message to transmit to the IMP. The
ARPANET address would be derived from the internet address by the
local network interface and would be the address of some host in the
ARPANET, that host might be a gateway to other networks.
1.4. Operation
The internet protocol implements two basic functions: addressing and
fragmentation.(IP协议两个最基本的功能,寻址和分片)
The internet modules use the addresses carried in the internet header
to transmit internet datagrams toward their destinations. The
selection of a path for transmission is called routing.
The internet modules use fields in the internet header to fragment and
reassemble internet datagrams when necessary for transmission through
“small packet” networks.
The model of operation is that an internet module resides in each host
engaged in internet communication and in each gateway that
interconnects networks. These modules share common rules for
interpreting address fields and for fragmenting and assembling
internet datagrams. In addition, these modules (especially in
gateways) have procedures for making routing decisions and other
functions.
The internet protocol treats each internet datagram as an independent
entity unrelated to any other internet datagram. There are no
connections or logical circuits (virtual or otherwise).
The internet protocol uses four key mechanisms in providing its
service: Type of Service, Time to Live, Options, and Header Checksum.
The Type of Service is used to indicate the quality of the service
desired. The type of service is an abstract or generalized set of
parameters which characterize the service choices provided in the
networks that make up the internet. This type of service indication
is to be used by gateways to select the actual transmission parameters
for a particular network, the network to be used for the next hop, or
the next gateway when routing an internet datagram.
The Time to Live is an indication of an upper bound on the lifetime of
an internet datagram. It is set by the sender of the datagram and
reduced at the points along the route where it is processed. If the
time to live reaches zero before the internet datagram reaches its
destination, the internet datagram is destroyed. The time to live can
be thought of as a self destruct time limit.
b ARP协议
ip = > mac — — 将网络层协议地址转换为48位以太网地址以在以太网硬件基础上传输
RFC:https://tools.ietf.org/html/rfc826
c RARP协议
mac = > ip 允许局域网的物理机器从网关服务器的 ARP 表或者缓存上请求其 IP 地址
RFC:https://tools.ietf.org/html/rfc903
I. Introduction
Network hosts such as diskless workstations frequently do not know
their protocol addresses when booted; they often know only their
hardware interface addresses. To communicate using higher-level
protocols like IP, they must discover their protocol address from
some external source. Our problem is that there is no standard
mechanism for doing so.
Plummer’s “Address Resolution Protocol” (ARP) [1] is designed to
solve a complementary problem, resolving a host’s hardware address
given its protocol address. This RFC proposes a “Reverse Address
Resolution Protocol” (RARP). As with ARP, we assume a broadcast
medium, such as Ethernet.
II. Design Considerations
The following considerations guided our design of the RARP protocol.
A. ARP and RARP are different operations. ARP assumes that every
host knows the mapping between its own hardware address and protocol
address(es). Information gathered about other hosts is accumulated
in a small cache. All hosts are equal in status; there is no
distinction between clients and servers.
On the other hand, RARP requires one or more server hosts to maintain
a database of mappings from hardware address to protocol address and
respond to requests from client hosts.
以下注意事项指导了我们对RARP协议的设计。 答:ARP和RARP是不同的操作。 ARP假定每个主机都知道其自己的硬件地址和协议地址之间的映射。 收集的有关其他主机的信息将存储在一个小的缓存中。 所有主机的状态相同; 客户端和服务器之间没有区别。 另一方面,RARP要求一个或多个服务器主机维护一个从硬件地址到协议地址的映射数据库,并响应来自客户端主机的请求。
d ICMP协议
差错检测
RFC:https://tools.ietf.org/rfc/rfc792
ICMP实际上是IP的组成部分,并且必须由每个IP模块来实现
提供有关通信环境中问题的反馈
ICMP差错报告报文共有5种
1> 终点不可达:终点不可达分为:网络不可达,主机不可达,协议不可达,端口不可达,需要分片但DF比特已置为1,以及源路由失败等六种情况,其代码字段分别置为0至5。当出现以上六种情况时就向源站发送终点不可达报文。
说明:
端口不可达:UDP的规则之一是:如果收到UDP数据报而且目的端口与某个正在使用的进程不相符,那么UDP返回一个ICMP不可达报文。
2> 源站抑制:当路由器或主机由于拥塞而丢弃数据报时,就向源站发送源站抑制报文,使源站知道应当将数据报的发送速率放慢。
3> 时间超过:当路由器收到生存时间为零的数据报时,除丢弃该数据报外,还要向源站发送时间超过报文。当目的站在预先规定的时间内不能收到一个数据报的全部数据报片时,就将已收到的数据报片都丢弃,并向源站发送时间超过报文。
4> 参数问题:当路由器或目的主机收到的数据报的首部中的字段的值不正确时,就丢弃该数据报,并向源站发送参数问题报文。
5> 改变路由(重定向)路由器将改变路由报文发送给主机,让主机知道下次应将数据报发送给另外的路由器。
说明:
以下几种情况都不会导致产生ICMP差错报文
1>ICMP差错报文(但是,ICMP查询报文可能会产生ICMP差错报文)
2>目的地址是广播地址或多播地址的IP数据报
3>作为链路层广播的数据报
4>不是IP分片的第一片
5>源地址不是单个主机的数据报。即源地址不能为零地址、环回地址、广播地址或多播地址。
这些规则是为了防止过去允许ICMP差错报文对广播分组响应所带来的广播风暴。
2.所有的ICMP差错报告报文中的数据字段都具有同样的格式。将收到的需要进行差错报告IP数据报的首部和数据字段的前8个字节提取出来,作为ICMP报文的数据字段。再加上响应的ICMP差错报告报文的前8个字节,就构成了ICMP差错报告报文。提取收到的数据报的数据字段的前8个字节是为了得到运输层的端口号(对于TCP和UDP)以及运输层报文的发送序号(对于TCP)。
2.IP地址的分类、表示及特点?
a 分类
IP地址分类(A类 B类 C类 D类 E类)
b 表示
以10进制表示
A:0.0.0.0-126.255.255.255
B:128.0.0.0-191.254.255.255
C:192.0.0.0-223.255.255.255
D:224.0.0.0-239.255.255.255
E:240.0.0.0-247.255.255.255
c 特点
每个IP都是网络地址+主机地址构成
IP地址就是标志着一个机器(比如终端或是路由器)和一条链路之间的接口。
分配的网络号平等
3.IP地址问答
a Subnet Mask 255.255.255.0代表?
代表有254个可用IP。一个广播地址,一个网络地址。
b Subnet Mask 255.255.255.248能够连接多少台主机?
6台
c 一个A类网络和一个B类网络的子网号分别为16个1和8个1的子网掩码区别?
子网掩码相同,均为24位,255.255.255.0/24;但子网数目不同。
16位子网号的A类网络有2^16 - 2 = 65534个子网(除去全0全1的子网号);
8位子网号的B类网络有2^8 - 2 = 254个子网
d 一个B类地址的子网掩码是255.255.240.0。试问在其中每一个子网上的主机数最多是多少?
4094
e A类子网掩码为255.255.0.255,是否有效?
有效,但不太支持这样做。
f 某个IP地址为C2.2F.14.81,点分十进制为?
这个进制转换一下就行了
192.47.20.129 是C类的
g C类网络地址使用子网掩码有意义吗?
有,可以进一步划分子网。
4.何为MTU?与之IP数据报何关?
a MTU
最大传输单元(Maximum Transmission Unit,MTU)是指一种通信协议的某一层上面所能通过的最大数据报巨细(以字节为单位)。最大传输单元这个参数通常与通信接口有关(网络接口卡、串口等)。
b MTU与IP数据报
与总长度字段(Total Length)有关。
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| IHL |Type of Service| Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Identification |Flags| Fragment Offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Time to Live | Protocol | Header Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Destination Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options | Padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
RFC:https://tools.ietf.org/rfc/rfc791
5.有如下的4个/24地址块,使之最大聚合
a 分析
212.56.132.0/24 | 10000100 |
---|---|
212.56.133.0/24 | 10000101 |
212.56.134.0/24 | 10000110 |
212.56.135.0/24 | 10000111 |
可以分析到第三个字节不同,前6位的100001bit相同。
b CIDR
答:212.56.132.0/22(11010100 00111000 100001)
6.地址划分
a 起始地址14.24.74.0/24,依次划分为120、60、10地址需求的子网。
子网1 需要 120 个地址 1首地址14.24.74.0/25
子网2 需要 60 个地址。2首地址14.24.74.128/26
子网3 需要 10 个地址。3首地址14.24.74.192/28
b 网络145.13.0.0/16划分四个子网,路由器接口分别m0-3,第五个接口m4接外网。
(1)试给出路由器R的路由表?
Destination IP | Destination Subnet-Mask | Next-hop |
---|---|---|
143.13.0.0 | 255.255.192.0 | 直接交付,接口 m0 |
143.13.64.0 | 255.255.192.0 | 直接交付,接口 m1 |
143.13.128.0 | 255.255.192.0 | 直接交付,接口 m2 |
145.13.192.0 | 255.255.192.0 | 直接交付,接口 m3 |
其他 | M | 默认路由器,接口 m4 |
(2)路由器R收到一个分组,目的地址145.13.160.78,分组是如何转发的?
收到的分组从路由器的接口m2转发,实际上就是直接交付连接在这个网络上的目的主机。
7.将IPv6转为简化形式
a IPv6零压缩方法
0000:0000:0F53:6382:AB00:67DB:BB27:7332
0000:0000:0000:0000:0000:0000:004D:ABCD
0000:0000:0000:AF36:7328:0000:87AA:0398
2819:00AF:0000:0000:0000:0035:0CB2:B271
(1)::F53:6382:AB00:67DB:BB27:7332
(2)::4D:ABCD
(3)::AF36:7328:0:87AA:398
(4)2819:AF::35:CB2:B271
b 法则
两个法则:
- 零压缩:每个IPv6地址中只允许出现一次。
- 前导零压缩:可出现任意次数。
c 零压缩(Zero Compression):
如果在一个IPv6地址存在连续多个字段的0时,其可用两个冒号**::
来代替。
注意:这类零压缩最多出现一次**,即在每个IPv6地址中只能出现一个::
。
示例:
源格式:1234 : 1234 : 0000 : 0000 : 0000 : 0000 : 3456 : 3434
压缩后:1234 : 1234 :: 3456 : 3434
d 前导零压缩(Leading Zero Compression)
在任意的16-bit的字段中,前导的0(leading zeros)可以被丢弃(dropped),但每个字段至少要保留有一位数(at least one number remaining)。因此,如果一个字段全为0,那么你必须留一个0来表示该字段。
示例:
原格式:1234 : 0000 : 1234 : 0000 : 1234 : 0000 : 0123 : 1234
压缩后:1234 : 0 : 1234 : 0 : 1234 : 0 : 123 : 1234