IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 网络协议 -> 计算机网络|iperf测量不同拥塞控制下TCP传输性能 -> 正文阅读

[网络协议]计算机网络|iperf测量不同拥塞控制下TCP传输性能

系列文章目录

待更新…



前言

在计算机网络中,TCP和UDP是传输层协议,其中TCP是面向连接的,也是应用最广泛的传输协议,TCP协议作为数据传输核心的最上层,对数据传输的质量至关重要,因此对于TCP协议的研究有重要意义。在庞大的计算机网络中,所有用户共享骨干网中的公共资源,TCP协议中拥塞控制算法是在全局上对网络传输的管理或约束,本文主要探讨不同拥塞控制算法对TCP传输的影响,做一些抓包的工作。


一、实验准备

本实验需要以下实验环境和软件:

  • Ubuntu系统或虚拟机(20.04LTS)
  • 云服务器(阿里云 AWS 腾讯云 华为云)

其中云服务器需要配置公网IP

二、操作内容及步骤

1.内核相关指令

查看可以使用的拥塞控制算法

sysctl net.ipv4.tcp_available_congestion_control

查看当前拥塞控制算法

sysctl net.ipv4.tcp_congestion_control

设置拥塞控制算法

sysctl net.ipv4.tcp_congestion_control = reno

安装拥塞控制算法到内核变量中

modprobe -a tcp_westwood
modprobe -a tcp_vegas
modprobe -a tcp_bic
modprobe -a tcp_htcp

2.iperf or iperf3

Iperf是一个广泛使用的网络性能测量和调整工具。它的意义在于它是一个跨平台的工具,可以为任何网络提供标准化的性能测量。Iperf具有客户端服务器功能,可以创建数据流来测量两端之间单向或双向的网络吞吐量。典型的iperf输出包含一个有时间标记的数据传输量和吞吐量测量的报告。

什么是iperf/iperf3?

iPerf3 是一种用于主动测量 IP 网络上可实现的最大带宽的工具。它支持调整与时间、缓冲区和协议(TCP、UDP、带有 IPv4 和 IPv6 的 SCTP)相关的各种参数。对于每个测试,它都会报告带宽、损耗和其他参数。Iperf3是一个新的实现,它与原始 iPerf 不共享任何代码,也不向后兼容。iPerf 最初由NLANR/DAST开发,iPerf3 主要由ESnet /劳伦斯伯克利国家实验室开发。它是根据三条款BSD 许可证发布的。

iperf特性

  • TCP 和SCTP
    • 测量带宽
    • 报告 MSS/MTU 大小和观察到的读取大小。
    • 通过套接字缓冲区支持 TCP 窗口大小。
  • UDP
    • 客户端可以创建指定带宽的 UDP 流。
    • 测量丢包
    • 测量延迟抖动
    • 组播能力
  • 跨平台:Windows、Linux、Android、MacOS X、FreeBSD、OpenBSD、NetBSD、VxWorks、-Solaris、…
  • 客户端和服务器可以有多个同时连接(-P 选项)。
  • 服务器处理多个连接,而不是在一次测试后退出。
  • 可以运行指定的时间(-t 选项),而不是要传输的设定数据量(-n 或 -k 选项)。
  • 以指定的时间间隔打印定期、中间带宽、抖动和丢失报告(-i 选项)。
  • 将服务器作为守护进程运行(-D 选项)
  • 使用代表性流来测试链路层压缩如何影响您的可实现带宽(-F 选项)。
  • 服务器同时接受一个客户端,同时接受多个客户端
  • 新:忽略 TCP 慢启动(-O 选项)。
  • 新:为 UDP 和(新)TCP(-b 选项)设置目标带宽。
  • 新增:设置 IPv6 流标签(-L 选项)
  • 新增:设置拥塞控制算法
  • 新:使用 SCTP 而不是 TCP(–sctp 选项)
  • 新:以 JSON 格式输出(-J 选项)。
  • 新增:磁盘读取测试(服务器:iperf3 -s / 客户端:iperf3 -c testhost -i1 -F 文件名)
  • 新:磁盘写入测试(服务器:iperf3 -s -F 文件名/客户端:iperf3 -c testhost -i1)

在终端上执行

iperf --help
Usage: iperf [-s|-c host] [options]
       iperf [-h|--help] [-v|--version]

Client/Server:
  -b, --bandwidth #[kmgKMG | pps]  bandwidth to read/send at in bits/sec or packets/sec
  -e, --enhanced    use enhanced reporting giving more tcp/udp and traffic information
  -f, --format    [kmgKMG]   format to report: Kbits, Mbits, KBytes, MBytes
      --hide-ips           hide ip addresses and host names within outputs
  -i, --interval  #        seconds between periodic bandwidth reports
  -l, --len       #[kmKM]    length of buffer in bytes to read or write (Defaults: TCP=128K, v4 UDP=1470, v6 UDP=1450)
  -m, --print_mss          print TCP maximum segment size
  -o, --output    <filename> output the report or error message to this specified file
  -p, --port      #        client/server port to listen/send on and to connect
      --permit-key         permit key to be used to verify client and server (TCP only)
      --sum-only           output sum only reports
  -u, --udp                use UDP rather than TCP
  -w, --window    #[KM]    TCP window size (socket buffer size)
  -B, --bind <host>[:<port>][%<dev>] bind to <host>, ip addr (including multicast address) and optional port and device
  -C, --compatibility      for use with older versions does not sent extra msgs
  -M, --mss       #        set TCP maximum segment size using TCP_MAXSEG
  -N, --nodelay            set TCP no delay, disabling Nagle's Algorithm
  -S, --tos       #        set the socket's IP_TOS (byte) field
  -Z, --tcp-congestion <algo>  set TCP congestion control algorithm (Linux only)

Server specific:
  -p, --port      #[-#]    server port(s) to listen on/connect to
  -s, --server             run in server mode
  -1, --singleclient       run one server at a time
      --histograms         enable latency histograms
      --permit-key-timeout set the timeout for a permit key in seconds
      --tcp-rx-window-clamp set the TCP receive window clamp size in bytes
      --tap-dev   #[<dev>] use TAP device to receive at L2 layer
  -t, --time      #        time in seconds to listen for new connections as well as to receive traffic (default not set)
      --udp-histogram #,#  enable UDP latency histogram(s) with bin width and count, e.g. 1,1000=1(ms),1000(bins)
  -B, --bind <ip>[%<dev>]  bind to multicast address and optional device
  -U, --single_udp         run in single threaded UDP mode
      --sum-dstip          sum traffic threads based upon destination ip address (default is src ip)
  -D, --daemon             run the server as a daemon
  -V, --ipv6_domain        Enable IPv6 reception by setting the domain and socket to AF_INET6 (Can receive on both IPv4 and IPv6)

Client specific:
      --bounceback         request a bounceback test (use -l for size, defaults to 100 bytes)
      --bounceback-congest request a concurrent full-duplex TCP stream
      --bounceback-hold    request the server to insert a delay of n milliseconds between its read and write
      --bounceback-period  request the client schedule a send every n milliseconds
      --bounceback-no-quickack request the server not set the TCP_QUICKACK socket option (disabling TCP ACK delays) during a bounceback test
  -c, --client    <host>   run in client mode, connecting to <host>
      --connect-only       run a connect only test
      --connect-retries #  number of times to retry tcp connect
  -d, --dualtest           Do a bidirectional test simultaneously (multiple sockets)
      --fq-rate #[kmgKMG]  bandwidth to socket pacing
      --full-duplex        run full duplex test using same socket
      --ipg                set the the interpacket gap (milliseconds) for packets within an isochronous frame
      --isochronous <frames-per-second>:<mean>,<stddev> send traffic in bursts (frames - emulate video traffic)
      --incr-dstip         Increment the destination ip with parallel (-P) traffic threads
      --incr-dstport       Increment the destination port with parallel (-P) traffic threads
      --incr-srcip         Increment the source ip with parallel (-P) traffic threads
      --incr-srcport       Increment the source port with parallel (-P) traffic threads
      --local-only         Set don't route on socket
      --near-congestion=[w] Use a weighted write delay per the sampled TCP RTT (experimental)
      --no-connect-sync    No sychronization after connect when -P or parallel traffic threads
      --no-udp-fin         No final server to client stats at end of UDP test
  -n, --num       #[kmgKMG]    number of bytes to transmit (instead of -t)
  -r, --tradeoff           Do a fullduplexectional test individually
      --tcp-quickack       set the socket's TCP_QUICKACK option (off by default)
      --tcp-write-prefetch set the socket's TCP_NOTSENT_LOWAT value in bytes and use event based writes
      --tcp-write-times    measure the socket write times at the application level
  -t, --time      #        time in seconds to transmit for (default 10 secs)
      --trip-times         enable end to end measurements (requires client and server clock sync)
      --txdelay-time       time in seconds to hold back after connect and before first write
      --txstart-time       unix epoch time to schedule first write and start traffic
  -B, --bind [<ip> | <ip:port>] bind ip (and optional port) from which to source traffic
  -F, --fileinput <name>   input the data to be transmitted from a file
  -H, --ssm-host <ip>      set the SSM source, use with -B for (S,G)
  -I, --stdin              input the data to be transmitted from stdin
  -L, --listenport #       port to receive fullduplexectional tests back on
  -P, --parallel  #        number of parallel client threads to run
  -R, --reverse            reverse the test (client receives, server sends)
  -S, --tos                IP DSCP or tos settings
  -T, --ttl       #        time-to-live, for multicast (default 1)
  -V, --ipv6_domain        Set the domain to IPv6 (send packets over IPv6)
  -X, --peer-detect        perform server version detection and version exchange

Miscellaneous:
  -x, --reportexclude [CDMSV]   exclude C(connection) D(data) M(multicast) S(settings) V(server) reports
  -y, --reportstyle C      report as a Comma-Separated Values
  -h, --help               print this message and quit
  -v, --version            print version information and quit

[kmgKMG] Indicates options that support a k,m,g,K,M or G suffix
Lowercase format characters are 10^3 based and uppercase are 2^n based
(e.g. 1k = 1000, 1K = 1024, 1m = 1,000,000 and 1M = 1,048,576)

The TCP window size option can be set by the environment variable
TCP_WINDOW_SIZE. Most other options can be set by an environment variable
IPERF_<long option name>, such as IPERF_BANDWIDTH.

Source at <http://sourceforge.net/projects/iperf2/>
Report bugs to <iperf-users@lists.sourceforge.net>

3.tcpdump

tcpdump可以将网络中传送的数据包完全截获下来提供分析。它支持针对网络层、协议、主机、网络或端口的过滤,并提供and、or、not等逻辑语句来帮助你去掉无用的信息。

$ tcpdump --help
tcpdump version 4.9.3 -- Apple version 114.100.1
libpcap version 1.9.1
LibreSSL 3.3.6
Usage: tcpdump [-aAbdDefhHIJKlLnNOpqStuUvxX#] [ -B size ] [ -c count ]
		[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
		[ -i interface ] [ -j tstamptype ] [ -M secret ] [ --number ]
		[ -Q in|out|inout ]
		[ -r file ] [ -s snaplen ] [ --time-stamp-precision precision ]
		[ --immediate-mode ] [ -T type ] [ --version ] [ -V file ]
		[ -w file ] [ -W filecount ] [ -y datalinktype ] [ -z postrotate-command ]
		[ -g ] [ -k (flags) ] [ -o ] [ -P ] [ -Q meta-data-expression ]
		[ --apple-tzo offset ] [--apple-truncate ]
		[ -Z user ] [ expression ]

4.实验抓包

云服务器拥有公网地址,作为服务器Server,需要注意的是:在云服务器操作台上开启一个端口,用来发送iperf数据包,我开启的端口号为5001。
本地无公网地址,作为客户端Client

在服务器Sever执行

# iperf作为服务器启动,后台运行,监听端口号为5001
iperf -s -D -p 5001

在客户端Client执行

iperf -c xx.xx.xx.xx -p 5001 -t 20

在客户端或服务端开启tcpdump抓包,监听ip地址,5001端口号,将抓到的包写进文件file.pcap

tcpdump host xx.xx.xx.xx -p 5001 -w file.pcap

更多指令可以自行设计,无论是iperf还是iperf3都可以测量网络带宽,可以使用–help查看相关指令。


总结

以上就是今天要讲的内容,本文仅仅简单介绍了Linux添加拥塞控制算法模块到内核,网络传输工具iperf/iperf3和抓包工具tcpdump,提供了一个网络吞吐量测试和抓包的例子。
注意,iperf和iperf3是两个不同的抓包工具,一些指令并不兼容,在其指令中包含拥塞控制算法参数,但是网上使用该参数的信息很少,可以进行尝试,也可以使用sysctl更改Linux内核拥塞控制算法。

Reference

Ubuntu配置|添加拥塞控制算法到Linux内核
Iperf 维基百科
TCPDUMP 百度百科

  网络协议 最新文章
使用Easyswoole 搭建简单的Websoket服务
常见的数据通信方式有哪些?
Openssl 1024bit RSA算法---公私钥获取和处
HTTPS协议的密钥交换流程
《小白WEB安全入门》03. 漏洞篇
HttpRunner4.x 安装与使用
2021-07-04
手写RPC学习笔记
K8S高可用版本部署
mySQL计算IP地址范围
上一篇文章      下一篇文章      查看所有文章
加:2022-07-17 16:57:20  更:2022-07-17 16:58:18 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/19 14:55:17-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码