Network performance test: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
(Add categories: Network, Reference, Configuration, Comparison)
(Fix: remove --- horizontal lines (12 removed))
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Speedtest ==
= Network Performance Test =
Using Speedtest.net tools to measure broadband up and down speed<syntaxhighlight lang="bash">
 
#Debian family including Ubuntu
{{Status
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
|status=Draft
sudo apt-get install speedtest
|owner=Knowledge Agent
|last_update=2026-07-15
|review=Pending
}}
 
{{TOC}}
 
== Overview ==
 
네트워크 성능 테스트는 데이터센터 및 서버의 네트워크 대역폭, 지연시간, 처리량 등을 측정하고 최적화하는 과정입니다. ethtool, netperf, pktgen 등 다양한 도구를 활용하여 테스트합니다.
 
=== Summary ===
 
* 무엇인가? — 네트워크 성능 측정 및 최적화
* 왜 필요한가? — 병목 현상 식별, 성능 검증, 설정 최적화
* 언제 사용하는가? — 신규 서버 도입, 네트워크 업그레이드, 문제 진단
 
 
== Purpose ==
 
이 문서가 존재하는 이유
 
* Goal: 네트워크 성능 테스트 도구, 설정 최적화, offload 기능 제공
* Scope: speedtest, netperf, pktgen, ethtool, sysctl 튜닝, offload 기능
* Non-goals: 네트워크 보안, 방화벽 설정, VLAN 구성
 
 
== Key Concepts ==
 
{| class="wikitable"
! Concept
! Description
! Related
|-
| Throughput
| 실제 데이터 전송률 (bit/s)
| [[Network performance test]]
|-
| Bandwidth Delay Product
| 네트워크 경로 최대 데이터량
| [[Network performance test]]
|-
| Jumbo Frames
| MTU 9000+ 대형 프레임
| [[Network performance test]]
|-
| RDMA
| 원격 메모리 직접 접근
| [[Network performance test]]
|-
| Offload
| NIC가 TCP/IP 처리 담당
| [[Network performance test]]
|-
| IRQ Affinity
| 인터럽트 CPU 바인딩
| [[Network performance test]]
|-
| Netperf
| 네트워크 성능 테스트 도구
| [[Network performance test]]
|-
| Pktgen
| 커널 공간 패킷 생성기
| [[Network performance test]]
|}
 
 
== Architecture ==


#redhat family
네트워크 성능 테스트 아키텍처:
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.rpm.sh | sudo bash
sudo yum install speedtest


$speedtest
<syntaxhighlight lang="mermaid">
graph TD
    A[Client] -->|TCP/UDP| B[Network]
    B --> C[Server]
    D[Netperf] --> A
    D --> C
    E[Pktgen] --> B
    F[ethtool] --> A
    F --> C
    G[sysctl] --> A
    G --> C
</syntaxhighlight>
</syntaxhighlight>


== Throughput ==
throughput means as data transfer rate or digital bandwidth consumption and denotes the achieved average useful bit rate in a com-


puter network over a physical communication link. so it is measured below the network layer and above the physical layer, e.g, data link layter in OSI 7 layer concept.
== Workflow ==
 
{| class="wikitable"
! Stage
! Input
! Output
|-
| Bandwidth [[Test]]
| speedtest/netperf
| Throughput (Gbit/s)
|-
| Latency Test
| ping/traceroute
| RTT (msec)
|-
| Offload Check
| ethtool -k
| Feature status
|-
| [[Kernel]] Tuning
| sysctl -w
| Performance improvement
|-
| Stress Test
| pktgen
| Max throughput
|}
 
 
== Detailed Explanation ==


{{Notes}}In network terminology, one Kbit/s means 1,000 bit/s and not 1,024 bit/s
=== Speedtest ===


== Transactions ==
Broadband 업로드/다운로드 속도 측정:
A transaction is defined as a single reply for a single request. In this case, request/response performance is quoted as “transactions/s” for a given request and response size


== Round trip time ==
<syntaxhighlight lang="bash">
Round trip time (RTT) is the total amount of time that a packet takes to reach the target destination and get back to the source address.
# Debian/Ubuntu
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
sudo apt-get install speedtest


round-trip delay is typically between 1msec and 100 msec, which can be measured using ping or traceroute.
# RHEL/CentOS
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.rpm.sh | sudo bash
sudo yum install speedtest


== Bandwidth delay product ==
# 실행
Bandwidth Delay Product (BDP) is an approximation for the amount of data that can be in flow in the network during a time slice.
$ speedtest
</syntaxhighlight>


To compute the BDP, it is required to know the speed of the slowest link in the path and the Round Trip Time (RTT) for the same path, where the bandwidth of a link is expressed in Gbit/s and the RTT in msec.
=== Throughput ===


The BDP is very important in TCP/IP to tune the buffers in the receive and sender side. Both side need to have an available buffer  Bigger than the BDP in order to allow the maximum available throughput, otherwise a packet overflow can happen because of out of free space.
데이터 전송률 또는 디지털 대역폭 소비를 나타내며, 물리 계층 위 데이터 링크 계층에서 측정됩니다.


== Jumbo Frames ==
* 1 Kbit/s = 1,000 bit/s (1,024 아님)
Jumbo frames are Ethernet frames that can carry more than the standard 1500 bytes of payload It was defined that jumbo frames can carry up to 9000 bytes, but some devices can [[support]] up to 16128 bytes per frame (called as Super Jumbo Frames).


Almost all 10 Gbit/s switches support jumbo frames, and new switches supports super jumbo frame
=== Round Trip Time (RTT) ===


패킷이 목적지에 도달하여 소스로 돌아오는 데 걸리는 총 시간.


The size of the frame is directly impact to
* 일반적으로 1msec ~ 100msec
* ping 또는 traceroute로 측정


* increase the performance on the network, once the amount of overhead is smaller
=== Bandwidth Delay Product (BDP) ===
* the interface Maximum Transfer Unit (MTU), and it is a specific adapter configuration that must be set for each node in a network,  all interfaces in the same network should have the same MTU in work to communicate properly, a different MTU on a specific node could cause awful issues.


MTU size can be changed $ifconfig <interface> mtu <size>
네트워크 경로에 동시에 존재할 수 있는 데이터 양의 근사치.


Jumbo frames not only reduce I/O overhead on end-hosts, they also improve the responsiveness of TCP by accelerating the congestion window increase by a factor of six compared to the standard MTU.
BDP = Bandwidth × RTT


Setting the MTU to a high number does not mean that all your traffic would use jumbo packets. For example, a normal ssh session is almost insensible to a MTU change, once almost all SSH packets are sent using small frames
* 버퍼는 BDP보다 커야 함 (패킷 오버플로우 방지)
* TCP/IP 튜닝에 중요


== Remote DMA ==
=== Jumbo Frames ===
Remote Direct Memory Access ([[RDMA]]) is an extension of DMA where it allows data to move, bypassing the kernel, from the memory of one computer into an other computer’s memory.


On Linux there is a project called OpenRDMA that provides an implementation of RDMA service layers.
표준 1500바이트보다 큰 이더넷 프레임 (최대 9000바이트, Super Jumbo는 16128바이트).


RDMA layer is already implemented by common applications such as NFS
* 10Gbit/s 스위치는 거의 모두 지원
* MTU는 네트워크 전체 노드에서 동일해야 함
* SSH와 같은 작은 패킷은 영향 적음


== Transmission queue size ==
<syntaxhighlight lang="bash">
The transmission queue is the buffer that holds packets that is scheduled to be sent to the card.
# MTU 변경
$ ifconfig <interface> mtu <size>
</syntaxhighlight>


The default 1000 packets value could not be enough and around 3000 would be idle depending of the network characteristics
**장점:**
* I/O 오버헤드 감소
* TCP 혼잡 윈도우 증가 가속화 (표준 MTU 대비 6배)


== SMP IRQ affinity ==
=== Remote DMA (RDMA) ===
CPU and a I/O device communicates is through interrupts. On an SMP system, the specific CPU handling your interruption is very important for performance. In general, the round robin algorithm (IRQ balancing) is used to choose the CPU that will handle a specific interruption for a specific card.


/proc/interrupts can display all the interrupts lines, and which CPU handled the interruptions generated for each interrupt line, to achieve the best performance, it is recommended that all the interruptions generated by a device queue is handled by the same CPU, instead of IRQ balancing since the same IRQ handler function can be remain on the specific CPU cache.
커널을 우회하여 한 컴퓨터의 메모리에서 다른 컴퓨터의 메모리로 직접 데이터 이동.


* [[Linux]]: OpenRDMA 프로젝트
* NFS 등 애플리케이션에 이미 구현됨


=== Transmission Queue Size ===


We can stop IRQ balancing on SMP system using following command
송신 큐는 전송 예정 패킷을 버퍼링합니다.


$ systemctl disable --now irqbalance.service
* 기본값: 1000 패킷
* 권장: 3000 패킷 (네트워크 특성에 따라)


After disabing IRQ balancing, we can bind an interrupt line to a specific CPU through /proc/<IRQ number>/smp_affinity, and can be changed any time on-the-fly. The content of the smp_affinity is a hexadecimal value that represents a group of CPU, for example, CPU0 (0x1) and CPU2 (0x4).
=== SMP IRQ Affinity ===


== Taskset affinity ==
SMP 시스템에서 특정 IRQ를 처리하는 CPU 선택이 성능에 중요.
On a multi stream setup, it is advised that a task is bound to one or few CPUs, as described above for IRQ to prevent the task migrate from one CPU to other from time to time that cause cache missing.


In order to bind a task to a CPU, the command taskset should be used as follows
* IRQ balancing 비활성화: `systemctl disable --now irqbalance.service`
* IRQ를 특정 CPU에 바인딩: `/proc/<IRQ number>/smp_affinity`
* hex 값: CPU0=0x1, CPU2=0x4


$ taskset -p 0x1 <PID>
=== Taskset Affinity ===


== Interrupt coalescence ==
멀티 스트림 설정에서 태스크를 특정 CPU에 바인딩하여 캐시 미스 방지.
interruption coalescing mechanisms to reduce the number of IRQs generated.  


Enabling interruption coalescence could be done using the tool ethtool together with parameter -C as long as network driver supports. we can use modinfo command to discover the module parameter depending on the NIC.
<syntaxhighlight lang="bash">
$ taskset -p 0x1 <PID>
</syntaxhighlight>


Since Kernel version 2.6, “New API” (NAPI) was created in the [[linux]] kernel aiming to improve the performance of high-speed networking, and avoid interrupt storms.
=== Interrupt Coalescence ===


== Offload features ==
IRQ 생성 횟수를 줄이는 메커니즘.
According to the 1 Hz per bit rule, one hertz of CPU is required to send or receive one bit of TCP/IP traffic, for example, a five gigabit per second of traffic in a network requires around five GHz of CPU for handling this traffic.  


This implies that two entire cores of a 2.5 GHz multi-core processor will be required to handle the TCP/IP processing associated with five gigabit per second of TCP/IP traffic. Since Ethernet is bidirectional, it means that to send and receive 10 Gbit/s we needs eight 2.5 GHz cores to drive a 10 Gbit/s Ethernet network link.
<syntaxhighlight lang="bash">
# ethtool -C로 설정 (드라이버 지원 시)
$ ethtool -C ethX rx-usecs 50
</syntaxhighlight>


As the link speed grows the more CPU cycle is required to be able to handle all the traffic in TCP/IP. 
=== Offload Features ===


Good news is the network manufacturers started to offload a lot of repetitive tasks to the network card itself without CPU involving,
1Hz/bit 규칙: 1bit 전송/수신에 1Hz CPU 필요.
* 5Gbit/s 트래픽 → 5GHz CPU 필요
* 양방향 10Gbit/s → 8개 2.5GHz 코어 필요


Based on the TCP stat, the manufactures classify offload features in two types -  stateful and stateless
**Offload 유형:**
* Stateful: 연결 상태 추적
* Stateless: 상태 없이 처리


== ethtool on Linux ==
**주요 offload 기능:**
Offload features can be checked and be configured using the ethtool tool.


{| class="wikitable"
{| class="wikitable"
|'''Command'''
! Feature
|'''Description'''
! Description
! 권장
|-
|-
|ethtool -s ethX speed 25000 autoneg off
| TX Checksum
|Force the speed to 25G. If the link is up on one port, the driver does not allow the other port to be set to a different speed.
| TX 체크섬 오프로드
| on
|-
|-
|ethtool -i ethX
| RX Checksum
|Output includes driver, firmware, and package version.
| RX 체크섬 오프로드
| on
|-
|-
|ethtool -k ethX
| TSO
|Show offload features.
| TCP Segmentation Offload
| on
|-
|-
|ethtool -K ethX tso off
| GSO
|Turn off TSO.
| Generic Segmentation Offload
| on
|-
|-
|ethtool -K ethX gro off lro off
| GRO
|Turn off GRO/LRO.
| Generic Receive Offload
| on
|-
|-
|ethtool -g ethX
| LRO
|Show ring sizes.
| Large Receive Offload
| on (드라이버별)
|-
|-
|ethtool -G ethX rx N
| SG
|Set ring sizes.
| Scatter-Gather
| on
|}
 
**CPU 절감 효과:**
* PCI-X Gbit + 1500 MTU: ~5%
* PCI-X Gbit + 9000 MTU: ~15%
 
=== ethtool 명령어 ===
 
{| class="wikitable"
! Command
! Description
|-
|-
|ethtool -S ethX
| ethtool -k ethX
|Get statistics.
| Offload 기능 확인
|-
|-
|ethtool -l ethX
| ethtool -K ethX tso off
|Show number of rings.
| TSO 비활성화
|-
|-
|ethtool -c ethX
| ethtool -K ethX gro off lro off
|Display the current offload features of a network device
| GRO/LRO 비활성화
|-
|-
|ethtool -C ethX rx-frames N
| ethtool -g ethX
|Set interrupt coalescing. Other parameters supported are rx-usecs, rx-frames, rx-usecs-irq, rx-frames-irq, tx-usecs, tx-frames, tx-usecs- irq, tx-frames-irq.
| Ring 크기 확인
|-
|-
|ethtool -L ethX rx 0 tx 0 combined M
| ethtool -G ethX rx N
|Set number of rings.
| Ring 크기 설정
|-
|-
|ethtool -x ethX
| ethtool -S ethX
|Show RSS flow hash indirection table and RSS key.
| 통계 확인
|-
|-
|ethtool -s ethX autoneg on speed 10000 duplex full
| ethtool -c ethX
|Enable Autoneg.
| 현재 offload 기능 표시
|-
|-
|ethtool --show-eee ethX
| ethtool -C ethX rx-frames N
|Show EEE state.
| 인터럽트 코얼레선스 설정
|-
|-
|ethtool --set-eee ethX eee off
| ethtool --set-eee ethX eee off
|Disable EEE.
| EEE 비활성화
|-
|-
|ethtool --set-eee ethX eee on tx-lpi off
| ethtool -t ethX
|Enable EEE, but disable LPI.
| 자가 진단 테스트
|-
|}
|ethtool -L ethX combined 1 rx 0 tx 0
|Disable RSS. Set the combined channels to 1.
|-
|ethtool -K ethX ntuple off
|Disable Accelerated RFS by disabling ntuple filters.
|-
|ethtool -K ethX ntuple on
|Enable Accelerated RFS.
|-
|ethtool -t ethX
|Performs various diagnostic self-tests.
|-
|echo 32768 > /proc/sys/net/core/ rps_sock_flow_entries


echo 2048 > /sys/class/net/ethX/queues/rx-X/
**offload 활성화 예시:**


rps_flow_cnt
|Enable RFS for ring X.
|-
|sysctl -w net.core.busy_read=50
|This sets the time to read the device's receive ring to 50 μsecs. For socket applications waiting for data to arrive, using this method can decrease latency by 2 or 3 μs typically at the expense of higher CPU utilization.
|-
|echo 4 > /sys/class/net/<NAME>/device/sriov_numvfs
|Enable [[SR-IOV]] with four VFs on the named interface.
|-
|ip link set ethX vf 0 mac 00:12:34:56:78:9a
|Set VF MAC address.
|-
|ip link set ethX vf 0 state enable
|Set VF link state for VF 0.
|-
|ip link set ethX vf 0 vlan 100
|Set VF 0 modprobe 8021q; ip link add link <NAME> name <VLAN Interface Name> type vlan id <VLAN ID>
'''Example:'''
modprobe 8021q; ip link add link ens3 name ens3.2 type vlan id 2
|}
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
#check which features are available
# TX/RX 체크섬 활성화
$ sudo ethtool -k eno1np0
Features for eno1np0:
rx-checksumming: on
tx-checksumming: on
        tx-checksum-ipv4: on
        tx-checksum-ip-generic: off [fixed]
        tx-checksum-ipv6: on
        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-tcp-mangleid-segmentation: off
        tx-tcp6-segmentation: on
generic-segmentation-offload: on
generic-receive-offload: on
large-receive-offload: off
rx-vlan-offload: on
tx-vlan-offload: on
ntuple-filters: on
receive-hashing: on
highdma: on [fixed]
rx-vlan-filter: off [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-gre-csum-segmentation: on
tx-ipxip4-segmentation: on
tx-ipxip6-segmentation: off [fixed]
tx-udp_tnl-segmentation: on
tx-udp_tnl-csum-segmentation: on
tx-gso-partial: on
tx-sctp-segmentation: off [fixed]
tx-esp-segmentation: off [fixed]
tx-udp-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: on
rx-vlan-stag-hw-parse: on
rx-vlan-stag-filter: off [fixed]
l2-fwd-offload: off [fixed]
hw-tc-offload: on
esp-hw-offload: off [fixed]
esp-tx-csum-hw-offload: off [fixed]
rx-udp_tunnel-port-offload: on
tls-hw-tx-offload: off [fixed]
tls-hw-rx-offload: off [fixed]
rx-gro-hw: on
tls-hw-record: off [fixed]
</syntaxhighlight>with this features we can check and enable RX or TX checksum.  <syntaxhighlight lang="bash">
# to enable the feature use -K (large) paramater on | off
$ sudo ethtool -K eno1np0 tx on
$ sudo ethtool -K eno1np0 tx on
$ sudo ethtool -K eno1np0 rx on
$ sudo ethtool -K eno1np0 rx on


# enable Scatter and gather
# Scatter-Gather 활성화
$sudo ethtool -K eno1np0 sg on
$ sudo ethtool -K eno1np0 sg on


# enable TCP Segmentation Offload (TSO)
# TSO 활성화
$sudo ethtool -K eno1np0 tso on
$ sudo ethtool -K eno1np0 tso on


# enable Large Receive Offload (LRO)
# GSO 활성화
$ sudo ethtool -K eno1np0 gso on
</syntaxhighlight>


# enable Generic Segmentation Offload (GSO)
=== Kernel 설정 ===
$sudo ethtool -K eno1np0 gso on


</syntaxhighlight>With the enabing TX and RX offload, the amount of CPU saved depends on the packet size. Small packets have little or no savings with this option, while large packets have larger savings.
/sysctl을 통해 네트워크 관련 커널 설정 변경:


* On the PCI-X gigabit adapters, it is possible to save around five percent in the CPU utilization when using a 1500 MTU. On the other hand, when using a 9000 MTU the savings is approximately around 15%.<ref>https://www.kernel.org/doc/ols/2009/ols2009-pages-169-184.pdf</ref>
<syntaxhighlight lang="bash">
* LRO features specific for each device driver and it is usually enabled using a module parameter, as lro_enable for s2io driver.
# 임시 설정
* GSO like TSO is only effective if the MTU is significantly less than the maximum value of 64K
$ sudo sysctl -w <param>=<value>
 
== Kernel setting ==
Most network relative kernel setting can be done using sysctl through the /proc filesystem <syntaxhighlight lang="bash">
# For temporary setting and test
$sudo sysctl -w <param> = <Value>
 
# To enable after boot, use /etc/sysctl.conf or /etc/sysctl.d/config_file
 
# To see all the parameters related to network
$sudo sysctl -a | grep net
 
# To run custom script
$sudo sysctl -p /script/path
 
# Increase Rx buffer size
$sudo sysctl -w net.core.rmem_max=16777216
# enable TCP Windows Scaling
$sudo sysctl net.ipv4.tcp_window_scaling
# Disable the timestamp, remove eight bytes to the TCP header that overhead affects the throughput and CPU usage.
$sudo sysctl -w net.ipv4.tcp_timestamps=0
# TCP fin timeout setting
# Default value is 60s, to make faster connection close and making more resources available for new connections less than 10s
$sudo sysctl -w net.ipv4.tcp_fin_timeout=5
 
# disabling TCP SACK (TCP Selective Acknowledgemen)
$sudo sysctl -w net.ipv4.tcp_sack=0


# 부팅 시 활성화 (/etc/sysctl.conf 또는 /etc/sysctl.d/)
$ sudo sysctl -p /script/path


# 네트워크 관련 파라미터 확인
$ sudo sysctl -a | grep net
</syntaxhighlight>


 
**중요 파라미터:**
 
</syntaxhighlight>inaddtion to SACK, Nagle is a TCP/IP feature and works by grouping small outgoing messages into a bigger segment. Usually Nagle algorithm is enabled on standard sockets and it can be disabled by set TCP_NODELAY on the socket.
 


{| class="wikitable"
{| class="wikitable"
|+Som important to consider factors
! Parameter
!Parameter
! Description
!Description
! 10G 권장값
!Recommended value for 10G
|-
|-
|net.ipv4.tcp_low_latency
| net.ipv4.tcp_low_latency
|The default value is 0 (off). For workloads or environments where latency is a higher priority
| 지연시간 우선 (기본 0)
|1
| 1
|-
|-
|<code>net.ipv4.tcp_window_scaling</code>
| net.ipv4.tcp_window_scaling
|Enable window scaling to support larger TCP window sizes for improved throughput
| TCP 윈도우 지원
|1
| 1
|-
|-
|net.ipv4.tcp_max_tw_buckets
| net.ipv4.tcp_max_tw_buckets
|The default value is 262,144. When network demands are high and the environment is less exposed to external threats
| TIME_WAIT 버킷 (기본 262,144)
|450,000
| 450,000
|-
|-
|<code>net.ipv4.tcp_timestamps</code>
| net.ipv4.tcp_timestamps
|Enable TCP timestamps for more accurate RTT (Round Trip Time) measurement and improved congestion control
| 정확한 RTT 측정
|1
| 1
|-
|-
|<code>net.ipv4.tcp_sack</code>
| net.ipv4.tcp_sack
|Enable Selective Acknowledgments (SACK) to improve TCP performance in the presence of packet loss
| 선택적 확인응답
|1
| 1
|-
|-
|<code>net.ipv4.tcp_no_metrics_save</code>
| net.ipv4.tcp_no_metrics_save
|Disable TCP metrics saving to prevent the system from saving and restoring TCP metrics across reboots
| TCP 메트릭 저장 비활성화
|1
| 1
|-
|-
|<code>net.ipv4.tcp_max_syn_backlog</code>
| net.ipv4.tcp_max_syn_backlog
|Increase the maximum number of pending connections that can be waiting to be accepted
| 대기 연결 최대값
|4096 or higher
| 4096+
|-
|-
|<code>net.core.rmem_max and net.core.wmem_max</code>
| net.core.rmem_max / wmem_max
|Increase the maximum socket receive and send buffer sizes
| 소켓 수신/송신 버퍼 최대
|1048576 (1GB) or higher.
| 1,048,576+
|-
|-
|<code>net.core.netdev_max_backlog</code>
| net.core.netdev_max_backlog
|Increase the maximum backlog size for incoming network packets
| 수신 패킷 백로그 최대
|30000 or higher
| 30,000+
|}
|}


== TCP memory ==
**추가 튜닝:**
All of following value should be changed so that the maximum size is bigger than the BDP, otherwise packets can be dropped because of buffer overflow.


net.ipv4.tcp_rmem (the size in bytes of receive buffer used by TCP sockets)
<syntaxhighlight lang="bash">
# RX 버퍼 크기 증가
$ sudo sysctl -w net.core.rmem_max=16777216


net.ipv4.tcp_wmem (the amount of memory in bytes reserved for sendbuffers)
# TCP 윈도우 스케일링 활성화
$ sudo sysctl net.ipv4.tcp_window_scaling


net.ipv4.tcp_mem ( total TCP buffer-space allocatable in units of page)
# TCP 타임스탬프 비활성화 (오버헤드 감소)
$ sudo sysctl -w net.ipv4.tcp_timestamps=0


# TCP FIN 타임아웃 (기본 60s → 5s)
$ sudo sysctl -w net.ipv4.tcp_fin_timeout=5


others are also considerable parameter to increase performance, kernel ip-sysctl.txt<ref>https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt</ref> describes all these value
# TCP SACK 비활성화
$ sudo sysctl -w net.ipv4.tcp_sack=0
</syntaxhighlight>


net.core.rmem_max, net.core.
=== TCP Memory ===


wmem_max, net.core.rmem_default, net.
모든 값은 BDP보다 커야 함 (패킷 드롭 방지):


core.wmem_default, and net.core.optmem_max.
* `net.ipv4.tcp_rmem`: TCP 소켓 수신 버퍼 크기
* `net.ipv4.tcp_wmem`: TCP 송신 버퍼 크기
* `net.ipv4.tcp_mem`: 할당 가능한 총 TCP 버퍼 공간


net.core.netdev_max_backlog
=== Netperf 성능 테스트 ===


== Netperf<ref>https://hewlettpackard.github.io/netperf/</ref> Performance test ==
{| class="wikitable"
Netperf supports a vast number of testcases, but only three are widely used,  they are TCP_STREAM, TCP_MAERTS7 and UDP_STREAM. The difference between TCP_STREAM and TCP_MAERTS, is that on first, the traffic flows from the client to the server, and on TCP_MAERTS, the traffic flows from the server to the client. Thus running both TCP_STREAM and TCP_MAERTS in parallel generate a full-duplex [[test]].<syntaxhighlight lang="bash">
! Test
#Netperf running for 10 seconds
! Description
$netperf -t TCP_STREAM -H 192.168.1.6 -l 10
|-
| TCP_STREAM
| Client → Server 트래픽
|-
| TCP_MAERTS
| Server → Client 트래픽
|-
| UDP_STREAM
| UDP 트래픽
|-
| TCP_RR
| 트랜잭션 성능 (요청/응답)
|}


#Netperf running with TCP_RR
<syntaxhighlight lang="bash">
$netperf -H 192.168.1.6 -t TCP_RR -l 10
# TCP_STREAM 10초 테스트
 
$ netperf -t TCP_STREAM -H 192.168.1.6 -l 10
#with options -c and -C options to enable CPU utilization reporting and shows the asymmetry in CPU loading.
$netperf -T0,0 -C -c


# TCP_RR 테스트
$ netperf -H 192.168.1.6 -t TCP_RR -l 10


# CPU 사용률 보고
$ netperf -T0,0 -C -c
</syntaxhighlight>
</syntaxhighlight>


**여러 테스트 병렬 실행 스크립트:**


Script to run multiple tests with Netperf<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
#!/bin/bash
#!/bin/bash
NUMBER=8
NUMBER=8
Line 399: Line 446:
echo '' > $TMPFILE
echo '' > $TMPFILE


for i in $(seq $NUMBER)
for i in $(seq $NUMBER); do
do
     echo "Start test ${i}"
     echo "Start test ${i}"  
     netperf -H $PEER -l 10 -t TCP_STREAM -- >> $TMPFILE &
     netperf -H $PEER -l 10 -t TCP_STREAM -- >> $TMPFILE &
     pids="$pids $!"
     pids="$pids $!"
Line 414: Line 460:
</syntaxhighlight>
</syntaxhighlight>


* transactions performance, the test option can be TCP_RR or UDP_RR
=== Pktgen ===
* for the request performance test case, −− −h should be appended in the end of the Netperf line, like netperf -t TCP_RR −− −h
 
커널 공간 애플리케이션으로 CPU 부하 없이 고대역폭 트래픽 생성.
 
* 네트워크 드라이버 전송 흐름 테스트
* 라우터/브리지 테스트용 일반 패킷 생성
 
=== Mpstat ===


== Pktgen<ref>https://www.kernel.org/doc/Documentation/networking/pktgen.txt</ref> ==
SMP CPU 사용률 모니터링. 네트워크 테스트 중 CPU 과부하 및 IRQ 처리 CPU 식별에 유용.
Pktgen can generate high bandwidth traffic without burdening the CPUspecially because it is a kernel space application. so Pktgen used to test the transmission flow of network device driver or to generate ordinary packets to test other network devices like router or bridge.


[https://buildmedia.readthedocs.org/media/pdf/pktgen-dpdk/latest/pktgen-dpdk.pdf DPDK document] shows details how to test Pktgen
=== TCP Congestion Algorithms ===


== Mpstat ==
Linux에서는 부팅 없이 실시간으로 알고리즘 변경 가능.
Mpstat monitors SMP CPUs usage and it is a very helpful tool to discover if a CPU is overloaded and which process is burdening each CPU during a network performance test. it also display statistics with the amount of IRQs that were raised in a time frame and which CPU handled them (The IRQ affinity above)


== TCP Congestion protocols ==
* 기본: reno
On Linux it is possible to change the congestion avoidance algorithm on the fly, without even reboot.
* IBM 권장: cubic


Among default algorithm in Linux, IBM recommends cubic algorithm instead of default reno.<ref>https://www.ibm.com/docs/en/linux-on-systems?topic=tuning-tcpip-ipv4-settings</ref> Other post-install module could be better suited for specific [[workload]] environment. For a more comprehensive list of algorithms which may be available for the Linux distribution being used, see:
<code><nowiki>https://en.wikipedia.org/wiki/TCP_congestion-avoidance_algorithm#Algorithms</nowiki></code>
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
#To lists all the algorithms available to the system
# 사용 가능한 알고리즘 확인
$ cat /proc/sys/net/ipv4/tcp_available_congestion_control
$ cat /proc/sys/net/ipv4/tcp_available_congestion_control
reno cubic
reno cubic


#To see see what algorithm the system is currently using
# 현재 알고리즘 확인
$ cat /proc/sys/net/ipv4/tcp_congestion_control
$ cat /proc/sys/net/ipv4/tcp_congestion_control
cubic
cubic


#To change algorithm
# 알고리즘 변경
$sudo sh -c "echo cubic > /proc/sys/net/ipv4/tcp_congestion_control"
$ sudo sh -c "echo cubic > /proc/sys/net/ipv4/tcp_congestion_control"
</syntaxhighlight>


</syntaxhighlight>RENO
**주요 알고리즘:**
* RENO: 기본 알고리즘
* CUBIC: TCP 곱절 증가 대신 큐빅 함수 사용 (고대역폭에 적합)
* FAST: 빠른 혼잡 제어


CUBIC


FAST
== Configuration ==
 
<syntaxhighlight lang="bash">
# offload 확인
$ sudo ethtool -k eth0
 
# offload 활성화
$ sudo ethtool -K eth0 tso on gso on gro on sg on
 
# Ring 크기 설정
$ sudo ethtool -G eth0 rx 4096 tx 4096
 
# 커널 튜닝
$ sudo sysctl -w net.core.rmem_max=16777216
$ sudo sysctl -w net.core.wmem_max=16777216
$ sudo sysctl -w net.ipv4.tcp_window_scaling=1
 
# IRQ balancing 비활성화
$ systemctl disable --now irqbalance.service
 
# netperf 테스트
$ netperf -t TCP_STREAM -H <server_ip> -l 60
</syntaxhighlight>
 
 
== Examples ==
 
=== Example 1: 네트워크 성능 테스트 ===
 
<syntaxhighlight lang="bash">
# speedtest
$ speedtest
 
# netperf TCP_STREAM
$ netperf -t TCP_STREAM -H 192.168.1.6 -l 60
 
# netperf TCP_RR
$ netperf -H 192.168.1.6 -t TCP_RR -l 60
</syntaxhighlight>
 
=== Example 2: offload 설정 ===
 
<syntaxhighlight lang="bash">
# 현재 설정 확인
$ sudo ethtool -k eth0
 
# 모든 offload 활성화
$ sudo ethtool -K eth0 tx on rx on tso on gso on gro on sg on
 
# Ring 크기 증가
$ sudo ethtool -G eth0 rx 4096 tx 4096
</syntaxhighlight>
 
=== Example 3: 커널 튜닝 ===
 
<syntaxhighlight lang="bash">
# /etc/sysctl.d/99-network-tuning.conf
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_window_scaling=1
net.ipv4.tcp_max_syn_backlog=4096
net.core.netdev_max_backlog=30000
 
# 적용
$ sudo sysctl -p /etc/sysctl.d/99-network-tuning.conf
</syntaxhighlight>
 
 
== Best Practices ==
 
* Jumbo Frames는 네트워크 전체에서 일관되게 설정
* offload 기능은 필수 활성화
* IRQ balancing은 비활성화하고 수동 바인딩
* BDP보다 큰 버퍼 크기 설정
* netperf로 양방향 테스트 (TCP_STREAM + TCP_MAERTS)
* pktgen으로 부하 테스트
* 정기적인 ethtool -S로 통계 모니터링
 
 
== Limitations ==
 
* Jumbo Frames는 네트워크 전체 일관성 필요
* offload 기능은 드라이버에 따라 제한적
* pktgen은 커널 모듈 필요
* netperf는 테스트 환경 설정 필요
 


== References ==
== References ==
<references />
 
* https://hewlettpackard.github.io/netperf/
* https://www.kernel.org/doc/Documentation/networking/pktgen.txt
* https://www.kernel.org/doc/ols/2009/ols2009-pages-169-184.pdf
 
 
== Related Pages ==
 
* [[Network]]
* [[ethtool]]
* [[TCP]]
* [[RDMA]]
* [[Jumbo Frames]]
 
 
[[Category:Network]]
[[Category:Network]]
== Knowledge Graph ==


[[Category:Reference]]
Related


[[Category:Configuration]]
[[RDMA]]
→ [[NIC Bonding]]
→ [[Network]]
→ [[IPMI]]
→ [[SDN]]
→ [[NFS]]


[[Category:Comparison]]
[[Category:Reference]]

Latest revision as of 11:29, 17 July 2026

Network Performance Test

Template:Status

Template:TOC

Overview

네트워크 성능 테스트는 데이터센터 및 서버의 네트워크 대역폭, 지연시간, 처리량 등을 측정하고 최적화하는 과정입니다. ethtool, netperf, pktgen 등 다양한 도구를 활용하여 테스트합니다.

Summary

  • 무엇인가? — 네트워크 성능 측정 및 최적화
  • 왜 필요한가? — 병목 현상 식별, 성능 검증, 설정 최적화
  • 언제 사용하는가? — 신규 서버 도입, 네트워크 업그레이드, 문제 진단


Purpose

이 문서가 존재하는 이유

  • Goal: 네트워크 성능 테스트 도구, 설정 최적화, offload 기능 제공
  • Scope: speedtest, netperf, pktgen, ethtool, sysctl 튜닝, offload 기능
  • Non-goals: 네트워크 보안, 방화벽 설정, VLAN 구성


Key Concepts

Concept Description Related
Throughput 실제 데이터 전송률 (bit/s) Network performance test
Bandwidth Delay Product 네트워크 경로 최대 데이터량 Network performance test
Jumbo Frames MTU 9000+ 대형 프레임 Network performance test
RDMA 원격 메모리 직접 접근 Network performance test
Offload NIC가 TCP/IP 처리 담당 Network performance test
IRQ Affinity 인터럽트 CPU 바인딩 Network performance test
Netperf 네트워크 성능 테스트 도구 Network performance test
Pktgen 커널 공간 패킷 생성기 Network performance test


Architecture

네트워크 성능 테스트 아키텍처:

graph TD
    A[Client] -->|TCP/UDP| B[Network]
    B --> C[Server]
    D[Netperf] --> A
    D --> C
    E[Pktgen] --> B
    F[ethtool] --> A
    F --> C
    G[sysctl] --> A
    G --> C


Workflow

Stage Input Output
Bandwidth Test speedtest/netperf Throughput (Gbit/s)
Latency Test ping/traceroute RTT (msec)
Offload Check ethtool -k Feature status
Kernel Tuning sysctl -w Performance improvement
Stress Test pktgen Max throughput


Detailed Explanation

Speedtest

Broadband 업로드/다운로드 속도 측정:

# Debian/Ubuntu
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
sudo apt-get install speedtest

# RHEL/CentOS
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.rpm.sh | sudo bash
sudo yum install speedtest

# 실행
$ speedtest

Throughput

데이터 전송률 또는 디지털 대역폭 소비를 나타내며, 물리 계층 위 데이터 링크 계층에서 측정됩니다.

  • 1 Kbit/s = 1,000 bit/s (1,024 아님)

Round Trip Time (RTT)

패킷이 목적지에 도달하여 소스로 돌아오는 데 걸리는 총 시간.

  • 일반적으로 1msec ~ 100msec
  • ping 또는 traceroute로 측정

Bandwidth Delay Product (BDP)

네트워크 경로에 동시에 존재할 수 있는 데이터 양의 근사치.

BDP = Bandwidth × RTT

  • 버퍼는 BDP보다 커야 함 (패킷 오버플로우 방지)
  • TCP/IP 튜닝에 중요

Jumbo Frames

표준 1500바이트보다 큰 이더넷 프레임 (최대 9000바이트, Super Jumbo는 16128바이트).

  • 10Gbit/s 스위치는 거의 모두 지원
  • MTU는 네트워크 전체 노드에서 동일해야 함
  • SSH와 같은 작은 패킷은 영향 적음
# MTU 변경
$ ifconfig <interface> mtu <size>
    • 장점:**
  • I/O 오버헤드 감소
  • TCP 혼잡 윈도우 증가 가속화 (표준 MTU 대비 6배)

Remote DMA (RDMA)

커널을 우회하여 한 컴퓨터의 메모리에서 다른 컴퓨터의 메모리로 직접 데이터 이동.

  • Linux: OpenRDMA 프로젝트
  • NFS 등 애플리케이션에 이미 구현됨

Transmission Queue Size

송신 큐는 전송 예정 패킷을 버퍼링합니다.

  • 기본값: 1000 패킷
  • 권장: 3000 패킷 (네트워크 특성에 따라)

SMP IRQ Affinity

SMP 시스템에서 특정 IRQ를 처리하는 CPU 선택이 성능에 중요.

  • IRQ balancing 비활성화: `systemctl disable --now irqbalance.service`
  • IRQ를 특정 CPU에 바인딩: `/proc/<IRQ number>/smp_affinity`
  • hex 값: CPU0=0x1, CPU2=0x4

Taskset Affinity

멀티 스트림 설정에서 태스크를 특정 CPU에 바인딩하여 캐시 미스 방지.

$ taskset -p 0x1 <PID>

Interrupt Coalescence

IRQ 생성 횟수를 줄이는 메커니즘.

# ethtool -C로 설정 (드라이버 지원 시)
$ ethtool -C ethX rx-usecs 50

Offload Features

1Hz/bit 규칙: 1bit 전송/수신에 1Hz CPU 필요.

  • 5Gbit/s 트래픽 → 5GHz CPU 필요
  • 양방향 10Gbit/s → 8개 2.5GHz 코어 필요
    • Offload 유형:**
  • Stateful: 연결 상태 추적
  • Stateless: 상태 없이 처리
    • 주요 offload 기능:**
Feature Description 권장
TX Checksum TX 체크섬 오프로드 on
RX Checksum RX 체크섬 오프로드 on
TSO TCP Segmentation Offload on
GSO Generic Segmentation Offload on
GRO Generic Receive Offload on
LRO Large Receive Offload on (드라이버별)
SG Scatter-Gather on
    • CPU 절감 효과:**
  • PCI-X Gbit + 1500 MTU: ~5%
  • PCI-X Gbit + 9000 MTU: ~15%

ethtool 명령어

Command Description
ethtool -k ethX Offload 기능 확인
ethtool -K ethX tso off TSO 비활성화
ethtool -K ethX gro off lro off GRO/LRO 비활성화
ethtool -g ethX Ring 크기 확인
ethtool -G ethX rx N Ring 크기 설정
ethtool -S ethX 통계 확인
ethtool -c ethX 현재 offload 기능 표시
ethtool -C ethX rx-frames N 인터럽트 코얼레선스 설정
ethtool --set-eee ethX eee off EEE 비활성화
ethtool -t ethX 자가 진단 테스트
    • offload 활성화 예시:**
# TX/RX 체크섬 활성화
$ sudo ethtool -K eno1np0 tx on
$ sudo ethtool -K eno1np0 rx on

# Scatter-Gather 활성화
$ sudo ethtool -K eno1np0 sg on

# TSO 활성화
$ sudo ethtool -K eno1np0 tso on

# GSO 활성화
$ sudo ethtool -K eno1np0 gso on

Kernel 설정

/sysctl을 통해 네트워크 관련 커널 설정 변경:

# 임시 설정
$ sudo sysctl -w <param>=<value>

# 부팅 시 활성화 (/etc/sysctl.conf 또는 /etc/sysctl.d/)
$ sudo sysctl -p /script/path

# 네트워크 관련 파라미터 확인
$ sudo sysctl -a | grep net
    • 중요 파라미터:**
Parameter Description 10G 권장값
net.ipv4.tcp_low_latency 지연시간 우선 (기본 0) 1
net.ipv4.tcp_window_scaling 큰 TCP 윈도우 지원 1
net.ipv4.tcp_max_tw_buckets TIME_WAIT 버킷 (기본 262,144) 450,000
net.ipv4.tcp_timestamps 정확한 RTT 측정 1
net.ipv4.tcp_sack 선택적 확인응답 1
net.ipv4.tcp_no_metrics_save TCP 메트릭 저장 비활성화 1
net.ipv4.tcp_max_syn_backlog 대기 연결 최대값 4096+
net.core.rmem_max / wmem_max 소켓 수신/송신 버퍼 최대 1,048,576+
net.core.netdev_max_backlog 수신 패킷 백로그 최대 30,000+
    • 추가 튜닝:**
# RX 버퍼 크기 증가
$ sudo sysctl -w net.core.rmem_max=16777216

# TCP 윈도우 스케일링 활성화
$ sudo sysctl net.ipv4.tcp_window_scaling

# TCP 타임스탬프 비활성화 (오버헤드 감소)
$ sudo sysctl -w net.ipv4.tcp_timestamps=0

# TCP FIN 타임아웃 (기본 60s → 5s)
$ sudo sysctl -w net.ipv4.tcp_fin_timeout=5

# TCP SACK 비활성화
$ sudo sysctl -w net.ipv4.tcp_sack=0

TCP Memory

모든 값은 BDP보다 커야 함 (패킷 드롭 방지):

  • `net.ipv4.tcp_rmem`: TCP 소켓 수신 버퍼 크기
  • `net.ipv4.tcp_wmem`: TCP 송신 버퍼 크기
  • `net.ipv4.tcp_mem`: 할당 가능한 총 TCP 버퍼 공간

Netperf 성능 테스트

Test Description
TCP_STREAM Client → Server 트래픽
TCP_MAERTS Server → Client 트래픽
UDP_STREAM UDP 트래픽
TCP_RR 트랜잭션 성능 (요청/응답)
# TCP_STREAM 10초 테스트
$ netperf -t TCP_STREAM -H 192.168.1.6 -l 10

# TCP_RR 테스트
$ netperf -H 192.168.1.6 -t TCP_RR -l 10

# CPU 사용률 보고
$ netperf -T0,0 -C -c
    • 여러 테스트 병렬 실행 스크립트:**
#!/bin/bash
NUMBER=8
TMPFILE=mktemp
DURATION=10
PEER=192.168.1.6
pids=""
echo '' > $TMPFILE

for i in $(seq $NUMBER); do
    echo "Start test ${i}"
    netperf -H $PEER -l 10 -t TCP_STREAM -- >> $TMPFILE &
    pids="$pids $!"
    netperf -H $PEER -l 10 -t TCP_MAERTS -- >> $TMPFILE &
    pids="$pids $!"
done

wait $pids

echo -n "Total throughput (10^6bits/sec) result: "
cat $TMPFILE | awk '{sum += $5} END{print sum}'

Pktgen

커널 공간 애플리케이션으로 CPU 부하 없이 고대역폭 트래픽 생성.

  • 네트워크 드라이버 전송 흐름 테스트
  • 라우터/브리지 테스트용 일반 패킷 생성

Mpstat

SMP CPU 사용률 모니터링. 네트워크 테스트 중 CPU 과부하 및 IRQ 처리 CPU 식별에 유용.

TCP Congestion Algorithms

Linux에서는 부팅 없이 실시간으로 알고리즘 변경 가능.

  • 기본: reno
  • IBM 권장: cubic
# 사용 가능한 알고리즘 확인
$ cat /proc/sys/net/ipv4/tcp_available_congestion_control
reno cubic

# 현재 알고리즘 확인
$ cat /proc/sys/net/ipv4/tcp_congestion_control
cubic

# 알고리즘 변경
$ sudo sh -c "echo cubic > /proc/sys/net/ipv4/tcp_congestion_control"
    • 주요 알고리즘:**
  • RENO: 기본 알고리즘
  • CUBIC: TCP 곱절 증가 대신 큐빅 함수 사용 (고대역폭에 적합)
  • FAST: 빠른 혼잡 제어


Configuration

# offload 확인
$ sudo ethtool -k eth0

# offload 활성화
$ sudo ethtool -K eth0 tso on gso on gro on sg on

# Ring 크기 설정
$ sudo ethtool -G eth0 rx 4096 tx 4096

# 커널 튜닝
$ sudo sysctl -w net.core.rmem_max=16777216
$ sudo sysctl -w net.core.wmem_max=16777216
$ sudo sysctl -w net.ipv4.tcp_window_scaling=1

# IRQ balancing 비활성화
$ systemctl disable --now irqbalance.service

# netperf 테스트
$ netperf -t TCP_STREAM -H <server_ip> -l 60


Examples

Example 1: 네트워크 성능 테스트

# speedtest
$ speedtest

# netperf TCP_STREAM
$ netperf -t TCP_STREAM -H 192.168.1.6 -l 60

# netperf TCP_RR
$ netperf -H 192.168.1.6 -t TCP_RR -l 60

Example 2: offload 설정

# 현재 설정 확인
$ sudo ethtool -k eth0

# 모든 offload 활성화
$ sudo ethtool -K eth0 tx on rx on tso on gso on gro on sg on

# Ring 크기 증가
$ sudo ethtool -G eth0 rx 4096 tx 4096

Example 3: 커널 튜닝

# /etc/sysctl.d/99-network-tuning.conf
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_window_scaling=1
net.ipv4.tcp_max_syn_backlog=4096
net.core.netdev_max_backlog=30000

# 적용
$ sudo sysctl -p /etc/sysctl.d/99-network-tuning.conf


Best Practices

  • Jumbo Frames는 네트워크 전체에서 일관되게 설정
  • offload 기능은 필수 활성화
  • IRQ balancing은 비활성화하고 수동 바인딩
  • BDP보다 큰 버퍼 크기 설정
  • netperf로 양방향 테스트 (TCP_STREAM + TCP_MAERTS)
  • pktgen으로 부하 테스트
  • 정기적인 ethtool -S로 통계 모니터링


Limitations

  • Jumbo Frames는 네트워크 전체 일관성 필요
  • offload 기능은 드라이버에 따라 제한적
  • pktgen은 커널 모듈 필요
  • netperf는 테스트 환경 설정 필요


References


Related Pages

Knowledge Graph

Related

RDMANIC BondingNetworkIPMISDNNFS