TASS Belgium / Mbed 2 deprecated UDP_Send_Test

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

Committer:
tass
Date:
Thu Oct 03 06:22:54 2013 +0000
Revision:
0:ce982aead3d2
UDP Tx Official Benchmark

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tass 0:ce982aead3d2 1 #include "mbed.h"
tass 0:ce982aead3d2 2 #include "EthernetInterface.h"
tass 0:ce982aead3d2 3
tass 0:ce982aead3d2 4 #define BUFFER_SIZE 1024
tass 0:ce982aead3d2 5 #define NUMBER_OF_SECONDS (20*1000u) // 20 seconds
tass 0:ce982aead3d2 6
tass 0:ce982aead3d2 7 #define REMOTE_IP "192.168.100.2"
tass 0:ce982aead3d2 8 #define REMOTE_PORT 2327
tass 0:ce982aead3d2 9 #define NUMBER_OF_FRAMES 1000
tass 0:ce982aead3d2 10
tass 0:ce982aead3d2 11 int main() {
tass 0:ce982aead3d2 12
tass 0:ce982aead3d2 13 EthernetInterface eth;
tass 0:ce982aead3d2 14 eth.init();
tass 0:ce982aead3d2 15 eth.connect();
tass 0:ce982aead3d2 16
tass 0:ce982aead3d2 17 printf("Started UDP Fast Test...\n");
tass 0:ce982aead3d2 18
tass 0:ce982aead3d2 19 UDPSocket server;
tass 0:ce982aead3d2 20 Endpoint endp;
tass 0:ce982aead3d2 21 char buffer[BUFFER_SIZE];
tass 0:ce982aead3d2 22
tass 0:ce982aead3d2 23 printf("Remote endpoint @ %s:%d\n",REMOTE_IP,REMOTE_PORT);
tass 0:ce982aead3d2 24 endp.set_address(REMOTE_IP,REMOTE_PORT);
tass 0:ce982aead3d2 25
tass 0:ce982aead3d2 26 printf("Binding result :%d\n", server.bind(REMOTE_PORT));
tass 0:ce982aead3d2 27
tass 0:ce982aead3d2 28 server.bind(REMOTE_PORT);
tass 0:ce982aead3d2 29 server.set_blocking(false,1000);
tass 0:ce982aead3d2 30
tass 0:ce982aead3d2 31 printf("Started sending packet flood...\n");
tass 0:ce982aead3d2 32
tass 0:ce982aead3d2 33 while(true)
tass 0:ce982aead3d2 34 {
tass 0:ce982aead3d2 35 int cnt = 0;
tass 0:ce982aead3d2 36 static uint32_t counter = 0;
tass 0:ce982aead3d2 37 while(cnt<5)
tass 0:ce982aead3d2 38 {
tass 0:ce982aead3d2 39 memcpy(buffer,&counter,sizeof(counter));
tass 0:ce982aead3d2 40 int size = server.sendTo(endp,buffer,sizeof(buffer));
tass 0:ce982aead3d2 41 counter++;
tass 0:ce982aead3d2 42 cnt++;
tass 0:ce982aead3d2 43 }
tass 0:ce982aead3d2 44 Thread::wait(1);
tass 0:ce982aead3d2 45 }
tass 0:ce982aead3d2 46
tass 0:ce982aead3d2 47 server.close();
tass 0:ce982aead3d2 48 }
tass 0:ce982aead3d2 49