Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
filimonic opened this issue Mar 22, 2020 · 3 comments
Open

Comments

@filimonic
Copy link

@filimonic filimonic commented Mar 22, 2020

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

@andybons andybons changed the title Windows10 1909 : Can not send multicast using ListenPacket("udp4", "") net: cannot send multicast using ListenPacket("udp4", "") on Windows 10 (1909) Mar 23, 2020
@andybons andybons added this to the Unplanned milestone Mar 23, 2020
@andybons andybons added the OS-Windows label Mar 23, 2020
@andybons

This comment has been minimized.

Copy link
Member

@andybons andybons commented Mar 23, 2020

@andybons

This comment has been minimized.

Copy link
Member

@andybons andybons commented Mar 23, 2020

@filimonic

This comment has been minimized.

Copy link
Author

@filimonic filimonic commented Mar 24, 2020

Added screenshot. On today morning, same code fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.