完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
|
我试图使用TCPIpTCPPFIFOSIZEAZECT函数来调整开放服务器套接字的RX/TX FIFO大小。FIFO大小确实改变了(如用TCPIpl TCPPoSokFiffGET验证过的),但是它的行为非常不一致,并且通常连接到连接,导致大量的重复ACKs、损坏的TX数据、无法接收远程RST等。是否有一些未记录的细微差别或使用此乐趣的要求?提示?我的套接字事件序列相当简单,如下:以上是非常基本的和简单的,并且应该在没有问题的情况下工作。然而,它对我来说非常危险。大多数时候,当发送响应时,它是损坏的数据。非常偶然地,预期数据由远程发送/接收。在损坏数据的情况下(如WiReSurk中所见),数据字节的正确数量在包中发送,但数据是垃圾。此外,在失败的情况下,该设备开始发送重复ACKs,永不停止。该连接在这之后不会恢复,即使当远程断开时,设备也不会获得FIN或RST,并且套接字被挂起,直到堆栈结束为止。关键是,如果我简单地将套接字初始化为静态RX/TX FIFO大小,则称为128/128,然后从不调整大小,它工作J。很好!这真是令人沮丧!我经常会遇到这样的事情——一旦我把信封推了一小段,东西就开始破裂。我已经阅读了所有的文件,在那里没有提到任何特殊的环必须跳过,以调整FIFO的大小。请告知。谢谢您。
以上来自于百度翻译 以下为原文 I am attempting to use the TCPIP_TCP_FifoSizeAdjust function to adjust the RX/TX FIFO sizes of an open server socket "on the fly". The FIFO sizes do change (as verified with TCPIP_TCP_SocketInfoGet), but it behaves very inconsistently, and usually hoses the connection, causes a flurry of duplicate ACKs, corrupted TX data, failure to receive remote RST, etc. Are there some undocumented nuances or requirements for using this function? My sequence of socket events is fairly simple, as follows: // from system_config.h ... #define TCPIP_TCP_SOCKET_DEFAULT_TX_SIZE 25 // ==TCP_MIN_TX_BUFF_SIZE #define TCPIP_TCP_SOCKET_DEFAULT_RX_SIZE 25 // ==TCP_MIN_RX_BUFF_SIZE #define TCPIP_TCP_DYNAMIC_OPTIONS true // one-time socket init... hTCP = TCPIP_TCP_ServerOpen( IP_ADDRESS_TYPE_IPV4, TCPIP_TCP_FifoSizeAdjust( hTCP, 256, 0, NULL ); // initialize sizes for large Rx // NOTE: whereever '0' is used as a size parameter, the stack actually uses a minimum size, as defined by TCP_MIN_xx_BUFF_SIZE // exit to main loop // the following is executed once per main loop... uint16_t TCPready = TCPIP_TCP_GetIsReady( hTCP ); // command received? if( TCPready ) { uint8_t dataRX[TCPready]; TCPIP_TCP_ArrayGet( hTCP, dataRx, TCPready ); // get the command data TCPIP_TCP_FifoSizeAdjust( hTCP, 0, 0, TCP_ADJUST_GIVE_REST_TO_TX ); // adjust for transmitting response TCPIP_TCP_StringPut( hTCP, "this is a responser" ); // send the response TCPIP_TCP_FifoSizeAdjust( hTCP, 0, 0, TCP_ADJUST_GIVE_REST_TO_RX ); // adjust for receiving next command } // exit to main loop The above is *very* basic and simple and should work without issue. However, it is very buggy (for me). Most of the time, when the response is sent, it is corrupt data. Very occasionally, the expected data is sent/received by the remote. In the case of corrupt data, (as seen in Wireshark) the correct number of data bytes are sent in the packet, but the data is garbage. Also in the failing case, the device starts sending out duplicate ACKs and never stops. The connection never recovers after this, and even when the remote disconnects, the device doesn't get the FIN or RST and the socket is hung until the stack times it out. The key is, if I simply initialize the socket to static Rx/Tx FIFO size, say 128/128, and then never adjust the sizes, it works just fine! This is really frustrating! I run into this kind of thing too often with this stack - as soon as I push the envelope a tiny bit, stuff starts breaking. I have read all the docs and there in no mention of any special hoops that have to be jumped through for adjust the FIFO sizes. Please advise. Thank you. |
|
相关推荐
3个回答
|
|
|
你试图做的事情永远不会起作用。例如:TCPIpHIPTCPSTRIGPUTE()和THCTCPIPTCPUFIFOSIZEXECUTE(),你把一些数据放在TX缓冲器中(它没有机会被传送——这个调用不是阻塞),并且你立即用TX缓冲区,缩小它。数据将被损坏。不清楚将在该缓冲区中留下什么。当两方之间没有活跃的通信量时,这些功能可以使用。否则,您会混淆TCP算法,并且中断先前被确认的数据。等等。我可以深入挖掘它,BA。在您的示例中,我们看到了什么是完全被破坏的,但是这不是一个有效的使用。我只会在没有挂起的数据的情况下使用这个函数,否则通信会中断。在不同的注释上,TCP将用大的缓冲器正确地和有效地工作,至少1KB IF。你想看到它的任何性能(大部分的堆栈甚至不允许用户弄乱缓冲区大小,但他们管理它,因为他们认为合适。并且缓冲器从至少KB开始,至少)Tx和Rx缓冲器=25字节。这是一个小规模而不是真实的生活场景。我可能会强制执行至少256个字节,这也是非常小的。
以上来自于百度翻译 以下为原文 What you're trying to do will never work. For example: TCPIP_TCP_StringPut() and then TCPIP_TCP_FifoSizeAdjust() You put some data in the TX buffer (which doesn't get a chance to be transmitted - this call is NOT blocking), and immediately you mess with that TX buffer, shrinking it. The data will get corrupted. Not clear what will be left in that buffer. These functions can be used when there is no active traffic being exchanged between the two parties. Otherwise you mess with the TCP algorithm and you break data that's previously been acknowledged, etc. I can dig more into it, based on your example, to see what exactly gets broken in there, but this is not a valid use. I'll make a note to use this function only when there is no pending data, otherwise the communication will break. On a different note, TCP will work properly and efficiently with large buffers, at least 1KB if you want to see any performance out of it (most of the stacks don't even allow the user to mess with the buffers size but they manage it as they see fit. And the buffers start at few KB, at least). TX and RX buffers == 25 bytes? This is way undersized and not a real life scenario. I'll probably enforce to be at least 256 bytes, which is also very small. |
|
|
|
|
|
嗨,雷诺德,谢谢你的回复。道歉。。。在我匆忙地展示一个简单的例子时,我忽略了一些重要的细节。实际上,我在TCPIPpTCPUSTRIGPUTE()之后调用TCPIPUTCPUFLUHE()。但是,您的观点仍然是有效的,因为在调用TCPIPpTCPIFIFOSIZEXECUTE()之前没有调用TCPIPHSTACKYTASK()。所以,好点,谢谢你…我会做这个调整,看看这是否可行。但是,我确实质疑你所说的……我认为可能,这是不正确的,基于可用的选项。TCPIPPUTCPUFIFOSIZEXECUTE()的第四个参数是VFLAGS,其中2个可用的标志是TCPYTracePrimeFieldE.RX和TCPYActudioFraveV.TX。在一种情况下,我成功地使用了这一点来动态地扩展RX FIFO来调整以更有效地接收大请求。实际上,如果一个人为许多远程连接服务,并试图有效地使用RAM,这可能是一种真实的生活场景。如果期望接收小TCP消息并发送小响应,就没有理由拥有1K FIFO(甚至256)。
以上来自于百度翻译 以下为原文 Hi rainad, thanks for the reply. Apologies... in my haste to show a simple example, I left out important details. Actually, I call TCPIP_TCP_Flush() after TCPIP_TCP_StringPut(). However, your point is nevertheless valid because TCPIP_STACK_Task() does not get called before the call to TCPIP_TCP_FifoSizeAdjust(). So, good point, thank you... I will make this adjustment and see if this works. However, I do question something you said... I think possibly, that is not true, based on available options. The 4th parameter to TCPIP_TCP_FifoSizeAdjust() is vFlags, and 2 of the available flags are TCP_ADJUST_PRESERVE_RX and TCP_ADJUST_PRESERVE_TX. I have successfully used this in one case to expand the RX FIFO dynamically to adjust for more efficient receipt of a large request. Well, actually it could be a real life scenario if one is servicing many remote connections, and trying to efficiently use RAM. There is no reason to have a 1k FIFO (or even 256) if one is expecting to receive small TCP messages and transmit small responses. |
|
|
|
|
|
-是的,如果使用保留缓冲区选项,或者扩展了缓冲区,那么一切都可以。问题在于,当缓冲区中包含了尚未被套接字用户发送或接收的数据时,需要小心。从一开始就选择合适的缓冲区,而不是这样做可能更好/更安全:它仍然是一个昂贵的操作,可能会导致内存分配和拷贝等。如果你真的知道所有的消息都很小,那么它可能是有意义的。但是不要指望那个套接字的性能会很慢。
以上来自于百度翻译 以下为原文 - Yes, if the preserve buffers option is used, or the buffers are expanded, then everything should be OK. The problem is with shrinking the buffers when they contain data that hasn't been transmitted yet or received by the socket user. So, you need to be careful. And probably better/safer to select the proper size of the buffers from the beginning rather than doing this: it is still an expensive operation, may result in memory allocations and copy, etc. - If you really know that all the messages are really small, then probably it makes sense. But don't expect any performance from that socket, it will be really slow. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1124浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1097浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 07:01 , Processed in 0.704446 second(s), Total 44, Slave 37 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2343