网络的分片,重组

个人学习,如有错误或补充,请多指教~

MTU

Maximum Transmission Unit,MTU:最大传输单元,接收数据包的最大单元,MTU在网络通信中是非常重要的,是网络分片和重组的基础。

IP分片
  • 首先IP分片发生在网络层
  • 当发送的数据包大小超过了MTU,则需要对数据包进行切片划分,使每一片长度小于等于MTU,其中涉及到一些数据包ip首部值的修改,标志位偏移位等,自行查阅。
IP重组
  • 重组发生在目的ip的网络层
  • 通过标志位和偏移位的设置,将分片的数据包通过数据的堆栈进行进一步处理。
避免IP分片

因为在网络层是没有超时重传机制的,如果分片之后其中的某一个分片丢失,就会导致传输层的重传,是对所有分片的重传,所以会降低传输效率和成功率,所以要避免IP分片。

  • 对于TCP的数据包:三次握手保证了数据包不会超过MTU值,避免了IP分片。
  • 对于UDP的数据包: 我们需要限制数据包的大小,保证不超过MTU值。
网卡的offload机制

早期处理网络低速传输以及网络传输的不可靠问题,是通过操作系统进行数据包的处理。这样会占用很多cpu的使用率。为了解决这样的问题,将网卡加入了offload机制,来提高网络的收发性能,将原本操作系统操作对数据包的处理,放到网卡中去做。

LSO(Large Segment Offload)/LRO(Large Receive Offload)
  • LSO:当发送数据超过了MTU的时候,操作系统将传输请求给网卡,网卡接收请求后将数据包进行切割,并封包发出。
  • LRO:LRO会将接收的碎片包自动组合,提交给操作系统处理。
  • 一般来说,LSO和LRO主要面向TCP报文。
GSO(Generic Segmentation Offload)/GRO(Generic Receive Offload)

比LSO/LRO更通用,会自动检测网卡支持的特性。

TSO(TCP Segmentation Offload)/UFO(UDP fragmentation offload)

分别对应TCP报文和UDP报文

查看以上说的各个选项

ethtool -k eth0

[root@dut dpdk]# ethtool -k eno1
Features for eno1:
rx-checksumming: on
tx-checksumming: on
	tx-checksum-ipv4: off [fixed]
	tx-checksum-ip-generic: on
	tx-checksum-ipv6: off [fixed]
	tx-checksum-fcoe-crc: off [fixed]
	tx-checksum-sctp: on
scatter-gather: on
	tx-scatter-gather: on
	tx-scatter-gather-fraglist: off [fixed]
tcp-segmentation-offload: on
	tx-tcp-segmentation: on
	tx-tcp-ecn-segmentation: off [fixed]
	tx-tcp6-segmentation: on
	tx-tcp-mangleid-segmentation: off
udp-fragmentation-offload: off [fixed]
generic-segmentation-offload: on
generic-receive-offload: on
large-receive-offload: off [fixed]
rx-vlan-offload: on
tx-vlan-offload: on
ntuple-filters: off
receive-hashing: on
highdma: on [fixed]
rx-vlan-filter: on [fixed]
vlan-challenged: off [fixed]
tx-lockless: off [fixed]
netns-local: off [fixed]
tx-gso-robust: off [fixed]
tx-fcoe-segmentation: off [fixed]
tx-gre-segmentation: on
tx-ipip-segmentation: on
tx-sit-segmentation: on
tx-udp_tnl-segmentation: on
fcoe-mtu: off [fixed]
tx-nocache-copy: off
loopback: off [fixed]
rx-fcs: off [fixed]
rx-all: off
tx-vlan-stag-hw-insert: off [fixed]
rx-vlan-stag-hw-parse: off [fixed]
rx-vlan-stag-filter: off [fixed]
busy-poll: off [fixed]
tx-gre-csum-segmentation: on
tx-udp_tnl-csum-segmentation: on
tx-gso-partial: on
tx-sctp-segmentation: off [fixed]
rx-gro-hw: off [fixed]
l2-fwd-offload: off [fixed]
hw-tc-offload: on
rx-udp_tunnel-port-offload: off [fixed]

ethtool -K eth0 gso off/on 开关命令

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
需要的开发包 -驱动:WinPcap_4_0_2 -开发包:WinPcap Developer's Packs v4.0.2 前段时间学习Winpcap在Linux下和Xp下的编程,Linux下用Gcc编的东西是基于控制台的,XP下直接加个MFC界面,都不是很稳定的。交流一下。 功能:截获流过网卡的数据包并重组成原始数据。 --------------------- 路径 名字 后缀 大小 用途 \ release 存放生成的exe文件 \ monitor 项目源代码目录 \monitor\ res 资源目录 \monitor\ user_fun 自定义类和函数 \ monitor sln 989 VS8解决方案 \monitor\ monitor cpp 1662 VS8解决方案 \monitor\ monitor h 447 VS8解决方案 \monitor\ monitor rc 6412 VS8解决方案 \monitor\ monitor vcproj 6412 VS8解决方案 \monitor\ monitorDlg cpp 21851 VS8解决方案 \monitor\ monitorDlg h 2842 VS8解决方案 \monitor\ ReadMe txt 2763 VS8解决方案 \monitor\ Resource h 1277 资源 \monitor\ stdafx cpp 138 VS8解决方案 \monitor\ stdafx h 2758 通用头文件 \monitor\res\ monitor ico 21630 图标资源 \monitor\res\ monitor rc2 363 界面资源 \monitor\user_fun\ big2small cpp 337 大小端转换定义 \monitor\user_fun\ big2small h 197 大小端转换头文件 \monitor\user_fun\ class cpp 13194 自定义存放捕获的包的数据结构和类定义 \monitor\user_fun\ class h 4242 自定义存放捕获的包的数据结构和类头文件 \monitor\user_fun\ commom_def h 2894 使用到的各种协议结构定义 \monitor\user_fun\ device cpp 3691 网卡相关函数定义 \monitor\user_fun\ device h 900 网卡相关函数头文件 \monitor\user_fun\ http_method cpp 17618 处理截获的包的函数定义 \monitor\user_fun\ http_method h 2865 处理截获的包的函数头文件 \release\ monitor exe 81920 主程序 \release\ monitor.exe manifest 650 VS8自动生成配置信息 \release\ monitor pdb 3075072 VS9自动生成程序数据
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值