Involved Source Files The udpmux package contains the logic for multiplexing multiple WebRTC (ICE)
connections over a single UDP socket.muxed_connection.go
UDPMux multiplexes multiple ICE connections over a single net.PacketConn,
generally a UDP socket.
The connections are indexed by (ufrag, IP address family) and by remote
address from which the connection has received valid STUN/RTC packets.
When a new packet is received on the underlying net.PacketConn, we
first check the address map to see if there is a connection associated with the
remote address:
If found, we pass the packet to that connection.
Otherwise, we check to see if the packet is a STUN packet.
If it is, we read the ufrag from the STUN packet and use it to check if there
is a connection associated with the (ufrag, IP address family) pair.
If found we add the association to the address map.(*UDPMux) Accept(ctx context.Context) (Candidate, error) Close implements ice.UDPMux GetConn implements ice.UDPMux
It creates a net.PacketConn for a given ufrag if an existing one cannot be found.
We differentiate IPv4 and IPv6 addresses, since a remote is can be reachable at multiple different
UDP addresses of the same IP address family (eg. server-reflexive addresses and peer-reflexive addresses). GetListenAddresses implements ice.UDPMux RemoveConnByUfrag removes the connection associated with the ufrag and all the
addresses associated with that connection. This method is called by pion when
a peerconnection is closed.(*UDPMux) Start()
*UDPMux : github.com/pion/ice/v4.UDPMux
*UDPMux : github.com/prometheus/common/expfmt.Closer
*UDPMux : io.Closer
func NewUDPMux(socket net.PacketConn) *UDPMux
ReceiveBufSize is the size of the buffer used to receive packets from the PacketConn.
It is fine for this number to be higher than the actual path MTU as this value is not
used to decide the packet size on the write path.
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.