]> git.feebdaed.xyz Git - linuxyz.git/commitdiff
working select poll epoll iperf
authorseantywork <seantywork@gmail.com>
Tue, 13 May 2025 00:18:59 +0000 (09:18 +0900)
committerseantywork <seantywork@gmail.com>
Tue, 13 May 2025 00:18:59 +0000 (09:18 +0900)
iperf/2505-03.xyz.md
iperf/iperf_s.c
iperf/iperf_s.h
iperf/main.c
iperf/test.sh [new file with mode: 0755]

index 4e768b56d84e02be46b30d93be818972220b8462..dc2e05ff4284186d856633d371393a672817b1d4 100644 (file)
@@ -1 +1,52 @@
-# 
\ No newline at end of file
+# 
+
+```shell
+
+
+sudo ip netns exec net1 iperf3 -s -p 5001
+-----------------------------------------------------------
+Server listening on 5001 (test #1)
+-----------------------------------------------------------
+
+```
+
+#
+
+```shell
+iperf$ sudo iperf3 -c 192.168.62.6 -p 5001 -t 60 -i 
+1
+Connecting to host 192.168.62.6, port 5001
+[  5] local 192.168.62.5 port 41342 connected to 192.168.62.6 port 5001
+[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
+[  5]   0.00-1.00   sec  4.91 GBytes  42.2 Gbits/sec    0    478 KBytes       
+[  5]   1.00-2.00   sec  5.00 GBytes  42.9 Gbits/sec    0    600 KBytes       
+[  5]   2.00-3.00   sec  5.06 GBytes  43.5 Gbits/sec    0    600 KBytes       
+[  5]   3.00-4.00   sec  5.03 GBytes  43.2 Gbits/sec    0    600 KBytes       
+^C[  5]   4.00-4.53   sec  2.67 GBytes  43.6 Gbits/sec    0    600 KBytes       
+- - - - - - - - - - - - - - - - - - - - - - - - -
+[ ID] Interval           Transfer     Bitrate         Retr
+[  5]   0.00-4.53   sec  22.8 GBytes  43.2 Gbits/sec    0             sender
+[  5]   0.00-4.53   sec  0.00 Bytes  0.00 bits/sec                  receiver
+iperf3: interrupt - the client has terminated
+
+```
+
+```shell
+
+Accepted connection from 192.168.62.5, port 41336
+[  5] local 192.168.62.6 port 5001 connected to 192.168.62.5 port 41342
+[ ID] Interval           Transfer     Bitrate
+[  5]   0.00-1.00   sec  4.91 GBytes  42.2 Gbits/sec                  
+[  5]   1.00-2.00   sec  5.02 GBytes  43.1 Gbits/sec                  
+[  5]   2.00-3.00   sec  5.08 GBytes  43.7 Gbits/sec                  
+[  5]   3.00-4.00   sec  5.06 GBytes  43.4 Gbits/sec                  
+[  5]   3.00-4.00   sec  5.06 GBytes  43.4 Gbits/sec                  
+- - - - - - - - - - - - - - - - - - - - - - - - -
+[ ID] Interval           Transfer     Bitrate
+[  5]   0.00-4.00   sec  22.8 GBytes  48.9 Gbits/sec                  receiver
+iperf3: the client has terminated
+-----------------------------------------------------------
+Server listening on 5001 (test #2)
+-----------------------------------------------------------
+
+```
\ No newline at end of file
index a8c68db01e93ca1012214b26e52fdb76cf48aa5a..fe9acadabe0495380f63d5e4acc018305c5228a2 100644 (file)
@@ -1 +1,24 @@
-#include "iperf_s.h"
\ No newline at end of file
+#include "iperf_s.h"
+
+
+int run_select(){
+
+
+
+    return 0;
+}
+
+
+int run_poll(){
+
+
+
+    return 0;
+}
+
+
+int run_epoll(){
+
+
+    return 0;
+}
\ No newline at end of file
index f966c6558b454affc98b13bcfe5fc9a2fd8ef11b..1492baf30d16381d123deb873513ef010d5987d8 100644 (file)
@@ -1,6 +1,39 @@
 #ifndef _IPERF_S_H_
 #define _IPERF_S_H_
 
+#include <stdio.h> 
+#include <netdb.h> 
+#include <netinet/in.h> 
+#include <arpa/inet.h>
+#include <stdlib.h> 
+#include <string.h> 
+#include <sys/socket.h> 
+#include <sys/types.h> 
+#include <unistd.h> 
+#include <stdint.h>
+#include <pthread.h>
+#include <signal.h>
+#include <time.h>
+#include <sys/time.h>
+#include <fcntl.h>
+#include <poll.h>
+
+#define MAXCLIENT 32
+#define MAXBUFFLEN 65536
+
+extern char mode;
+extern int port;
+extern int client_num;
+extern uint8_t client_buff[MAXCLIENT][MAXBUFFLEN];
+
+
+int run_select();
+
+int run_poll();
+
+int run_epoll();
+
+
 
 
 #endif
\ No newline at end of file
index 92b2b3e7e9f1ec1288403457784e22b9a1051976..5f2fce4d3427f51098f39d3d3e52af83f40a0461 100644 (file)
@@ -1,8 +1,70 @@
 #include "iperf_s.h"
 
 
+char mode = 's';
+int port = 5001;
+int client_num = 1;
+uint8_t client_buff[MAXCLIENT][MAXBUFFLEN];
+
+static void help(){
+
+    printf("arguments: mode port client_num\n");
+        
+    printf("mode: s - select, p - poll, e - epoll\n");
+}
+
 int main(int argc, char** argv){
 
+    int result = -1;
+
+
+    if(argc != 4){
+
+        help();
+
+        return -1;
+    }
+
+    memset(client_buff, 0, MAXCLIENT * MAXBUFFLEN);
+
+    if(strcmp(argv[1], "s") == 0){
+
+        mode = 's';
+    } else if(strcmp(argv[1], "p") == 0){
+
+        mode = 'p';
+    } else if(strcmp(argv[1], "e") == 0){
+
+        mode = 'e';
+    } else {
+
+        printf("invalid mode: %s\n", argv[1]);
+        help();
+
+        return -2;
+    }
+
+    sscanf(argv[2], "%d", &port);
+
+    printf("port to use: %d\n", port);
+
+    sscanf(argv[3], "%d", &client_num);
+
+    printf("client num: %d\n", client_num);
+
+
+    if(mode == 's'){
+
+        result = run_select();
+
+    } else if (mode == 'p') {
+
+        result = run_poll();
+
+    } else if (mode == 'e') {
+
+        result = run_epoll();
+    }
 
     return 0;
 }
\ No newline at end of file
diff --git a/iperf/test.sh b/iperf/test.sh
new file mode 100755 (executable)
index 0000000..3641e5f
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash 
+
+
+echo "creating interface..."
+
+sudo ip netns add net1
+
+sudo ip link add dev veth11 type veth peer name veth12 netns net1
+
+sudo ip link set up veth11
+
+sudo ip netns exec net1 ip link set up veth12
+
+sudo ip addr add 192.168.62.5/24 dev veth11
+
+sudo ip netns exec net1 ip addr add 192.168.62.6/24 dev veth12
+