Official TCP Full speed benchmark
Dependencies: PicoTCP lpc1768-picotcp-eth mbed-rtos mbed
This project represents a the official TCP Full speed Benchmark for the PicoTCP library.
The mbed board is sending and receiving one Megabyte from/to the other side and we measure how fast it does that.
The result:
TX+RX Throughput: 2097152 bytes in 1 seconds (12.410)Mbits/s
The python script used (which you should rename it to PicoTCP_Official_TCP_Full_Benchmark.py)
#!/usr/bin/python import sys, socket import random, string import select from time import time ECHO_SERVER_ADDRESS = "192.168.100.12" ECHO_SERVER_PORT = 7 N_PACKETS = 1024 LEN_PACKET = 1024 TOT_BITS = (LEN_PACKET * N_PACKETS * 8) * 2. # TX bits + RX bits PACKET = ''.join(random.choice(string.ascii_uppercase+string.digits) for _ in range(LEN_PACKET)) MEGA = 1024 * 1024. UPDATE_STEP = (N_PACKETS/20) # Make the update step such as one step = 5% UPDATE_R_STEP = (N_PACKETS/100) #Make the update step such as one step = 1% s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT)) start = time() rx_total = 0 tx_total = 0 data = '' i = 0 lp = [] p = select.poll() while(True): # keeping this in for robustness testing, when the test will run for days print "Started echoing data...." for i in range(N_PACKETS): if (i % UPDATE_STEP) == 0: print "%.2f%%" % (float(i)/float(N_PACKETS) * 100.) s.sendall(PACKET) data = s.recv(LEN_PACKET) if (len(data) != LEN_PACKET): print "Error echoing !" sys.exit(1) print "Test was finished!" break; t = time() - start s.close() print "TX+RX Throughput: %d bytes in %d seconds (%.3f)Mbits/s" % (TOT_BITS / 8, t, ((TOT_BITS / t) / MEGA))
This test is based on the following libraries
Import librarylpc1768-picotcp-eth
A PicoTCP driver for the lpc1768 mbed board
Import libraryPicoTCP
Free (GPLv2) TCP/IP stack developed by TASS Belgium
Import librarymbed-rtos
Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.
Revision 0:a90d7f1c17bc, committed 2013-10-02
- Comitter:
- tass
- Date:
- Wed Oct 02 08:14:42 2013 +0000
- Child:
- 1:1996535d99e9
- Commit message:
- Official TCP Full speed benchmark;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PicoTCP.lib Wed Oct 02 08:14:42 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/daniele/code/PicoTCP/#6764a53bb6e6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lpc1768-picotcp-eth.lib Wed Oct 02 08:14:42 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/tass/code/lpc1768-picotcp-eth/#1ef61e7465a5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Oct 02 08:14:42 2013 +0000
@@ -0,0 +1,64 @@
+#include <mbed.h>
+#include <stdarg.h>
+#include "EthernetInterface.h"
+
+#define ECHO_SERVER_PORT 7
+#define BUFFER_QUANTITY (1024*1024)
+#define BUFFER_SIZE (1024)
+
+EthernetInterface eth;
+
+int main()
+{
+ TCPSocketServer server;
+
+ printf("Started PicoTCP Full Benchmark....\n");
+
+ eth.init();
+ printf("Waiting for DHCP server to give IP...\n");
+
+ while(eth.connect() != 0);
+ printf("IP address assigned : %s\n",eth.getIPAddress());
+
+ server.bind(ECHO_SERVER_PORT);
+ server.listen();
+ printf("Local server listening on port : %d\n",ECHO_SERVER_PORT);
+
+
+ while (true) {
+ printf("\n>>> You can start PicoTCP_Official_TCP_Full_Benchmark.py\n");
+
+ TCPSocketConnection client;
+ server.accept(client);
+ client.set_blocking(false, 1500); // Timeout after (1.5)s
+
+ char buffer[BUFFER_SIZE];
+ int dataSent = 0, dataReceived = 0;
+ while(dataSent < BUFFER_QUANTITY)
+ {
+ while((dataReceived+dataSent) < 2*BUFFER_QUANTITY)
+ {
+ int n = client.receive(buffer, sizeof(buffer));
+ if (n <= 0) {
+ break;
+ }
+ dataReceived += n;
+
+ n = client.send_all(buffer, n);
+ if (n <= 0) {
+ break;
+ }
+ dataSent += n;
+ }
+ }
+
+ if((dataSent+dataReceived) == 2*BUFFER_QUANTITY)
+ {
+ printf("You can read the Rx+Tx Throughput now \n");
+ }
+ else
+ {
+ printf("Benchmark failed !\n");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Wed Oct 02 08:14:42 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#ee87e782d34f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Oct 02 08:14:42 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file
TASS Belgium


