/// <summary>
        /// Creates peers for benchmarking. The first peer will be used as the master.
        /// This means that shutting down the master will shut down all other peers as well.
        /// </summary>
        /// <param name="nrOfPeers">Number of peers to create.</param>
        /// <param name="rnd">The random object used for peer ID creation.</param>
        /// <param name="port">The UDP and TCP port.</param>
        /// <param name="maintenance">Indicates whether maintenance should be enabled.</param>
        /// <param name="timeout">Indicates whether timeout should be enabled.</param>
        /// <returns></returns>
        public static Peer[] CreateNodes(int nrOfPeers, InteropRandom rnd, int port, bool maintenance, bool timeout)
        {
            Console.WriteLine("Creating network with {0} peers...", nrOfPeers);

            var peers = new Peer[nrOfPeers];

            var masterId = CreateRandomId(rnd);
            var masterMap = new PeerMap(new PeerMapConfiguration(masterId));
            var pb = new PeerBuilder(masterId)
                .SetPorts(port)
                .SetEnableMaintenance(maintenance)
                .SetExternalBindings(new Bindings())
                .SetPeerMap(masterMap);
            if (!timeout)
            {
                pb.SetChannelServerConfiguration(CreateInfiniteTimeoutChannelServerConfiguration(port));
            }
            peers[0] = pb.Start();
            //Logger.Info("Created master peer: {0}.", peers[0].PeerId);

            for (int i = 1; i < nrOfPeers; i++)
            {
                peers[i] = CreateSlave(peers[0], rnd, maintenance, timeout);
            }
            return peers;
        }
 private static Peer CreateSlave(Peer master, InteropRandom rnd, bool maintenance, bool timeout)
 {
     var slaveId = CreateRandomId(rnd);
     var slaveMap = new PeerMap(new PeerMapConfiguration(slaveId).SetPeerNoVerification());
     var pb = new PeerBuilder(slaveId)
         .SetMasterPeer(master)
         .SetEnableMaintenance(maintenance)
         .SetExternalBindings(new Bindings())
         .SetPeerMap(slaveMap);
     if (!timeout)
     {
         pb.SetChannelServerConfiguration(CreateInfiniteTimeoutChannelServerConfiguration(Ports.DefaultPort));
     }
      var slave = pb.Start();
     //Logger.Info("Created slave peer {0}.", slave.PeerId);
     return slave;
 }