计算机网络 网络性能优化技术 数据发送TSO/USO/GSO 您所在的位置:网站首页 招商手册电子版怎么弄的出来 计算机网络 网络性能优化技术 数据发送TSO/USO/GSO

计算机网络 网络性能优化技术 数据发送TSO/USO/GSO

2023-09-28 15:32| 来源: 网络整理| 查看: 265

目录

概念介绍

如何查看网卡是否启用了TSO

概念介绍

我们知道,网络设备一次能够传输的最大数据量就是MTU,即IP传递给网络设备的每一个数据包不能超过MTU个字节,IP层的分段和重组功能就是为了适配网络设备的MTU而存在的。从理论上来讲,TCP可以不关心MTU的限定,只需要按照自己的意愿随意的将数据包丢给IP,是否需要分段可以由IP透明的处理,但是由于分片会带来效率和性能上的损失,所以TCP在实现时总是会基于MTU设定自己的发包大小,尽量避免让数据包在IP层分片,也就是说TCP会保证一个TCP段经过IP封装后传给网络设备时,数据包的大小不会超过网络设备的MTU。

TCP的这种实现会使得其必须对用户空间传入的数据进行分段,这种工作很固定,但是会耗费CPU时间,所以在高速网络中就想优化这种操作。优化的思路就是TCP将大块数据(远超MTU)传给网络设备,由网络设备按照MTU来分段,从而释放CPU资源,这就是TSO(TCP Segmentation Offload)的设计思想。

显然,TSO需要网络设备硬件支持。更近一步,TSO实际上是一种延迟分段技术,延迟分段会减少发送路径上的数据拷贝操作,所以即使网络设备不支持TSO,只要能够延迟分段也是有收益的,而且也不仅仅限于TCP,对于其它L4协议也是可以的,这就衍生出了GSO(Generic Segmentation Offload)。这种技术是指尽可能的延迟分段,最好是在设备驱动程序中进行分段处理,但是这样一来就需要修改所有的网络设备驱动,不太现实,所以再提前一点,在将数据递交给网络设备的入口处由软件进行分段(见dev_queue_xmit()),这正是Linux内核的实现方式。  

与TSO类似的,还有巨型帧(Jumbo Frames),只不过工作的层次不同。

 

如何查看网卡是否启用了TSO

使用ethtool 查看网卡特性

 

[root@oracletest ~]# ethtool -k ens192 Features for ens192: 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: off [fixed] 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: on rx-vlan-offload: on tx-vlan-offload: on ntuple-filters: off [fixed] receive-hashing: on highdma: on 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: off [fixed] tx-ipip-segmentation: off [fixed] tx-sit-segmentation: off [fixed] tx-udp_tnl-segmentation: off [fixed] fcoe-mtu: off [fixed] tx-nocache-copy: off loopback: off [fixed] rx-fcs: off [fixed] rx-all: off [fixed] 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: off [fixed] tx-udp_tnl-csum-segmentation: off [fixed] tx-gso-partial: off [fixed] tx-sctp-segmentation: off [fixed] rx-gro-hw: off [fixed] l2-fwd-offload: off [fixed] hw-tc-offload: off [fixed] rx-udp_tunnel-port-offload: off [fixed] [root@oracletest ~]#

可以看到其中的 tcp-segmentation-offload: on。上文提到,除了网卡要支持TSO,网络设备也要支持才行,否则将解包压力堆积到了交换机上,仍然会造成瓶颈。

有关TSO的具体实现原理,请参见参考部分连接。

 

转自:

https://blog.csdn.net/xiaoyu_750516366/article/details/85461457

参考:

https://blog.csdn.net/megan_free/article/details/84992350?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2.nonecase

https://blog.csdn.net/dog250/article/details/47055121

https://blog.csdn.net/u011130578/article/details/44569231

https://blog.csdn.net/xiaoyu_750516366/article/details/85461457

https://blog.csdn.net/megan_free/article/details/84992350

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有