2025-11-24 11:55:57 同人作品

灌包与抓包(还是不太懂)

服务器灌包与抓包【部分转载】

导言:什么是灌包与抓包 抓包看码流,可以借此分析定位网络问题 ;灌包可以将抓到的包配置在网卡上发出去 ,就是可以对码流进行编辑与发送。

开发人员眼中的灌包与抓包的作用 主要是通信部门无线侧和核心网交互中,用于用户面的东西需要灌包比较多,在不同网卡上对码流进行编辑。

灌包工具:

linux下灌包工具:iperf, windows下的图形灌包工具:giperf

抓包工具:tcpdump与Wireshark

tcpdump与Wireshark是常见的两种抓包工具,前者主要用于Linux系统下,后者主要用于windows系统下。 例:tcpdump -i any -w /home/001.pacp

灌包总结: 例子: 下行包: 5gc --> UE 核心网侧: 下行UDP: iperf -u -c 10.45.0.1 -i 1 -b 100M -t 30 UE侧:下行UDP:.\iperf.exe -u -s -i 1

核心网侧: 下行TCP: iperf -c 10.45.0.1 -p 5200 -i 1 -t 30 UE侧:下行TCP:.\iperf.exe -u -s -i 1

备注:参数-l -i -b -t 等可以网上找些iperf的详细资料查看,或者英语好的,直接 iperf --help, 前面部分是客户端服务端共有的参数,接着是服务端的专属参数,最后是客户端专属参数 Usage: iperf [-s|-c host] [options] iperf [-h|–help] [-v|–version]

Client/Server: -b, --bandwidth #[kmgKMG | pps] bandwidth to send at in bits/sec or packets per second -e, --enhancedreports use enhanced reporting giving more tcp/udp and traffic information -f, --format [kmgKMG] format to report: Kbits, Mbits, KBytes, MBytes -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 (MTU - TCP/IP header) -o, --output output the report or error message to this specified file -p, --port # server port to listen on/connect to -u, --udp use UDP rather than TCP –udp-counters-64bit use 64 bit sequence numbers with UDP -w, --window #[KM] TCP window size (socket buffer size) -z, --realtime request realtime scheduler -B, --bind bind to , an interface or multicast address -C, --compatibility for use with older versions does not sent extra msgs -M, --mss # set TCP maximum segment size (MTU - 40 bytes) -N, --nodelay set TCP no delay, disabling Nagle’s Algorithm -S, --tos # set the socket’s IP_TOS (byte) field

Server specific: -s, --server run in server mode -t, --time # time in seconds to listen for new connections as well as to receive traffic (default not set) -U, --single_udp run in single threaded UDP mode -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: -c, --client run in client mode, connecting to -d, --dualtest Do a bidirectional test simultaneously -n, --num #[kmgKMG] number of bytes to transmit (instead of -t) -r, --tradeoff Do a bidirectional test individually -t, --time # time in seconds to transmit for (default 10 secs) -B, --bind [ | ip:port] bind src addr(s) from which to originate traffic -F, --fileinput input the data to be transmitted from a file -I, --stdin input the data to be transmitted from stdin -L, --listenport # port to receive bidirectional tests back on -P, --parallel # number of parallel client threads to run -R, --reverse reverse the test (client receives, server sends) -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 -Z, --linux-congestion set TCP congestion control algorithm (Linux only)

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_, such as IPERF_BANDWIDTH.

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