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

Why does lite agent dial when checking connectivity? #510

Open
lugy-bupt opened this issue Dec 29, 2022 · 0 comments
Open

Why does lite agent dial when checking connectivity? #510

lugy-bupt opened this issue Dec 29, 2022 · 0 comments
Labels
question Further information is requested

Comments

@lugy-bupt
Copy link

lugy-bupt commented Dec 29, 2022

I am learning the ice logic about ice-lite and found an interesting case TestConnectivityLite in agent_test.go

There are 2 agents, aAgent works as full ice agent and bAgent works as lite ice agent, in TestConnectivityLite case. They connect each other in function connectWithVNet

	cfg0 := &AgentConfig{
		Urls:             []*URL{stunServerURL},
		NetworkTypes:     supportedNetworkTypes(),
		MulticastDNSMode: MulticastDNSModeDisabled,
		//Net:              v.net0,
	}

	aAgent, err := NewAgent(cfg0)
	require.NoError(t, err)
	require.NoError(t, aAgent.OnConnectionStateChange(aNotifier))

	cfg1 := &AgentConfig{
		Urls:             []*URL{},
		Lite:             true,
		CandidateTypes:   []CandidateType{CandidateTypeHost},
		NetworkTypes:     supportedNetworkTypes(),
		MulticastDNSMode: MulticastDNSModeDisabled,
		//Net:              v.net1,
	}

	bAgent, err := NewAgent(cfg1)
	require.NoError(t, err)
	require.NoError(t, bAgent.OnConnectionStateChange(bNotifier))

	aConn, bConn := connectWithVNet(aAgent, bAgent)

In connectWithVNet, the 2 agent start to check the connectivity after they exchange their candidates, like below code. But why, bAgent start to Dial instead of aAgent calling Accept? The bAgent is a lite agent, maybe it should be listener according RFC 5245.

# RFC 5245 https://www.rfc-editor.org/rfc/rfc5245#page-30

   One agent full, one lite:  The full agent MUST take the controlling
      role, and the lite agent MUST take the controlled role.  The full
      agent will form check lists, run the ICE state machines, and
      generate connectivity checks.  That agent will execute the logic
      in Section 8.1 to nominate pairs that will be selected by ICE, and
      use the logic in Section 8.1.2 to end ICE.  The lite
      implementation will just listen for connectivity checks, receive
      them and respond to them, and then conclude ICE as described in
      Section 8.2.  For the lite implementation, the state of ICE
      processing for each media stream is considered to be Running, and
      the state of ICE overall is Running.
	accepted := make(chan struct{})
	var aConn *Conn

	go func() {
		var acceptErr error
		aConn, acceptErr = aAgent.Accept(context.TODO(), bUfrag, bPwd)
		check(acceptErr)
		close(accepted)
	}()

	bConn, err := bAgent.Dial(context.TODO(), aUfrag, aPwd)
	check(err)
	
@stv0g stv0g added the question Further information is requested label Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

No branches or pull requests

2 participants