我正在使用AutoIt的标准UDP功能。我测试并将UDP数据包转发到环回接口127.0.0.1(将udp数据包发送给自己)。我用RawCap捕获它,然后在Wireshark中打开它。它向我显示Header Check sum存在问题。为什么? 我可以以某种方式将HTTP封装在UDP内(使用AutoIt)吗?
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
HotKeySet("{esc}", "Cleanup")
HotKeySet("{enter}", "sendData")
Global $ConnectedSocket = -1
Global $MainSocket
Local $g_IP, $RogueSocket, $GOOEY, $edit, $input, $butt, $msg
Local $ret, $recv
$g_IP = "127.0.0.1"
$_INCOMING_FLAG = "UDP DATA: "
OnAutoItExitRegister ("Cleanup")
; 1. UDP Listener ### Start The UDP Services ###
;==============================================
UDPStartup()
OnAutoItExitRegister ("Cleanup")
; 1. UDP Listener ### Create a Listening "SOCKET"
;==============================================
$socket = UDPBind($g_IP, 65432)
If @error <> 0 Then Exit
; 3. GUI ### Create a GUI for chatting
;==============================================
$GOOEY = GUICreate("P2P Chat", 300, 200)
$edit = GUICtrlCreateEdit("", 10, 40, 280, 150, $WS_DISABLED)
$input = GUICtrlCreateInput("", 10, 10, 200, 20)
$butt = GUICtrlCreateButton("Send", 210, 10, 80, 20, $BS_DEFPUSHBUTTON)
GUISetState()
; GUI Message Loop
;==============================================
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
If $msg = $butt Then sendData()
$data = UDPRecv($socket, 200)
If $data <> "" Then
GUICtrlSetData($edit, GUICtrlRead($edit) & $_INCOMING_FLAG &$data & @CRLF)
EndIf
;~ Sleep(50)
WEnd
GUIDelete($GOOEY)
Func sendData()
If $socket <> 0 Then
$status = UDPSend($socket, GUICtrlRead($input))
If $status = 0 Then
MsgBox(0, "ERROR", "Error while sending UDP message: " & @error)
Exit
EndIf
ElseIf $ret > 0 Then
; UPDATE EDIT CONTROL WITH DATA WE SENT
;----------------------------------------------------------------
GUICtrlSetData($edit, GUICtrlRead($edit) & GUICtrlRead($input) & @CRLF)
GUICtrlSetData($input, "")
EndIf
EndFunc ;==>sendData
Func Lookup()
; If no connection look for one
Return 0
EndFunc ;==>Lookup
Func Cleanup()
UDPCloseSocket($socket)
UDPShutdown()
EndFunc ;==>Cleanup
答案 0 :(得分:1)
我猜所有错误的校验和都是0x0000
;在这种情况下,您可能会遇到TCP Checksum Offloading。这是操作系统试图让网络硬件计算校验和(这将减少CPU上的负载)。这些校验和在您的应用程序中不是错误。