Skip to content

Commit 4417563

Browse files
authored
Merge pull request #1 from SPRESENSE/release-v2.0.0
Merge release-v2.0.0 into new-master for v2.0.0 release
2 parents 91b6ad6 + 91c0b3b commit 4417563

38 files changed

+1300
-636
lines changed

Application.mk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ ifneq ($(BUILD_MODULE),y)
7171
endif
7272

7373
ROOTDEPPATH += --dep-path .
74+
ROOTDEPPATH += $(DEPPATH)
7475

7576
VPATH += :.
7677

@@ -203,11 +204,11 @@ else
203204
context::
204205
endif
205206

206-
.depend: Makefile $(SRCS)
207+
.depend: Makefile $(SRCS) $(DEPCONFIG)
207208
ifeq ($(filter %$(CXXEXT),$(SRCS)),)
208-
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(filter-out Makefile,$^) >Make.dep
209+
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
209210
else
210-
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CXX)" -- $(CXXFLAGS) -- $(filter-out Makefile,$^) >Make.dep
211+
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CXX)" -- $(CXXFLAGS) -- $(SRCS) >Make.dep
211212
endif
212213
$(Q) touch $@
213214

examples/tcpblaster/Kconfig

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ config EXAMPLES_TCPBLASTER_SENDSIZE
1717
int "Payload size"
1818
default 4096
1919
---help---
20-
This setting determines size of each test packet sent to the server.
20+
This setting determines size of each TCP send that is sent to the server.
21+
22+
config EXAMPLES_TCPBLASTER_GROUPSIZE
23+
int "Group size"
24+
default 50
25+
---help---
26+
This setting determines how many TCP sends are sent to the server before printing statistics
27+
and starting again.
2128

2229
config EXAMPLES_TCPBLASTER_PROGNAME1
2330
string "Target1 program name"
@@ -459,7 +466,7 @@ config EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_1
459466
---help---
460467
IP address of the server. If the target is the server, then
461468
EXAMPLES_TCPBLASTER_SERVERIP should be the same as
462-
EXAMPLES_TCPBLASTER_IPADDR (default). If the target is the cleint,
469+
EXAMPLES_TCPBLASTER_IPADDR (default). If the target is the client,
463470
then the default value of EXAMPLES_TCPBLASTER_SERVERIP is set to the
464471
host PC IP address (possibly the gateway address,
465472
EXAMPLES_TCPBLASTER_DRIPADDR?).

examples/tcpblaster/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ ifneq ($(CONFIG_EXAMPLES_TCPBLASTER_LOOPBACK),y)
8585

8686
HOSTCFLAGS += -DTCPBLASTER_HOST=1
8787
ifeq ($(CONFIG_EXAMPLES_TCPBLASTER_SERVER),y)
88-
HOSTCFLAGS += -DCONFIG_EXAMPLES_TCPBLASTER_SERVER=1 -DCONFIG_EXAMPLES_TCPBLASTER_SERVERIP="$(CONFIG_EXAMPLES_TCPBLASTER_SERVERIP)"
88+
HOSTCFLAGS += -DCONFIG_EXAMPLES_TCPBLASTER_SERVER=1 -DCONFIG_EXAMPLES_TCPBLASTER_SERVERIP=$(CONFIG_EXAMPLES_TCPBLASTER_SERVERIP)
8989
endif
9090

91-
HOST_SRCS = tcpblaster_host.c
91+
HOST_SRCS = tcpblaster_host.c tcpblaster_cmdline.c
9292
ifeq ($(CONFIG_EXAMPLES_TCPBLASTER_SERVER),y)
9393
HOST_SRCS += tcpblaster_client.c
94-
HOST_BIN = tcpclient$(EXEEXT)
94+
HOST_BIN = tcpclient$(HOSTEXEEXT)
9595
else
9696
HOST_SRCS += tcpblaster_server.c
97-
HOST_BIN = tcpserver$(EXEEXT)
97+
HOST_BIN = tcpserver$(HOSTEXEEXT)
9898
endif
9999

100100
HOSTOBJEXT ?= hobj

examples/tcpblaster/README.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
tcpblaster Performance Test Example
2+
===================================
3+
4+
To set up, do `make menuconfig` and select the Apps > Examples > tcpblaster. By default, nuttx will the be the client
5+
which sends data; and the host computer (Linux, macOS, or Windows) will be the server.
6+
7+
Set up networking so the nuttx computer can ping the host, and the host can ping nuttx. Now you are ready to run the
8+
test.
9+
10+
On host:
11+
12+
$ ./tcpserver
13+
Binding to IPv4 Address: 00000000
14+
server: Accepting connections on port 5471
15+
16+
On nuttx:
17+
18+
nsh> tcpclient
19+
Connecting to IPv4 Address: 0100000a
20+
client: Connected
21+
[2014-07-31 00:16:15.000] 0: Sent 200 4096-byte buffers: 800.0 KB (avg 4.0 KB) in 0.18 seconds ( 4444.4 KB/second)
22+
23+
Now on the host you should see something like:
24+
25+
$ ./tcpserver
26+
Binding to IPv4 Address: 00000000
27+
server: Accepting connections on port 5471
28+
server: Connection accepted -- receiving
29+
[2020-02-22 16:17:07.000] 0: Received 200 buffers: 502.9 KB (buffer average size: 2.5 KB) in 0.12 seconds ( 4194.8 KB/second)
30+
[2020-02-22 16:17:07.000] 1: Received 200 buffers: 393.1 KB (buffer average size: 2.0 KB) in 0.09 seconds ( 4299.4 KB/second)
31+
32+
33+
This will tell you the link speed in KB/sec – kilobytes per second. If you want kilobits, multiply by 8.
34+
35+
You can use the `make menuconfig` to reverse the setup, and have nuttx be the server, and the host be the client. If you
36+
do that, start the server first (nuttx), then start the client (host).
37+
38+
39+
40+

examples/tcpblaster/tcpblaster.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,21 @@
5252
****************************************************************************/
5353

5454
#ifdef TCPBLASTER_HOST
55-
/* HTONS/L macros are unique to uIP */
55+
/* HTONS/L macros are unique to NuttX */
5656

57-
# define HTONS(a) htons(a)
58-
# define HTONL(a) htonl(a)
57+
# undef HTONS
58+
# undef HTONL
59+
# define HTONS(ns) htons(ns)
60+
# define HTONL(nl) htonl(nl)
5961

60-
/* Have SO_LINGER */
62+
# undef NTOHS
63+
# undef NTOHL
64+
# define NTOHS(hs) ntohs(hs)
65+
# define NTOHL(hl) ntohl(hl)
6166

67+
/* Have SO_LINGER */
68+
69+
# define FAR
6270
# define TCPBLASTER_HAVE_SOLINGER 1
6371

6472
#else
@@ -87,14 +95,20 @@
8795
# define SENDSIZE 4096
8896
#endif
8997

98+
#ifdef CONFIG_EXAMPLES_TCPBLASTER_GROUPSIZE
99+
# define GROUPSIZE CONFIG_EXAMPLES_TCPBLASTER_GROUPSIZE
100+
#else
101+
# define GROUPSIZE 50
102+
#endif
103+
90104
/****************************************************************************
91105
* Public Data
92106
****************************************************************************/
93107

94108
#ifdef CONFIG_EXAMPLES_TCPBLASTER_IPv6
95-
uint16_t g_tcpblasterserver_ipv6[8];
109+
extern uint16_t g_tcpblasterserver_ipv6[8];
96110
#else
97-
uint32_t g_tcpblasterserver_ipv4;
111+
extern uint32_t g_tcpblasterserver_ipv4;
98112
#endif
99113

100114
/****************************************************************************

examples/tcpblaster/tcpblaster_client.c

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,23 @@ void tcpblaster_client(void)
6767
#endif
6868
struct timespec start;
6969
socklen_t addrlen;
70-
char *outbuf;
70+
FAR char *outbuf;
7171
unsigned long sendtotal;
7272
unsigned long totallost;
73+
int groupcount;
7374
int sendcount;
7475
int partials;
7576
int sockfd;
7677
int nbytessent;
7778
int ch;
7879
int i;
80+
char timebuff[100];
81+
82+
setbuf(stdout, NULL);
7983

8084
/* Allocate buffers */
8185

82-
outbuf = (char*)malloc(SENDSIZE);
86+
outbuf = (FAR char *)malloc(SENDSIZE);
8387
if (!outbuf)
8488
{
8589
printf("client: failed to allocate buffers\n");
@@ -98,26 +102,30 @@ void tcpblaster_client(void)
98102
/* Set up the server address */
99103

100104
#ifdef CONFIG_EXAMPLES_TCPBLASTER_IPv6
101-
server.sin6_family = AF_INET6;
102-
server.sin6_port = HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVER_PORTNO);
103-
memcpy(server.sin6_addr.s6_addr16, g_tcpblasterserver_ipv6, 8 * sizeof(uint16_t));
104-
addrlen = sizeof(struct sockaddr_in6);
105-
106-
printf("Connecting to IPv6 Address: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
107-
g_tcpblasterserver_ipv6[0], g_tcpblasterserver_ipv6[1], g_tcpblasterserver_ipv6[2], g_tcpblasterserver_ipv6[3],
108-
g_tcpblasterserver_ipv6[4], g_tcpblasterserver_ipv6[5], g_tcpblasterserver_ipv6[6], g_tcpblasterserver_ipv6[7]);
105+
server.sin6_family = AF_INET6;
106+
server.sin6_port = HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVER_PORTNO);
107+
memcpy(server.sin6_addr.s6_addr, g_tcpblasterserver_ipv6, 16);
108+
addrlen = sizeof(struct sockaddr_in6);
109+
110+
printf("Connecting to IPv6 Address: "
111+
"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
112+
g_tcpblasterserver_ipv6[0], g_tcpblasterserver_ipv6[1],
113+
g_tcpblasterserver_ipv6[2], g_tcpblasterserver_ipv6[3],
114+
g_tcpblasterserver_ipv6[4], g_tcpblasterserver_ipv6[5],
115+
g_tcpblasterserver_ipv6[6], g_tcpblasterserver_ipv6[7]);
109116
#else
110-
server.sin_family = AF_INET;
111-
server.sin_port = HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVER_PORTNO);
112-
server.sin_addr.s_addr = (in_addr_t)g_tcpblasterserver_ipv4;
113-
addrlen = sizeof(struct sockaddr_in);
117+
server.sin_family = AF_INET;
118+
server.sin_port = HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVER_PORTNO);
119+
server.sin_addr.s_addr = (in_addr_t)g_tcpblasterserver_ipv4;
120+
addrlen = sizeof(struct sockaddr_in);
114121

115-
printf("Connecting to IPv4 Address: %08lx\n", (unsigned long)g_tcpblasterserver_ipv4);
122+
printf("Connecting to IPv4 Address: %08lx\n",
123+
(unsigned long)g_tcpblasterserver_ipv4);
116124
#endif
117125

118126
/* Connect the socket to the server */
119127

120-
if (connect( sockfd, (struct sockaddr*)&server, addrlen) < 0)
128+
if (connect(sockfd, (FAR struct sockaddr *)&server, addrlen) < 0)
121129
{
122130
printf("client: connect failure: %d\n", errno);
123131
goto errout_with_socket;
@@ -139,12 +147,13 @@ void tcpblaster_client(void)
139147

140148
/* Then send messages forever */
141149

150+
groupcount = 0;
142151
sendcount = 0;
143152
sendtotal = 0;
144153
partials = 0;
145154
totallost = 0;
146155

147-
(void)clock_gettime(CLOCK_REALTIME, &start);
156+
clock_gettime(CLOCK_REALTIME, &start);
148157

149158
for (; ; )
150159
{
@@ -197,14 +206,14 @@ void tcpblaster_client(void)
197206

198207
sendtotal += nbytessent;
199208

200-
if (++sendcount >= 50)
209+
if (++sendcount >= GROUPSIZE)
201210
{
202211
struct timespec elapsed;
203212
struct timespec curr;
204213
float fkbrecvd;
205214
float felapsed;
206215

207-
(void)clock_gettime(CLOCK_REALTIME, &curr);
216+
clock_gettime(CLOCK_REALTIME, &curr);
208217

209218
elapsed.tv_sec = curr.tv_sec - start.tv_sec;
210219
if (curr.tv_nsec >= start.tv_nsec)
@@ -218,10 +227,15 @@ void tcpblaster_client(void)
218227
elapsed.tv_nsec = curr.tv_nsec + borrow;
219228
}
220229

221-
fkbrecvd = (float)sendtotal / 1024.0;
222-
felapsed = (float)elapsed.tv_sec + (float)elapsed.tv_nsec / 1000000000.0;
223-
printf("Sent %d buffers: %7.1f Kb (avg %5.1f Kb) in %6.2f Sec (%7.1f Kb/Sec)\n",
224-
sendcount, fkbrecvd, fkbrecvd/sendcount, felapsed, fkbrecvd/felapsed);
230+
strftime(timebuff, 100,
231+
"%Y-%m-%d %H:%M:%S.000", localtime(&curr.tv_sec));
232+
233+
fkbrecvd = sendtotal / 1024.0f;
234+
felapsed = elapsed.tv_sec + elapsed.tv_nsec / 1000000000.0f;
235+
printf("[%s] %d: Sent %d %d-byte buffers: %7.1fKB "
236+
"(avg %5.1f KB) in %6.2f seconds (%7.1f KB/second)\n",
237+
timebuff, groupcount, sendcount, SENDSIZE, fkbrecvd,
238+
fkbrecvd / sendcount, felapsed, fkbrecvd / felapsed);
225239

226240
if (partials > 0)
227241
{
@@ -236,9 +250,10 @@ void tcpblaster_client(void)
236250
sendtotal = 0;
237251
partials = 0;
238252
totallost = 0;
253+
groupcount++;
239254

240-
(void)clock_gettime(CLOCK_REALTIME, &start);
241-
}
255+
clock_gettime(CLOCK_REALTIME, &start);
256+
}
242257
}
243258

244259
free(outbuf);

examples/tcpblaster/tcpblaster_cmdline.c

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,37 +51,10 @@
5151

5252
#ifdef CONFIG_EXAMPLES_TCPBLASTER_IPv6
5353

54-
uint16_t g_tcpblasterserver_ipv6[8] =
55-
{
56-
#if defined(CONFIG_EXAMPLES_TCPBLASTER_LOOPBACK) && defined(NET_LOOPBACK)
57-
0 /* Use the loopback address */
58-
0
59-
0
60-
0
61-
0
62-
0
63-
0
64-
HTONS(1);
65-
#else
66-
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_1),
67-
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_2),
68-
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_3),
69-
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_4),
70-
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_5),
71-
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_6),
72-
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_7),
73-
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_8)
74-
#endif
75-
};
54+
uint16_t g_tcpblasterserver_ipv6[8];
7655

7756
#else
78-
79-
#if defined(CONFIG_EXAMPLES_TCPBLASTER_LOOPBACK) && defined(NET_LOOPBACK)
80-
uint32_t g_tcpblasterserver_ipv4 = HTONL(0x7f000001);
81-
#else
82-
uint32_t g_tcpblasterserver_ipv4 = HTONL(CONFIG_EXAMPLES_TCPBLASTER_SERVERIP);
83-
#endif
84-
57+
uint32_t g_tcpblasterserver_ipv4;
8558
#endif
8659

8760
/****************************************************************************
@@ -108,8 +81,47 @@ static void show_usage(FAR const char *progname)
10881

10982
void tcpblaster_cmdline(int argc, char **argv)
11083
{
84+
/* Init the default IP address. */
85+
86+
#ifdef CONFIG_EXAMPLES_TCPBLASTER_IPv6
87+
# if defined(CONFIG_EXAMPLES_TCPBLASTER_LOOPBACK) && \
88+
defined(CONFIG_NET_LOOPBACK)
89+
g_tcpblasterserver_ipv6[0] = 0;
90+
g_tcpblasterserver_ipv6[1] = 0;
91+
g_tcpblasterserver_ipv6[2] = 0;
92+
g_tcpblasterserver_ipv6[3] = 0;
93+
g_tcpblasterserver_ipv6[4] = 0;
94+
g_tcpblasterserver_ipv6[5] = 0;
95+
g_tcpblasterserver_ipv6[6] = 0;
96+
g_tcpblasterserver_ipv6[7] = HTONS(1);
97+
# else
98+
g_tcpblasterserver_ipv6[0] =
99+
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_1);
100+
g_tcpblasterserver_ipv6[1] =
101+
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_2);
102+
g_tcpblasterserver_ipv6[2] =
103+
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_3);
104+
g_tcpblasterserver_ipv6[3] =
105+
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_4);
106+
g_tcpblasterserver_ipv6[4] =
107+
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_5);
108+
g_tcpblasterserver_ipv6[5] =
109+
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_6);
110+
g_tcpblasterserver_ipv6[6] =
111+
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_7);
112+
g_tcpblasterserver_ipv6[7] =
113+
HTONS(CONFIG_EXAMPLES_TCPBLASTER_SERVERIPv6ADDR_8);
114+
# endif
115+
#else
116+
# if defined(CONFIG_EXAMPLES_TCPBLASTER_LOOPBACK) && defined(CONFIG_NET_LOOPBACK)
117+
g_tcpblasterserver_ipv4 = HTONL(0x7f000001);
118+
# else
119+
g_tcpblasterserver_ipv4 = HTONL(CONFIG_EXAMPLES_TCPBLASTER_SERVERIP);
120+
# endif
121+
#endif
122+
111123
/* Currently only a single command line option is supported: The server
112-
* IP address.
124+
* IP address. Used to override default.
113125
*/
114126

115127
if (argc == 2)

examples/tcpblaster/tcpblaster_host.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454

5555
int main(int argc, char **argv, char **envp)
5656
{
57+
/* Parse any command line options */
58+
59+
tcpblaster_cmdline(argc, argv);
60+
5761
#ifdef CONFIG_EXAMPLES_TCPBLASTER_SERVER
5862
tcpblaster_client();
5963
#else

0 commit comments

Comments
 (0)