date: 2024-04-24
title: 04-Network Layer
status: TOBECONTINUED
author:
- AllenYGY
tags:
- Network-Layer
- NOTE
- Network
created: 2024-04-24T20:24
updated: 2024-05-29T12:22
publish: True
Network Layer
An IP datagram consists of a header part and a text part.
Version: to keep track of which version of the protocol the datagram belongs to. 4 bit
IHL: to provide the length of the header, in 32-bit words. 4 bit
- When the value is 5, which applies no options are present.
TOS: (Type of service) to distinguish between different classes of services. 8 bit
- Three-bit precedence field and three flags, D, T, and R {Delay, Throughput and Reliability}. 3 bit
- 三位优先字段(precedence field)和三标志位(D、T、R)用于指示数据报的服务质量需求和优先级。这些字段通常位于IPv4首部的服务类型(Type of Service, TOS)字段中。
TOS Bits | Description |
---|---|
0000 | Normal (default) |
0001 | Minimize cost |
0010 | Maximize reliability |
0100 | Maximize throughput |
1000 | Minimize delay |
这个表格展示了服务类型字段的不同比特组合及其对应的描述。每种组合表示数据报在传输过程中不同的服务质量要求,例如默认服务、最小化成本、最大化可靠性、最大化吞吐量和最小化延迟。
Total Length: to provide the length of the datagram (including header and data). 16 bit
16 bit
3 bit
13 bit
8 bit
8 bit
16 bit
Source address and destination address 32 bit
Unique: no two machines on the Internet have the same IP address.
32-bit long.
字段 | 比特数 | 功能描述 |
---|---|---|
版本 (Version) | 4 | 标识IP协议的版本,IPv4的版本字段值为4 |
首部长度 (IHL) | 4 | 指示IP数据报首部的长度,以32位(4字节)为单位 |
服务类型 (TOS) | 8 | 指定数据报的优先级和服务质量 |
总长度 | 16 | 指示整个IP数据报的总长度,包括首部和数据部分,以字节为单位 |
标识 (Identification) | 16 | 唯一标识数据报,以便在需要时进行分片和重组 |
标志 (Flags) | 3 | 控制和识别数据报的分片,包括不分片位(DF)和更多分片位(MF) |
片偏移 (Fragment Offset) | 13 | 指示数据报片在原始数据报中的相对位置,以8字节为单位 |
生存时间 (TTL) | 8 | 限制数据报在网络中的生存时间,防止无限循环 |
协议 (Protocol) | 8 | 指示数据报携带的数据所使用的协议,如TCP、UDP等 |
首部校验和 (Header Checksum) | 16 | 验证IP首部的完整性 |
源地址 (Source Address) | 32 | 表示数据报发送方的IP地址 |
目的地址 (Destination Address) | 32 | 表示数据报接收方的IP地址 |
选项 (Options) | 可变 | 支持其他的控制功能和服务,长度可变,最多可达40字节 |
总结:IPv4首部的基本部分是20字节(160位),但如果包含选项字段,长度可能会超过20字节。选项字段的长度是可变的,最大可达40字节,因此整个IPv4首部的最大长度是60字节。
Dual stack
Tunneling
Header translation
转发
Shortest Path Routing