Concurrent Socket Limitation
#1
Posted 02 October 2011 - 09:04 AM
#2
Posted 03 October 2011 - 12:59 AM
#3
Posted 04 October 2011 - 09:40 AM
#4
Posted 23 October 2011 - 05:35 PM
#5
Posted 23 October 2011 - 05:48 PM
#6
Posted 23 October 2011 - 08:08 PM
I do not know if you have any options. I'm still a newb on most of this stuff.
The following is pure speculation:
The Opt.h file is part of the networking code. I found it in
..\SourceCode_Netduino_AllEditions_4.2.0.0_RC3\DeviceCode\pal\lwip\lwip_1_3_2\src\include\lwip
It is full of similar variables whose value has been reduced. My guess is this was done to reduce the memory footprint of the lwip stack. (N+ is a bit memory starved.) If you were so inclined, you could try changing the value and recompiling your own custom firmware. This is NOT a task for a beginner - and I've have not tried it... but the hotshots talk about it like it's simple enough. Here are the not-too-detailed instructions that came with the Netduino source code download:
To build the Netduino Firmware v4.2.0 (release candidate 3):
1. Install the .NET Micro Framework 4.2 RTM Platform Kit
2. Copy these files over the Platform Kit (typically into C:\MicroFrameworkPK_v4_2)
3. Compile the desired Netduino solution
Good luck. Let us know what you learn, good or bad.
#7
Posted 23 October 2011 - 08:29 PM
#8
Posted 23 October 2011 - 09:16 PM
#9
Posted 24 October 2011 - 12:16 AM
#10
Posted 24 October 2011 - 05:40 AM
My issue with the the 5-socket networking limitation which appears to be a firmware limitation that's been introduced.
Wow, what a coincidence. I was just debugging why my UDP based set-time function worked on startup, but then not subsequently. It would crash on the new socket constructor. Strange. Then, I disabled another part of my code that happens to open a socket listener and the set-time started working again. I had just read this thread and immediately thought... I am running out of sockets! By my count, I had been using 3 UDP and 1 TCP. So I made the change suggested by Dan T, but it didn't work, although I don't know why not. Then I opened the Network_defines_lwip.h file and bumped up the TCP and UDP sockets and EUREKA! It works. I agree that the 5 is a bit too contrained. Maybe 10 would be a better number. Here is how I changed the file... (notice thechange from "min" -> "default")
#ifdef NETWORK_MEMORY_PROFILE_LWIP__small #define PLATFORM_DEPENDENT__MEM_SIZE MEM_SIZE__min #define PLATFORM_DEPENDENT__MEMP_NUM_PBUF MEMP_NUM_PBUF__min #define PLATFORM_DEPENDENT__MEMP_NUM_UDP_PCB MEMP_NUM_UDP_PCB__default #define PLATFORM_DEPENDENT__MEMP_NUM_TCP_PCB MEMP_NUM_TCP_PCB__default #define PLATFORM_DEPENDENT__MEMP_NUM_TCP_PCB_LISTEN MEMP_NUM_TCP_PCB_LISTEN__min #define PLATFORM_DEPENDENT__MEMP_NUM_TCP_SEG MEMP_NUM_TCP_SEG__min #define PLATFORM_DEPENDENT__MEMP_NUM_SYS_TIMEOUT MEMP_NUM_SYS_TIMEOUT__min #define PLATFORM_DEPENDENT__MEMP_NUM_NETBUF MEMP_NUM_NETBUF__min #define PLATFORM_DEPENDENT__MEMP_NUM_NETCONN MEMP_NUM_NETCONN__min #define PLATFORM_DEPENDENT__PBUF_POOL_SIZE PBUF_POOL_SIZE__min #define PLATFORM_DEPENDENT__PBUF_POOL_BUFSIZE PBUF_POOL_BUFSIZE__min #define PLATFORM_DEPENDENT__TCP_MSS TCP_MSS__min #define PLATFORM_DEPENDENT__TCP_SND_BUF TCP_SND_BUF__min #define PLATFORM_DEPENDENT__TCP_SND_QUEUELEN TCP_SND_QUEUELEN__min #define PLATFORM_DEPENDENT__TCP_WND TCP_WND__min #define PLATFORM_DEPENDENT__TCP_SNDLOWAT TCP_SNDLOWAT__min #endif
Anyway, that worked. Getting everything setup to build firmware is a real hassle, but there is enough info in this forum to put the pieces together.
Chris -- I would really love to see this limit get a little bump up in the release...
-Valkyrie-MT
#11
Posted 24 October 2011 - 06:06 AM
#12
Posted 24 October 2011 - 02:29 PM
...how many did you end up with?
No, I did not make Dan's change. Just the one I mentioned.
From the config file:
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One per active UDP "connection". */ #define MEMP_NUM_UDP_PCB__min 4 #define MEMP_NUM_UDP_PCB__default 8 #define MEMP_NUM_UDP_PCB__max 16 /* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections. */ #define MEMP_NUM_TCP_PCB__min 5 #define MEMP_NUM_TCP_PCB__default 16 #define MEMP_NUM_TCP_PCB__max 32
As you can see, UDP went from 4 to 8 and TCP went from 5 to 16.
Oddly, I still don't know how I ended up running out... I should have had just enough for what I was doing. But with these settings, I have more breathing room... Also, this may help my rudimentary web server queue up the incoming requests... I will have to test that.
Ultimately, RC3 is a HUGE improvement over RC2 which hung on the constructor. Now with RC3, we get an exception we can handle!
-Valkyrie-MT
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users