I want to do a simulation with several nodes on different machines. I know IP addresses of all these machines and also ports they are listening to. How can I use host.Connect to connect to those nodes? I have tried to create a multiaddr from the ip address and port but there was an error stating that the address is not a valid p2p address.
Interesting question… I think this is not possible to
host.Connectwithout knowing the peer ID.
Assuming you know the machines and ports, you could also pregenerate the peer keys/IDs ?
Also, libp2p peer use mDNS for autodiscovery, which essentially is broadcasting their full addresses and peer IDs to the local network. If you are in a local network, you could try letting all peers discover each others automatically (https://github.com/libp2p/go-libp2p/blob/master/p2p/discovery/mdns.go).