0

I have an iOS application that remotely connects to 3 sockets(of some hardware). Each Socket has its own priority. One channel is only used for transferring messages between iPad App & hardware, one for Tx/Rx Images, another one for Tx/Rx Videos. I had implemented all the three sockets using GCDAsyncSocket API & things worked fine while using MSGSocket/ImageSocket (OR) MSGSocket/VideoSocket, but when I start using the VideoSocket/ImageSocket/MSGSocket simultaneously this is where things go a little haywire. I Lose Packets of Data.{Actually a chunk of file goes missing :-(} I went through the API & found some bug in the API: Unable to complete Read Stream which I assumed could be a cause of problem. Hence, I Switched to threads & implemented the same using NSThreads/CFSocket API.

I changed only the implementation for ImageSocket/VideoSocket code using NSThreads/CFSocket API & here is the implementation of the same dropbox-ed. I'm just unable to understand as to where the things are going wrong whether it is at iOS App end or at the Server side. In my understanding there shall be no loss of packets in TCP Communication.

Is there a way to Debug This issue. Also I request to go through the code & let me know if any thing is wrong(I know this can be too much that I'm asking for but I need some assurance as to the code implementation is correct). Any help to resolve this issue will be highly appreciated.

EDIT 1: After @JoeMcMahon Comment, I referred to this Technical Q&A & got a TCP Dump - trace.pcap file. I opened this tcp dump with Wireshark & it does show me the bytes transferred between the ports of hardware & iPad. Also in the terminal when I stopped the tcp dump capture I saw these messages:
12463 packets captured
36469 packets received by filter
0 packets dropped by kernel
Can someone point out the difference between packets captured & packets received by filter?
Note - The TCP dump attached is not for a failed scenario.
EDIT 1.1: Found the answer to difference between packets captured & packets received by filter here

4

1 回答 1

0

TCP 通信不保证可靠。基本的 ack-syn 范式可能会中断,这就是为什么您有重传机制等。Wireshark 在您的数据包捕获会话中报告此类问题。

对于使用wireshark/tcpdump,您通常需要提供一个过滤器,因为通过线路的流量是压倒性的(ping、ntp 等),您需要使用一些基本过滤器过滤捕获以查看相关的数据包给你。被过滤掉的数据包没有被捕获,因此存在数值差异。

如果丢失了一大块文件,我怀疑问题出在 TCP 级别。很可能是更高级别的错误。我会通过通道反复运行一个固定大小的文件,直到我可以可靠地重现损失。

于 2014-10-27T00:52:23.047 回答