我嘗試使用UDP通過本地網絡傳輸大量數據,並使用QT作爲Socket訪問的框架。發送簡單消息到目前爲止不是問題。 但是,我沒有(完全)理解如何處理包的分割以及由誰來完成。UDP拆分/合併。哪一層處理它? (QT Networking)
所以QT指出:
發送數據包大於512個字節是一般disadvised,因爲即使它們被成功發送,他們很可能要由IP層在他們到達最終目的地之前支離破碎。
因此我實現了我自己的小協議來處理大數據的拆分和合並。具有更大的尺寸大於512個字節(在10kBytes的順序)播放的時候,我遇到了下面的代碼片段從Wireshark的:
"17","0.145050","192.168.2.111","192.168.2.222","IPv4","1514","Fragmented IP protocol (proto=UDP 17, off=0, ID=3a47) [Reassembled in #23]"
"18","0.145051","192.168.2.111","192.168.2.222","IPv4","1514","Fragmented IP protocol (proto=UDP 17, off=1480, ID=3a47) [Reassembled in #23]"
"19","0.145051","192.168.2.111","192.168.2.222","IPv4","1514","Fragmented IP protocol (proto=UDP 17, off=2960, ID=3a47) [Reassembled in #23]"
"20","0.145051","192.168.2.111","192.168.2.222","IPv4","1514","Fragmented IP protocol (proto=UDP 17, off=4440, ID=3a47) [Reassembled in #23]"
"21","0.145052","192.168.2.111","192.168.2.222","IPv4","1514","Fragmented IP protocol (proto=UDP 17, off=5920, ID=3a47) [Reassembled in #23]"
"22","0.145052","192.168.2.111","192.168.2.222","IPv4","1514","Fragmented IP protocol (proto=UDP 17, off=7400, ID=3a47) [Reassembled in #23]"
"23","0.145052","192.168.2.111","192.168.2.222","UDP","1186","63230 > 8007 Len=10024"
,並從我得到一個數據報在QT。 對我來說,似乎IP層已經在分解/合併我的(太大)UDP數據包了。 所以:
- 爲什麼建議我自己拆分UDP數據?
- 「誰」處理IP層? (QT,Windows,網絡硬件?)
- 我假設在UDP套接字中有讀寫緩衝區產生的第二個限制,我可以在哪裏檢查?