Skip to content

net: cannot send multicast using ListenPacket("udp4", "") on Windows 10 (1909) #37998

@filimonic

Description

@filimonic

What version of Go are you using (go version)?

go version go1.14.1 windows/amd64

Does this issue reproduce with the latest release?

Yes, with 1.14 and 1.14.1 ( never tested earlier )

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\ADFilimonov\AppData\Local\go-build
set GOENV=C:\Users\ADFilimonov\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\ADFilimonov\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADFILI~1\AppData\Local\Temp\go-build411155850=/tmp/go-build -gno-record-gcc-switches

What did you do?

Single file in directory: mctest_test.go :

package mctest

import (
	"net"
	"testing"
	"time"
)

var (
	bulbMulticastAddr *net.UDPAddr   = &net.UDPAddr{IP: net.IPv4(239, 255, 255, 250), Port: 1982}
	bulbSearchRequest []byte         = []byte("M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:1982\r\nMAN:\"ssdp:discover\"\r\nST:wifi_bulb\r\n")
	bulbSearchConn    net.PacketConn = nil
)

func TestMC(t *testing.T) {
	testMulticast(5)
}

func testMulticast(timeout int) error {
	bulbSearchConn, err := net.ListenPacket("udp4", "")
	if err != nil {
		return err
	}

	readDeadlineTime := time.Now().Add(time.Second * time.Duration(timeout))
	err = bulbSearchConn.SetReadDeadline(readDeadlineTime)
	if err != nil {
		return err
	}

	_, err = bulbSearchConn.WriteTo(bulbSearchRequest, bulbMulticastAddr)
	if err != nil {
		return err
	}

	time.Sleep(time.Second * time.Duration(10))
	return nil
}

  1. I run Wireshark on two interfaces ( "Ethernet" and "Adapter for loopback traffic capture" ) with filter udp port 1982.
  2. I run code
CD /D S:\PRJ\doesntmatter\pkg\mctest
go test
  1. I monitor packets wireshark shows.

What did you expect to see?

Expected 2 packets with source = "ip-of-my-ethernet", target "mulicast address", one using Ethernet interface and one using loopback interface

What did you see instead?

Sometimes everything is right ( I see everything as expected ). And sometimes I see
1 packet with source = "127.0.0.1", target "mulicast address", using loopback interface.

I can not determine, what happens with my envinronment to "switch" this behaviour. After system reboot I can see it working and some time after it stops, ot vice-versa.

SCREENSHOTS

Wireshark setup

WSCAP_SETUP

Wireshark shows OK

WSCAP_WHEN_OK

Wireshark shows NOT OK

Sorry I have no screenshot now. It happens periodically each few days. I try add later
Update: Added Screenshot
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windows

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions