Keil Logo

RL TCPNet for large packets

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Author
Renê Augusto Benvenuti
Posted
4-Sep-2017 15:35 GMT
Toolset
ARM
New! RL TCPNet for large packets

Hello,

I'm using RL-TCPnet with RTX in order to develop an Modbus TCP application. Everything works fine until the application tries to send some packet greater than 1460 bytes of data.

I'm using tcp_max_dsize and tcp_send to handle the response packets, but tcp_send only accepts packets up to 1460 bytes. When I tried to split the big packet in smaller chuncks of data the tcp_send functions returned FALSE after the first packet had been sent.

I belive that TCP stack should handle large packets and split then when its size are greater than maximum packet size.

Should I use other function?

Is there a better way to send large bunch of data using tcp sockets?

My MDK is 4.7.

Best regards.

Author
Rene Augusto Benvenuti
Posted
5-Sep-2017 20:43 GMT
Toolset
ARM
New! RE: RL TCPNet for large packets

Hello again,

After some research, I have found that my problem is related with TX fragmentation.

How could I, using TCPNet lib and tcp_send function, fragment data packets? The library should be capable of split the data into fragments, right?

My drivers are from EMAC_LPC177x_8x files.

Best regards.

Author
Fret Bert
Posted
6-Sep-2017 11:15 GMT
Toolset
ARM
New! RE: RL TCPNet for large packets

It's been a while since I seriously used the TCPnet, but I do remember some extreme gotchas.

The 'basic' functionality provided by the stack at that time meant that the application had to send a block and wait for it to be acknowledged before sending the next block.

The protocol stack did not automatically fragment.

Since TCP is a stream oriented protocol, my approach was to buffer up all data pending transmission and extracting it for transmission when possible.

Hope that little information helps.

Author
Franc Urbanc
Posted
6-Sep-2017 13:42 GMT
Toolset
ARM
New! RE: RL TCPNet for large packets

Use BSD sockets, and the TCPnet library will do it for you.

Author
Rene Augusto Benvenuti
Posted
6-Sep-2017 21:20 GMT
Toolset
ARM
New! RE: RL TCPNet for large packets

Thank you both for all this information.

I will try to change my application from TCP sockets to BDS sockets. Hope it is available some demo code of BDS sockets with RTX OS.

Author
Andrew Neil
Posted
7-Sep-2017 08:56 GMT
Toolset
None
New! RE: BDS (sic) sockets

Note that it's BSD sockets - from Berkeley Software Distribution.

It is a very common API model

https://en.wikipedia.org/wiki/Berkeley_sockets

Author
Fret Bert
Posted
7-Sep-2017 10:39 GMT
Toolset
None
New! RE: BDS (sic) sockets

It is a very common API model

Very true. Shame it was only introduced into TCPnet after I'd completed the development of our product :(

Author
Rene Augusto Benvenuti
Posted
11-Sep-2017 19:46 GMT
Toolset
None
New! RE: BDS (sic) sockets

Hello again,

I am trying to change my application from TCP sockets to BSD sockets as mentioned. I still using init_tcp() and main_TcpNet() calls in order to enable ICMP to work.

My main task is like the following:

__task void ethCOMLoop( void )
{ ...

SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); ack_mode = 1; res = ioctlsocket (SocketFD, FIO_KEEP_ALIVE , &sck_mode); /* keep alive */

memset(&sa, 0, sizeof sa);

sa.sin_family = AF_INET; sa.sin_port = htons(1001); sa.sin_addr.s_addr = htonl(INADDR_ANY);

bind(SocketFD, (struct sockaddr *)&sa, sizeof sa) ;

listen(SocketFD, 10) ;

while( 1 ) { if ( ETHInitialized ) { int ConnectFD; int peerSize = sizeof(struct sockaddr_in);

ConnectFD = accept(SocketFD, (struct sockaddr *)&peer, &peerSize );

if (0 > ConnectFD) { /* ALWAYS -2 =/ */ status = -1; } else {

// proccess data... } main_TcpNet(); }
}

However, I still cannot accept incoming attempts of connection. Accept function always returns -2 (SCK_EINVALID), even with socket(), bind() and listen() functions returning success.

Is there something I am missing?

Again, thanks a lot for your support so far.

Author
John Linq
Posted
12-Sep-2017 02:43 GMT
Toolset
None
New! RE: BDS (sic) sockets
listen(SocketFD, 10) ;

while( 1 ) {

    ConnectFD = accept(SocketFD, (struct sockaddr *)&peer, &peerSize );

}

The accept() function creates a new socket for each connection and removes the connection from the listen queue.

Author
Rene Augusto Benvenuti
Posted
12-Sep-2017 18:22 GMT
Toolset
None
New! RE: BDS (sic) sockets

Hello,

Some update...

After some work, I managed to make BSD sockets work, receiving and sending packets. However, I still have fragmentation problems.

Using send() function and disabling block option for sockets my system works fine until I try to send some data greater than 1460 bytes. Send() function returns 1460 bytes sent, but do not finishes the transmission of the remaining data. I tried to call send() in a loop, but after first call it returns error code.

Should I call main_TcpNet() after first send()? I was unable to find documentation or examples using BSD API with RTX and TCPnet (calls to main_TcpNet()).

Enabling block option for sockets, system halts its execution.

Best regards.

Author
Rene Augusto Benvenuti
Posted
22-Sep-2017 18:53 GMT
Toolset
None
New! RE: BDS (sic) sockets

Hello again,

Until now still cannot make it work =/.

Application works fine with BSD sockets, but, when I try to send packets larger than 1460B, the send() function send only 1460B (non blocking) or stall the RTX system (blocking mode). I have tried to put main_tcpNET function in other tasks without success.

Have anyone some tip/advice on using BSD sockets, server mode, with RTX?

Best regards,

Author
Franc Urbanc
Posted
25-Sep-2017 06:28 GMT
Toolset
None
New! RE: BDS (sic) sockets

Take a look at BSD_client example configuration.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.