[lwip-users] will lwip support asyncselect just like WSAAsyncSelect

5 views
Skip to first unread message

chenyintao

unread,
Apr 2, 2011, 1:29:49 AM4/2/11
to lwip-users
Hi!
I want to use lwip 1.3.2 to support multiple sessions in a embedded system.
But I foud it is so inefficient to use the api select when there are 64 sockets as clients.For example,a modbus client socket can only do the receive data after all the 64 sockets finish sending.
will anyone can help me to solve the problem.

ps:in my case,64 clients sockets will send data at the same time and the sever may not respond at once,so for a socket,it will receive the packet from the server after a really long time





工作顺利!

--------------
陈银桃/现场总线业务部
cheny...@supcon.com
2011-04-02

欢迎光临我们公司的网站,http://www.supcon.com
**********************************************
浙江中控技术股份有限公司/ 研发中心/现场总线业务部
电话:0571-86667270
传真:0571- 86667250
邮箱:cheny...@supcon.com
邮编:310053
地址:杭州市滨江区六和路309号中控科技园A区4楼
***********************************************

Kieran Mansley

unread,
Apr 3, 2011, 6:44:14 AM4/3/11
to Mailing list for lwIP users

On 2 Apr 2011, at 06:29, chenyintao wrote:

> Hi!
> I want to use lwip 1.3.2 to support multiple sessions in a embedded system.
> But I foud it is so inefficient to use the api select when there are 64 sockets as clients.For example,a modbus client socket can only do the receive data after all the 64 sockets finish sending.
> will anyone can help me to solve the problem.

No, I don't think we have anything like WSAAsyncSelect.

> ps:in my case,64 clients sockets will send data at the same time and the sever may not respond at once,so for a socket,it will receive the packet from the server after a really long time

I'm not sure I fully understand your application. Can you give an example of how you're calling select. I didn't think lwIP supported that many sockets in the select set for example.

Kieran
_______________________________________________
lwip-users mailing list
lwip-...@nongnu.org
http://lists.nongnu.org/mailman/listinfo/lwip-users

chenyintao

unread,
Apr 6, 2011, 4:29:46 AM4/6/11
to Mailing list for lwIP users
Hi,Kieran!
Thanks for your reply~~
I'm sorry for my awful written English.I will try to improve it~_~.
Our application is implementing a modbus-tcp poll that connecting to 64 servers in one thread.
I do it like that:
void modbustcppoll()
{
for(i=0;i<TCP_CLIENT_LINK_TOTALS;i++)
connet();
select(65,readset, writeset,errset, 0);
for(i=0;i<TCP_CLIENT_LINK_TOTALS;i++)
{
if (FD_ISSET(clientsocket[i].socket, writeset))
send();
if (FD_ISSET(clientsocket[i].socket, readset))
receive();
}
}
When TCP_CLIENT_LINK_TOTALS is equal 16,it works well.But when it is equal 64,it will cost more than 100 ms for a socktet to receiver something.






工作顺利!

--------------
陈银桃/工业通讯技术部
cheny...@supcon.com
2011-04-06

欢迎光临我们公司的网站,http://www.supcon.com
**********************************************
浙江中控技术股份有限公司/ 研发中心/工业通讯技术部
电话:0571- 88851888 9258
传真:0571- 86667250
邮箱:cheny...@supcon.com
邮编:310053
地址:杭州市滨江区六和路309号中控科技园A区4楼
***********************************************
-------------------------------------------------------------
发件人:Kieran Mansley
发送日期:2011-04-03 18:45:17
收件人:Mailing list for lwIP users
抄送:
主题:Re: [lwip-users] will lwip support asyncselect just likeWSAAsyncSelect


On 2 Apr 2011, at 06:29, chenyintao wrote:

> Hi!
> I want to use lwip 1.3.2 to support multiple sessions in a embedded system.
> But I foud it is so inefficient to use the api select when there are 64 sockets as clients.For example,a modbus client socket can only do the receive data after all the 64 sockets finish sending.
> will anyone can help me to solve the problem.

No, I don't think we have anything like WSAAsyncSelect.

> ps:in my case,64 clients sockets will send data at the same time and the sever may not respond at once,so for a socket,it will receive the packet from the server after a really long time

Simon Goldschmidt

unread,
Apr 6, 2011, 4:39:42 AM4/6/11
to Mailing list for lwIP users
"chenyintao" <cheny...@supcon.com> wrote:
> Our application is implementing a modbus-tcp poll that connecting to
> 64 servers in one thread.
> I do it like that:
> void modbustcppoll()
> {
> for(i=0;i<TCP_CLIENT_LINK_TOTALS;i++)
> connet();

I'm assuming this is a nonblocking connect?

> select(65,readset, writeset,errset, 0);
> for(i=0;i<TCP_CLIENT_LINK_TOTALS;i++)
> {
> if (FD_ISSET(clientsocket[i].socket, writeset))
> send();
> if (FD_ISSET(clientsocket[i].socket, readset))
> receive();
> }
> }
> When TCP_CLIENT_LINK_TOTALS is equal 16,it works well.But when it is
> equal 64,it will cost more than 100 ms for a socktet to receiver something.


I wouldn't have thought that the select implementation is the limiting factor here. Are you sure you did not run into memory limitations somewhere? Specifically, you need to set MEMP_NUM_NETCONN high enough as well as have enough pbufs, heap memory and tcp segments. Did you check the stats that there is no error (all 'err' members should be 0)?

While our select implementation might be somewhat suboptimal, 64 sockets should not be a problem at all. I'll see if I can write a test for this.

Simon
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

chenyintao

unread,
Apr 6, 2011, 9:14:15 PM4/6/11
to Mailing list for lwIP users
Hi,Simon!
Thanks for your reply!

>I'm assuming this is a nonblocking connect?
yes!
> select(65,readset, writeset,errset, 0);
> for(i=0;i<TCP_CLIENT_LINK_TOTALS;i++)
> {
> if (FD_ISSET(clientsocket[i].socket, writeset))
> send();
> if (FD_ISSET(clientsocket[i].socket, readset))
> receive();
> }
> }
> When TCP_CLIENT_LINK_TOTALS is equal 16,it works well.But when it is
> equal 64,it will cost more than 100 ms for a socktet to receiver something.

>I wouldn't have thought that the select implementation is the limiting factor here. Are you sure you did not run >into memory limitations somewhere? Specifically, you need to set MEMP_NUM_NETCONN high enough as well as >have enough pbufs, heap memory and tcp segments. Did you check the stats that there is no error (all 'err' >members should be 0)?

>While our select implementation might be somewhat suboptimal, 64 sockets should not be a problem at all. I'll >see if I can write a test for this.

I also have done some tests for this issue. I edite the "charge" programe so that it can echo the request of the modbuspoll.the lengthe of the request packet data is 12 Bytes,and the one of the echo's is 250 Bytes.I use the wireshark to capture the traffics.there is the result.
If there are 64 active connetions and only 1 connetion has traffics,the ack time is among 1~54 ms,and the usual valuse is 2 ms.
If send a arp begin the first "for" cycle,and observe the time between two arp packets,the the time is among 1~154ms.
In fact,it is ok if everything is done in my own modbuspoll program and the throught may achieve 2000pps.But the actual application is that a 10ms thread decide what to send and to see if have something received and other correlative process. So,in some case,my modbuspoll will send 64 packets first,then do the receive in the next "select". As the result it is maybe too inefficient.

It must be difficult to understand my application,maybe you can see the program for example? Thanks very much.

The file "tcpclient.c" is my test program.the 10ms thread is just like the function below,of courese more complex .
void TaskRun(void *pData)
{
U8 byErr = 0;
U8 i = 0;


while(TRUE)
{
pMsg = (U32*) OSQPend(AppArray, 0, &err);//every 10ms
for(i=0;i<64;i++)
{
if(recvflag[i])
{
sendflag[i] = 1;
recvflag[i] = 0;
}
}
}
}

Simon
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

_______________________________________________

tcpclient.c
Reply all
Reply to author
Forward
0 new messages