简体   繁体   English

为什么在AutoIt UDP协议中出现标头校验和错误?

[英]Why do I have header checksum erro in AutoIt UDP protocol?

I am using standart UDP function of AutoIt. 我正在使用AutoIt的标准UDP功能。 I tested and dumped UDP packets to loopback interface 127.0.0.1 (send udp packets to myself). 我测试了UDP数据包并将其转储到回送接口127.0.0.1(向自己发送udp数据包)。 I captured it with RawCap, then opened in Wireshark. 我用RawCap捕获了它,然后在Wireshark中打开了它。 It showed me that there is a problem with Header Check sum. 它告诉我报头校验和有问题。 Why? 为什么? Can I somehow encapsulate HTTP inside UDP (using AutoIt)? 我能以某种方式(使用AutoIt)将HTTP封装在UDP中吗?

在此处输入图片说明

    #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

I'm guessing all of the errant checksums are 0x0000 ; 我猜所有错误的校验和都是0x0000 ; in that case, you are probably running into TCP Checksum Offloading . 在这种情况下,您可能正在运行TCP Checksum Offloading This is the operating system trying to let the networking hardware calculate the checksum (which will reduce load on the CPU). 这是试图让网络硬件计算校验和的操作系统(这将减少CPU的负载)。 These checksums are not an error in your application. 这些校验和不是您的应用程序中的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM