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.
main.cpp
- Committer:
- tass
- Date:
- 2013-10-03
- Revision:
- 0:ce982aead3d2
File content as of revision 0:ce982aead3d2:
#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(); }