UDP Tx Official Benchmark

Dependencies:   PicoTCP lpc1768-picotcp-eth mbed-rtos mbed

This project represents a the official UDP Tx speed Benchmark for the PicoTCP library.

The mbed board is sending 5 frames per milisecond (each frame has 1024 bytes of payload) to a linux host(directly connected). Each time we send a packet, a counter is increased and sent to the receiver, so it can measure the number of packets that were lost during transmission.

The result:
20 seconds Tx Statistics
Total bytes received : 102404096
UDP Speed : 39.064 Mbit/s
Packet loss : 0.000000 %

The python script used (which you should rename it to PicoTCP_Official_UDP_Tx_Benchmark.py)

import socket
from struct import unpack
import fcntl, os
import errno
import random, string
from time import time, sleep

ECHO_SERVER_ADDRESS = "192.168.100.12"
NUMBER_OF_SECONDS = 20
LOCAL_SERVER_PORT = 2327
MEGA = 1024*1024.
LEN_PACKET = 1024
data = ''.join('\0' for _ in range(LEN_PACKET))

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM,socket.IPPROTO_UDP)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(('', LOCAL_SERVER_PORT))

print "Started receiving data...."
print "Time : %d " % time()

while True:
	start = time()
	counter = 0
	size = 0
	lost_packets = 0
	index = -1
	
	while start + NUMBER_OF_SECONDS > time():
		data, addr = s.recvfrom(LEN_PACKET)
		counter+=1
		size += len(data)
		_index = unpack("<I",data[:4])
	        if _index[0] > 0 and index > 0:
			lost_packets += _index[0] - index -1
		index = _index[0]
						

	print "20 seconds Tx Statistics"
	print "Total bytes received : %d" % size
	print "UDP Speed : %.3f Mbit/s" % ((size*8.)/(MEGA * NUMBER_OF_SECONDS))
	print "Packet loss : %.6f %%" % (100. * lost_packets/(lost_packets+counter))

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.

Files at this revision

API Documentation at this revision

Comitter:
tass
Date:
Thu Oct 03 06:22:54 2013 +0000
Commit message:
UDP Tx Official Benchmark

Changed in this revision

PicoTCP.lib Show annotated file Show diff for this revision Revisions of this file
lpc1768-picotcp-eth.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r ce982aead3d2 PicoTCP.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PicoTCP.lib	Thu Oct 03 06:22:54 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/daniele/code/PicoTCP/#6764a53bb6e6
diff -r 000000000000 -r ce982aead3d2 lpc1768-picotcp-eth.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lpc1768-picotcp-eth.lib	Thu Oct 03 06:22:54 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/tass/code/lpc1768-picotcp-eth/#1ef61e7465a5
diff -r 000000000000 -r ce982aead3d2 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 03 06:22:54 2013 +0000
@@ -0,0 +1,49 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+
+#define BUFFER_SIZE        1024
+#define NUMBER_OF_SECONDS (20*1000u)  // 20 seconds
+
+#define REMOTE_IP       "192.168.100.2"
+#define REMOTE_PORT      2327
+#define NUMBER_OF_FRAMES 1000
+
+int main() {
+
+    EthernetInterface eth;
+    eth.init();
+    eth.connect();
+    
+    printf("Started UDP Fast Test...\n");
+    
+    UDPSocket server;
+    Endpoint endp;
+    char buffer[BUFFER_SIZE];
+    
+    printf("Remote endpoint @ %s:%d\n",REMOTE_IP,REMOTE_PORT);
+    endp.set_address(REMOTE_IP,REMOTE_PORT);
+    
+    printf("Binding result :%d\n", server.bind(REMOTE_PORT));
+    
+    server.bind(REMOTE_PORT);
+    server.set_blocking(false,1000);
+    
+    printf("Started sending packet flood...\n");
+    
+    while(true)
+    {
+       int cnt = 0;
+       static uint32_t counter = 0;
+       while(cnt<5)
+       {
+        memcpy(buffer,&counter,sizeof(counter));
+        int size = server.sendTo(endp,buffer,sizeof(buffer));
+        counter++;
+        cnt++;
+       }
+       Thread::wait(1);
+    }
+    
+    server.close();
+}
+
diff -r 000000000000 -r ce982aead3d2 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Thu Oct 03 06:22:54 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#ee87e782d34f
diff -r 000000000000 -r ce982aead3d2 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Oct 03 06:22:54 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file