# Networking Programming - IPerf ## What is IPerf? <div style="text-align:center; margin-bottom: 30px;"> <img src="https://hackmd.io/_uploads/Skh5KAsu6.png" alt="logo iperf" width="250" /> </div> iPerf is a straightforward, free, cross-platform tool widely utilized for measuring and testing network performance. Supporting various protocols such as TCP, UDP, SCTP with both IPv4 and IPv6, iPerf is compatible with multiple operating systems including Linux and Windows. Network administrators and engineers employ iPerf to diagnose network issues, optimize performance, and conduct network experiments. Additionally, iPerf is instrumental in performance testing and benchmarking of network devices. While iPerf can be employed to saturate high-speed links, it's crucial to acknowledge its resource-intensive nature, demanding substantial CPU and memory. Theoretically, iPerf could test links up to 100Gbps, but for such high speeds, using dedicated traffic generators and professional tools is often a more prudent approach. ## IPerf Usage An iPerf test furnishes users with crucial information primarily focused on throughput, but it goes beyond by offering insights into packet loss, jitter, and traffic distribution. Through this test, users can gain a comprehensive understanding of their network's performance characteristics. iPerf testing is a useful tool for network engineering as it allows engineers to gain a better understanding of a network’s performance characteristics. By conducting these tests, engineers can identify bottlenecks, detect network congestion, and pinpoint areas where network performance can be optimized. When network issues arise, engineers can use iPerf to isolate the problem and determine its root cause. It's important to note that iPerf has undergone various iterations over the years, evolving from NLANR's ttcp. The codebase was completely revamped to create a more compact and efficient tool, resulting in two distinct branches: iPerf2 and iPerf3. iPerf3, introduced in 2014, is primarily tailored for network testing, while iPerf2 is better suited for evaluating Wi-Fi speeds. Although users commonly refer to iPerf3 when discussing the tool, both versions are capable of executing similar tests and yielding comparable results. <div style="text-align:center; margin-bottom: 30px;"> <img src="https://hackmd.io/_uploads/ByhH6RjuT.png" alt="ilustrate iperf" width="500" /> </div> For Example picture above, were provided commands illustrate the use of iPerf for network performance testing between a client and a server. The iPerf client initiates a connection to the server with the command "iperf -c iperf.netbeez.net -p 5000 -r". This command specifies the client ("-c") connecting to the server at the address "iperf.netbeez.net" on port 5000 ("-p 5000"), and the reverse direction ("-r") indicates that data will be uploaded from the client to the server on connection. Then, The iPerf server is configured to listen for incoming connections on port 5000 with the command "iperf -s -p 5000". This sets up the server ("-s") to operate as a receiver on port 5000 ("-p 5000"). ## Install IPerf iPerf must be installed on the computers at both ends of the connection you're testing. If using a Unix or Linux-based operating system on a personal computer, one can install iPerf on a local machine for the iPerf speed test. If testing the throughput of a Linode, however, it's better to use another server as the endpoint, as the local ISP may impose network restrictions that can affect the results of the test. Here is step for install IPerf (Here use IPerf3) and usage it : For Ubuntu : 1. Open a terminal window on Ubuntu system. 2. Use the package manager (apt) to install iPerf. Enter the following command and press. ```sudo apt-get install iperf3``` <div style="text-align:center; margin-bottom: 30px;"> <img src="https://hackmd.io/_uploads/rJKiXcaOa.png" alt="install iperf" width="400" /> </div> 3. Verify Installation successfully by typing ```iperf3 --version``` <div style="text-align:center; margin-bottom: 30px;"> <img src="https://hackmd.io/_uploads/HJL679TOp.png" alt="verify iperf iperf" width="500" /> </div> For Windows : 1. Download iPerf for Windows, Visit the official iPerf website: https://iperf.fr/iperf-download.php. Choose either the 32-bit or 64-bit version. <div style="text-align:center; margin-bottom: 30px;"> <img src="https://hackmd.io/_uploads/SJiKM9Tdp.png" alt="download iperf" width="500" /> </div> 3. Extract the Zip File, Once the download is complete, extract the contents of the zip file to a location of your choice like C:\iperf-3.1.3-win64. <div style="text-align:center; margin-bottom: 30px;"> <img src="https://hackmd.io/_uploads/B1q2M5aua.png" alt="download iperf" width="500" /> </div> 4. Open Command Prompt and navigate to the directory where you extracted iPerf and excute command ```iperf --version``` <div style="text-align:center; margin-bottom: 30px;"> <img src="https://hackmd.io/_uploads/HkxwQqT_6.png" alt="check version" width="500" /> </div> ## Run IPerf After installing, now we can run iPerf as a server or client. Here is following step : 1. Choose server and client, decide which machine will act as the server (Windows) and which as the client (Ubuntu) in this case. 2. Start iPerf server, on the machine that will act as the server, run ```iperf -s```, This starts iPerf in server mode, waiting for a connection. <div style="text-align:center; margin-bottom: 30px;"> <img src="https://hackmd.io/_uploads/ryFyH5adp.png" alt="listen server" width="450" /> </div> 3. On the machine that will act as the client, run ```iperf -c <server_ip>```. Replace <server_ip> with the actual IP address or hostname of the iPerf server. Can try ```ipconfig``` for find ip address network. <div style="text-align:center; margin-bottom: 30px;"> <img src="https://hackmd.io/_uploads/rJIQ89pda.png" alt="check ip" width="500" /> </div> <div style="text-align:center; margin-bottom: 30px;"> <img src="https://hackmd.io/_uploads/B1F-I9TOa.pn" alt="run client" width="600" /> </div> The iPerf test output reveals crucial information about the network performance between the client (abdfikih@ubuntu) and the server with the IP address 192.168.217.156. Throughout the 10-second test duration, data transfer occurred in one-second intervals showcasing varying bitrates and data volumes. The average bitrate, a key indicator of network speed, was approximately 14.7 Mbits/sec for the client (sender) and 13.9 Mbits/sec for the server (receiver). There were no packet retractions, suggesting a stable and reliable connection during the test. The output provides a detailed breakdown of data transfer metrics including the amount of data transferred in each interval, bitrate, and congestion window size. These insights empower users to assess the network's quality, identify potential issues like congestion, and make informed decisions regarding network optimization and performance enhancements. 4. We can experiment with various options like -t (time), -p (port), and -i (interval) to customize the test. For more detailed information on iPerf options can use the ```iperf --help``` command. <div style="text-align:center; margin-bottom: 30px;"> <img src="https://hackmd.io/_uploads/r1rv8qaO6.png" alt="ipef options" width="600" /> </div> Here Example use combine options with command ```iperf3 -c 192.168.217.156 -t 60 -i 5 -p 5201```. The ```-c``` flag designates the target server with the IP address ```192.168.217.156``` to which the client will connect. The ```-t 60``` option sets the duration of the test to 60 seconds defining the time period over which the network performance will be measured. Then, the ```-i 5``` flag configures the interval between each result output to be 5 seconds,aiding in creating a more readable and detailed report. The ```-p 5201``` option specifies the port number (5201 in this case) to be used for the connection. <div style="text-align:center; margin-bottom: 30px;"> <img src="https://hackmd.io/_uploads/B1_8Fc6_a.png" alt="ipef options" width="600" /> </div>