]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/commitdiff
Add testing tool iperf
authorJakub NejedlĂ˝ <nejedjak@fel.cvut.cz>
Wed, 21 Aug 2019 08:09:32 +0000 (10:09 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Sat, 31 Aug 2019 21:19:45 +0000 (23:19 +0200)
New debuging tool allows to test quality of ethernet connection. New function
works as iperf server. To test is nessesary connect from computer.

rpp-test-sw/Makefile.var
rpp-test-sw/commands/.gitattributes
rpp-test-sw/commands/cmd.c
rpp-test-sw/commands/cmd_iperf.c [new file with mode: 0644]
rpp-test-sw/commands/cmd_iperf.h [new file with mode: 0644]

index 7b42df367b5bda2ab2223b95e27c6d10ff7235cb..5f84552ef75c5036e04296b9a1fdb091395083e6 100644 (file)
@@ -18,6 +18,7 @@ SOURCES = \
        commands/cmd_netstats.c \
        commands/cmd_echoserver.c \
        commands/cmd_ping.c \
+       commands/cmd_iperf.c \
        commands/main.c
 
 SOURCES_tms570_rpp = \
index 3b040e81200321c9572100636102ff6dc2f61b08..6cedafcab45de0635cd16f5a4e577b446cd0babf 100644 (file)
@@ -16,6 +16,8 @@
 /cmd_pin.h     eaton
 /cmd_ping.c    eaton
 /cmd_ping.h    eaton
+/cmd_iperf.c   eaton
+/cmd_iperf.h   eaton
 /cmd_port.c    eaton
 /cmd_port.h    eaton
 /main.c        eaton
index 293772105499f2bdfd6d332322cec19b11cfe6b8..81210385f71beee8b1123465cbc5189427f42e7d 100644 (file)
@@ -30,6 +30,7 @@
 #include "cmd_emac.h"
 #include "cmd_echoserver.h"
 #include "cmd_ping.h"
+#include "cmd_iperf.h"
 
 #ifdef TARGET_TMS570_RPP
 #include "cmd_dac.h"
@@ -153,6 +154,7 @@ cmd_des_t const *cmd_list_main[] = {
        CMD_DES_INCLUDE_SUBLIST(cmd_list_es),
        CMD_DES_INCLUDE_SUBLIST(cmd_list_netstats),
        CMD_DES_INCLUDE_SUBLIST(cmd_list_ping),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_iperf),
 #ifdef TARGET_TMS570_RPP
        CMD_DES_INCLUDE_SUBLIST(cmd_list_dac),
        CMD_DES_INCLUDE_SUBLIST(cmd_list_din),
diff --git a/rpp-test-sw/commands/cmd_iperf.c b/rpp-test-sw/commands/cmd_iperf.c
new file mode 100644 (file)
index 0000000..ed19f9a
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2012-2019 Czech Technical University in Prague
+ *
+ * Created on: 25.3.2019
+ *
+ * Authors:
+ *     - Jakub Nejedly
+ *
+ * This document contains proprietary information belonging to Czech
+ * Technical University in Prague. Passing on and copying of this
+ * document, and communication of its contents is not permitted
+ * without prior written authorization.
+ *
+ * File : cmd_iperf.c
+ *
+ * Abstract:
+ *
+ *
+ */
+
+#include "cmd_iperf.h"
+
+#ifndef DOCGEN
+
+
+#include "cmdproc_freertos.h"
+#include "rpp/rpp.h"
+
+#include "lwip/opt.h"
+#include "lwip/tcp.h"
+
+
+
+static err_t lwiperf_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err){
+
+       LWIP_UNUSED_ARG(arg);
+
+       if (err == ERR_OK && p != NULL) {
+       tcp_recved(pcb, p->tot_len);
+       pbuf_free(p);
+
+       } else if (err != ERR_OK && p != NULL) {
+       pbuf_free(p);
+
+       }
+
+       if (err == ERR_OK && p == NULL) {
+               tcp_arg(pcb, NULL);
+       tcp_sent(pcb, NULL);
+       tcp_recv(pcb, NULL);
+       tcp_close(pcb);
+       }
+       return ERR_OK;
+}
+
+static err_t lwiperf_accept(void *arg, struct tcp_pcb *pcb, err_t err){
+
+       LWIP_UNUSED_ARG(arg);
+       LWIP_UNUSED_ARG(err);
+
+       tcp_arg(pcb, NULL);
+       tcp_sent(pcb, NULL);
+       tcp_recv(pcb, lwiperf_recv);
+       return ERR_OK;
+}
+
+
+
+
+int cmd_do_eth_lwiperf(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]){
+
+       // test ethinit
+       if (!isPostInitialized()) {
+               rpp_sci_printf("Eth not initialized run 'ethinit' command first.\n");
+               return FAILURE;
+       }
+
+       //err_t err = ERR_OK;
+
+       struct tcp_pcb *pcb;
+
+       pcb = tcp_new();
+       tcp_bind(pcb, IP_ADDR_ANY, 5001); // bind to iperf port
+       pcb = tcp_listen(pcb);
+       tcp_accept(pcb, lwiperf_accept);
+
+       rpp_sci_printf("Iperf initialized \r\n");
+       
+
+       return ERR_OK;
+}
+
+
+
+#endif  /* DOCGEN */
+
+cmd_des_t const cmd_des_ethiperf = {
+       0, 0,
+       "ethiperf","Command to test IP Bandwidth",
+       "### Command syntax ###\n"
+       "\n"
+       "    ethiperf \n"
+       "\n"
+       "### Description ###\n"
+       "Command start iperf server on platform. To test internet bandwidth run iperf -c [board_IP] at testing computer."
+       "\n"
+       "### Example ###\n"
+       "\n"
+       "    --> ethiperf\n"
+       "At testing computer\n"
+       "    --> ethiperf -c 10.35.95.25\n",
+       CMD_HANDLER(cmd_do_eth_lwiperf), (void *)&cmd_list_iperf
+};
+
+/** List of commands for adc, defined as external */
+cmd_des_t const *cmd_list_iperf[] = {
+       &cmd_des_ethiperf,
+       NULL
+};
+
diff --git a/rpp-test-sw/commands/cmd_iperf.h b/rpp-test-sw/commands/cmd_iperf.h
new file mode 100644 (file)
index 0000000..bbc049a
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * cmd_iperf.h
+ *
+ *  Created on: 25.3.2019
+ *      Author: Jakub Nejedly
+ */
+
+#ifndef CMD_IPERF_H_
+#define CMD_IPERF_H_
+
+#include "cmdproc.h"
+
+extern cmd_des_t const *cmd_list_iperf[];
+
+
+#endif /* CMD_IPERF_H_ */