예제 #1
0
 /**
 <summary>Creates an Information object for the node and type of service
 provider.</summary>
 <param name="node">The node where the service is to be provided</param>
 <param name="type">The name of the application providing service (example:
 BasicNode)</param>
 */
 public Information(StructuredNode node, String type) {
   UserData = new Hashtable();
   _type = type;
   _node = node;
   _rpc = RpcManager.GetInstance(node);
   _rpc.AddHandler("Information", this);
 }
예제 #2
0
 public SocialRpcHandler(StructuredNode node, SocialUser localUser,
                    Dictionary<string, SocialUser> friends)
 {
     _node = node;
       _rpc = node.Rpc;
       _rpc.AddHandler("SocialVPN", this);
       _local_user = localUser;
       _friends = friends;
 }
예제 #3
0
파일: LocalHT.cs 프로젝트: xujyan/hurricane
        public LocalHT()
        {
            AHAddress addr = new AHAddress(new RNGCryptoServiceProvider());
              Node brunetNode = new StructuredNode(addr);
              RpcManager rpc = RpcManager.GetInstance(brunetNode);
              this._ts = new TableServer(brunetNode);
              this._node = brunetNode;

            #if FUSE_DEBUG
              //Having some init data isn't bad
              string key = FuseDhtUtil.GenDhtKey("testbasedir", "testkey1", "ipop_ns");
              this.Put(key, "testvalue1", 5000);
              this.Put(key, "testvalue2", 3000);
            #endif
        }
예제 #4
0
 public void Test() {
   RandomNumberGenerator rng = new RNGCryptoServiceProvider();      
   AHAddress tmp_add = new AHAddress(rng);
   Node n = new StructuredNode(tmp_add, "unittest");
   AHSender ah = new AHSender(n, AddressParser.Parse("brunet:node:JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4"));
   ForwardingSender fs = new ForwardingSender(n, 
                                              AddressParser.Parse("brunet:node:JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4"),
                                              AddressParser.Parse("brunet:node:5FMQW3KKJWOOGVDO6QAQP65AWVZQ4VUQ"));
   
   string uri = "sender:ah?dest=brunet:node:JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4&mode=exact";
   ISender s = SenderFactory.CreateInstance(n, uri);
   Assert.IsTrue(s is AHSender);
   Assert.AreEqual(uri, s.ToUri());
   uri = "sender:ah?dest=brunet:node:JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4&mode=greedy";
   s = SenderFactory.CreateInstance(n, uri);
   Assert.IsTrue(s is AHSender);
   Assert.AreEqual(uri, s.ToUri());      
   uri = "sender:fw?relay=brunet:node:JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4&init_mode=greedy&dest=brunet:node:5FMQW3KKJWOOGVDO6QAQP65AWVZQ4VUQ&ttl=3&mode=path";
   s = SenderFactory.CreateInstance(n, uri);
   Assert.IsTrue(s is ForwardingSender);
   Assert.AreEqual(uri, s.ToUri());
 }
예제 #5
0
    private static void add_node() {
      int local_port = 0;
//      while(taken_ports.Contains(local_port = rand.Next(0, max_range) + base_port));
      AHAddress address = new AHAddress(new RNGCryptoServiceProvider());
      Node node = new StructuredNode(address, brunet_namespace);
/*      ArrayList arr_tas = new ArrayList();
      for(int j = 0; j < max_range / 10; j++) {
        int remote_port = 0;
        do {
          remote_port = rand.Next(0, max_range) + base_port;
        } while(remote_port == local_port);
        PortTAAuthorizer port_auth = new PortTAAuthorizer(remote_port);
        arr_tas.Add(port_auth);
      }
      arr_tas.Add(new ConstantAuthorizer(TAAuthorizer.Decision.Allow));
      TAAuthorizer ta_auth = new SeriesTAAuthorizer(arr_tas);*/
      node.AddEdgeListener(new FunctionEdgeListener((new Random()).Next(1024, 65535))); //local_port, null));//, ta_auth));
//      node.AddEdgeListener(new TunnelEdgeListener(node));
//      node.RemoteTAs = RemoteTA;
      (new Thread(node.Connect)).Start();
//      taken_ports[local_port] = node;
      nodes.Add((Address) address, node);
      dhts.Add(node, new Dht(node, DEGREE));
      network_size++;
    }
예제 #6
0
    static void Main(string[] args)
    {
      //first, remove the log file
      if(File.Exists("time_stamp.log")){
	File.Delete("time_stamp.log");
      }

      String config_file = args[0];
      NetworkConfiguration network_configuration = NetworkConfiguration.Deserialize(config_file);

      int port_selection = Convert.ToInt32(args[1]); //There will be 10 different ports available for use: 0, 1, 2..
      //for example, node 0 on a machine will use port_selection # 0, node 1 on a machine will use port_selection # 1

      ///There will be multiple BruNet nodes on the same machine. The following is a list of possible ports used
      int list_size = 10;
      int [] port_list = new int[list_size];
      for(int i = 0; i < list_size; i++){
	port_list[i] = 25010 + i*10;
      }
	
      ///The line below is used when there is only one node per machine
      //int local_host_index = network_configuration.GetLocalHostIndex();                                                                
	
      int desired_port = port_list[port_selection];
      int local_host_index = network_configuration.GetLocalHostIndex(desired_port); 

      NodeConfiguration this_node_configuration = (NodeConfiguration)network_configuration.Nodes[local_host_index];
      TransportAddressConfiguration local_ta_configuration = (TransportAddressConfiguration)this_node_configuration.TransportAddresses[0];
      short port = local_ta_configuration.Port;

      SHA1 sha = new SHA1CryptoServiceProvider();
      String local_ta = local_ta_configuration.GetTransportAddressURI();
      //We take the local transport address plus the port number to be hashed to obtain a random AHAddress
      byte[] hashedbytes = sha.ComputeHash(Encoding.UTF8.GetBytes(local_ta + port));
      //inforce type 0
      hashedbytes[Address.MemSize - 1] &= 0xFE;
      AHAddress _local_ahaddress = new AHAddress(hashedbytes);
      Node this_node = new StructuredNode( _local_ahaddress );
      ///Node this_node = new HybridNode( new AHAddress( new BigInteger( 2*(local_host_index+1) ) ) );      

      String file_string = "brunetadd" + Convert.ToString(desired_port) + ".log";
      StreamWriter sw = new StreamWriter(file_string, false);
      sw.WriteLine( "local_address " + this_node.Address.ToBigInteger().ToString() + " " + Dns.GetHostName()); 
      sw.Close();      

      if ( local_ta_configuration.Protocol == "tcp" ) {
        this_node.AddEdgeListener( new TcpEdgeListener(port) );
      } 
      else if( local_ta_configuration.Protocol == "udp" ) {
        this_node.AddEdgeListener( new UdpEdgeListener(port) );        
      }

      int remote_node_index = local_host_index-1;
      int num_remote_ta = 20; //20 nodes on the list to try to bootstrap to

      if (local_host_index!=0) {
        NodeConfiguration remote_node_configuration = (NodeConfiguration)network_configuration.Nodes[0];
        TransportAddressConfiguration remote_ta_configuration = (TransportAddressConfiguration)remote_node_configuration.TransportAddresses[0];

        String remote_ta = remote_ta_configuration.GetTransportAddressURI(); 
        this_node.RemoteTAs.Add( TransportAddressFactory.CreateInstance( remote_ta  ) );
      }
      
      while ( (remote_node_index>=0) && (num_remote_ta>=0) ) { 
        NodeConfiguration remote_node_configuration = (NodeConfiguration)network_configuration.Nodes[remote_node_index];
        TransportAddressConfiguration remote_ta_configuration = (TransportAddressConfiguration)remote_node_configuration.TransportAddresses[0];

        String remote_ta = remote_ta_configuration.GetTransportAddressURI(); 
        this_node.RemoteTAs.Add( TransportAddressFactory.CreateInstance( remote_ta  ) );

        System.Console.WriteLine("Adding {0}", remote_ta);

          remote_node_index--;
          num_remote_ta--;
        }

      //EchoTester echo_printer = new EchoTester();
      //this_node.Subscribe(AHPacket.Protocol.Echo, echo_printer);
      StreamWriter stamp_sw = new StreamWriter("time_stamp.log", true);
      stamp_sw.WriteLine("Local_node: {0} start_time_GMT: {1}:{2}", Dns.GetHostName(), DateTime.Now.ToUniversalTime().ToString(),
			DateTime.Now.ToUniversalTime().Millisecond );
      stamp_sw.Close();

      this_node.Connect();

    }
예제 #7
0
파일: BrunetApp.cs 프로젝트: xujyan/brunet
    static void Main(string[] args)
    {

      BootStrapTester bst = new BootStrapTester();
      //NodeList
      ArrayList node_list = new ArrayList();
      bst.NodeList = node_list;
      ArrayList all_ta_list = new ArrayList();
      Random my_rand = new Random( unchecked((int)DateTime.Now.Ticks) );

      //Initialize hosts
      //Console.WriteLine("\n\n---------------------------------------\n\n");
      int port = 20287;
      int net_size = Int32.Parse( args[0] );

      for (int loop=0;loop<net_size;loop++)
      {
        //create and initialize new host
        //create one new node for each host
        //Set the last bit to be zero so it will be class 0

        //byte[] address = new byte[Address.MemSize];
        //my_rand.NextBytes(address);
        //address[Address.MemSize - 1] &= 0xFE;
        //Node tmp_node = new StructuredNode(new AHAddress(address));
        long small_add = 2*(loop+1);
        Node tmp_node = new StructuredNode(new AHAddress( new BigInteger(small_add)) );
        //tmp_node.AddEdgeListener(new TcpEdgeListener(port+loop));
        tmp_node.AddEdgeListener(new FunctionEdgeListener(port+loop));
        for (int loop2=0;loop2<loop;loop2++)
        {
          if (loop != loop2)
          {
            int other_port = port+loop2;
            tmp_node.RemoteTAs.Add(
              //new TransportAddress("brunet.tcp://128.97.89.79:" + other_port )
              TransportAddressFactory.CreateInstance("brunet.function://localhost:" + other_port )
            );
          }
        }
        node_list.Add(tmp_node);
      }

      //testAddressComparer(node_list);

      //Start the dot thread:
      System.Threading.Thread t = new System.Threading.Thread(
                                    new System.Threading.ThreadStart(bst.DotThread));
      t.Start();
      //Get Connected:
      int i=0;
      foreach( Node item in node_list)
      {
        System.Console.WriteLine("{0}: CONNECTING NODE: {1}", ++i, item.Address);
        System.Console.WriteLine("--------------------------");
        item.Connect();
        /*Console.WriteLine(item.Address.ToString()
          + " RemoteTAs count: " + item.RemoteTAs.Count);*/

        //Console.ReadLine();

        //foreach (TransportAddress item2 in item.RemoteTAs)
        //  Console.WriteLine(item2);

      }

      Console.WriteLine("BeforeDisconnect");
      Console.ReadLine();
      Node anode = (Node)node_list[5];
      anode.Disconnect();

      //We are connected now, stop the threads:
      //t.Abort();
    }
예제 #8
0
파일: BasicNode.cs 프로젝트: myidpt/brunet
    /**
    <summary>Creates a Brunet.Node, the resulting node will be available in
    the class as _node.</summary>
    <remarks>The steps to creating a node are first constructing it with a
    namespace, optionally adding local ip addresses to bind to, specifying
    local end points, specifying remote end points, and finally registering
    the dht.</remarks>
    */
    public virtual void CreateNode() {
      AHAddress address = (AHAddress) AddressParser.Parse(_node_config.NodeAddress);
      _node = new StructuredNode(address, _node_config.BrunetNamespace);
      IEnumerable addresses = IPAddresses.GetIPAddresses(_node_config.DevicesToBind);

      Brunet.EdgeListener el = null;
      foreach(NodeConfig.EdgeListener item in _node_config.EdgeListeners) {
        int port = item.port;
        if (item.type =="tcp") {
          try {
            el = new TcpEdgeListener(port, addresses);
          }
          catch {
            el = new TcpEdgeListener(0, addresses);
          }
        }
        else if (item.type == "udp") {
          try {
            el = new UdpEdgeListener(port, addresses);
          }
          catch {
            el = new UdpEdgeListener(0, addresses);
          }
        }
        else {
          throw new Exception("Unrecognized transport: " + item.type);
        }
        _node.AddEdgeListener(el);
      }
      el = new TunnelEdgeListener(_node);
      _node.AddEdgeListener(el);

      ArrayList RemoteTAs = null;
      if(_node_config.RemoteTAs != null) {
        RemoteTAs = new ArrayList();
        foreach(String ta in _node_config.RemoteTAs) {
          RemoteTAs.Add(TransportAddressFactory.CreateInstance(ta));
        }
        _node.RemoteTAs = RemoteTAs;
      }

      try {
        if (_node_config.NCService.Enabled) {
          _ncservice = new NCService(_node, _node_config.NCService.Checkpoint);

          if (_node_config.NCService.OptimizeShortcuts) {
            _node.Sco.TargetSelector = new VivaldiTargetSelector(_node, _ncservice);
          }
        }
      } catch {}
      _dht = new Dht(_node, 3, 20);
    }
예제 #9
0
    public void Test() {
      RandomNumberGenerator rng = new RNGCryptoServiceProvider();      
      AHAddress tmp_add = new AHAddress(rng);
      Node n = new StructuredNode(tmp_add, "unittest");
      AHSender ah = new AHSender(n, AddressParser.Parse("brunet:node:JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4"));
      ForwardingSender fs = new ForwardingSender(n, 
                                                 AddressParser.Parse("brunet:node:JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4"),
                                                 AddressParser.Parse("brunet:node:5FMQW3KKJWOOGVDO6QAQP65AWVZQ4VUQ"));
      
      string uri = "sender:ah?dest=JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4&mode=exact";
      ISender s = SenderFactory.CreateInstance(n, uri);
      Assert.IsTrue(s is AHSender);
      Assert.AreEqual(uri, s.ToUri());
      uri = "sender:ah?dest=JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4&mode=greedy";
      
      //Create the above programatically
      IDictionary<string, string> param_args = new Dictionary<string,string>();
      param_args["dest"] = "JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4";
      param_args["mode"] = "greedy";
      string uri0 = SenderFactory.EncodeUri("ah", param_args); 
      Assert.AreEqual(uri, uri0, "EncodeUri works");
      //Check decode:
      string scheme;
      param_args = SenderFactory.DecodeUri(uri, out scheme);
      Assert.AreEqual(scheme, "ah", "Scheme decoded");
      Assert.AreEqual(param_args.Count, 2, "2 parameters in uri");
      Assert.AreEqual(param_args["dest"], "JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4", "Extracted address");
      Assert.AreEqual(param_args["mode"], "greedy", "got mode");

      s = SenderFactory.CreateInstance(n, uri);
      Assert.IsTrue(s is AHSender);
      Assert.AreEqual(uri, s.ToUri());      
      string furi = "sender:fw?relay=JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4&init_mode=greedy&dest=5FMQW3KKJWOOGVDO6QAQP65AWVZQ4VUQ&ttl=3&mode=path";
      s = SenderFactory.CreateInstance(n, furi);
      Assert.IsTrue(s is ForwardingSender);
      Assert.AreEqual(furi, s.ToUri());
    }
예제 #10
0
    static void Main(string[] args)
    {
    //log.Debug( "Starting the Brunet Echo Tester" );

      String config_file = args[0];
      NetworkConfiguration network_configuration = NetworkConfiguration.Deserialize(config_file);

      int port_selection = Convert.ToInt32(args[1]); //There will be 10 different ports available for use: 0, 1, 2..
      //for example, node 0 on a machine will use port_selection # 0, node 1 on a machine will use port_selection # 1

      ///There will be multiple BruNet nodes on the same machine. The following is a list of possible ports used
      int list_size = 150;
      int [] port_list = new int[list_size];
      for(int i = 0; i < list_size; i++){
	port_list[i] = 25000 + i;
      }
	
      ///The line below is used when there is only one node per machine
      //int local_host_index = network_configuration.GetLocalHostIndex();                                                                
	
      int desired_port = port_list[port_selection];
      int local_host_index = network_configuration.GetLocalHostIndex(desired_port); 

      NodeConfiguration this_node_configuration = (NodeConfiguration)network_configuration.Nodes[local_host_index];
      TransportAddressConfiguration local_ta_configuration = (TransportAddressConfiguration)this_node_configuration.TransportAddresses[0];
      short port = local_ta_configuration.Port;

      SHA1 sha = new SHA1CryptoServiceProvider();
      String local_ta = local_ta_configuration.GetTransportAddressURI();
      //We take the local transport address plus the port number to be hashed to obtain a random AHAddress
      byte[] hashedbytes = sha.ComputeHash(Encoding.UTF8.GetBytes(local_ta + port));
      //inforce type 0
      hashedbytes[Address.MemSize - 1] &= 0xFE;
      AHAddress _local_ahaddress = new AHAddress(hashedbytes);
      Node this_node = new StructuredNode( _local_ahaddress );
      ///Node this_node = new HybridNode( new AHAddress( new BigInteger( 2*(local_host_index+1) ) ) );      

      String file_string = "./data/brunetadd" + Convert.ToString(desired_port) + ".log";
      StreamWriter sw = new StreamWriter(file_string, false);
      sw.WriteLine( "local_address " + this_node.Address.ToBigInteger().ToString() + " " + Dns.GetHostName()
		      + ":" + port); 
      sw.Close();

      if ( local_ta_configuration.Protocol == "tcp" ) {
        this_node.AddEdgeListener( new TcpEdgeListener(port) );
      } 
      else if( local_ta_configuration.Protocol == "udp" ) {
        this_node.AddEdgeListener( new UdpEdgeListener(port) );        
      }

      int remote_node_index = local_host_index-1;
      int num_remote_ta = 20; //20 nodes on the list to try to bootstrap to

      if (local_host_index!=0) {
        NodeConfiguration remote_node_configuration = (NodeConfiguration)network_configuration.Nodes[0];
        TransportAddressConfiguration remote_ta_configuration = (TransportAddressConfiguration)remote_node_configuration.TransportAddresses[0];

        String remote_ta = remote_ta_configuration.GetTransportAddressURI(); 
        this_node.RemoteTAs.Add( TransportAddressFactory.CreateInstance( remote_ta  ) );
      }
      
      while ( (remote_node_index>=0) && (num_remote_ta>=0) ) { 
        NodeConfiguration remote_node_configuration = (NodeConfiguration)network_configuration.Nodes[remote_node_index];
        TransportAddressConfiguration remote_ta_configuration = (TransportAddressConfiguration)remote_node_configuration.TransportAddresses[0];

        String remote_ta = remote_ta_configuration.GetTransportAddressURI(); 
        this_node.RemoteTAs.Add( TransportAddressFactory.CreateInstance( remote_ta  ) );

        System.Console.WriteLine("Adding {0}", remote_ta);

          remote_node_index--;
          num_remote_ta--;
        }

     /* NodeConfiguration remote_node_configuration = (NodeConfiguration)network_configuration.Nodes[remote_node_index];
      TransportAddressConfiguration remote_ta_configuration = (TransportAddressConfiguration)remote_node_configuration.TransportAddresses[0];

      String remote_ta = remote_ta_configuration.GetTransportAddressURI(); 
      this_node.RemoteTAs.Add( TransportAddressFactory.CreateInstance( remote_ta  ) );*/
 
      EchoTester echo_printer = new EchoTester();
      this_node.GetTypeSource(PType.Protocol.Echo).Subscribe(echo_printer, this_node);

      this_node.Connect();

       //Send a "hello message" to a random neighbor

      ASCIIEncoding ascii = new ASCIIEncoding();

      //Make the target addresses      
      AHAddress target  = new AHAddress( new BigInteger( 2*(remote_node_index+1) ) );

      string hello_msg = "hello, brunet";
      int byteCount = ascii.GetByteCount(hello_msg);
      byte[] bytes = new byte[byteCount + 1];
      ascii.GetBytes(hello_msg, 0, hello_msg.Length, bytes, 1);

      // update the payload
      // This is a request, so the first byte is greater than zero
      bytes[0] = (byte) 1;
      ICopyable p = new CopyList(PType.Protocol.AH,
                                 new AHHeader(0, 30, this_node.Address,
                                              target, AHHeader.Options.Greedy),
                                 PType.Protocol.Echo, MemBlock.Reference(bytes));

      ///RDP Experiment: sending the echo packet periodically
/*      int seq = 0;
      while(true){
	int start_time = System.DateTime.Now.Millisecond;
	this_node.Send(p);
	Console.WriteLine("Seq = {0}, Start Time = {1}", seq, start_time);
        System.Threading.Thread.Sleep(10000);
	seq++;
      }*/


///The following is a while-loop for the local node to Brunet-ping all other nodes in the network
      System.Threading.Thread.Sleep(60000);  ///IMPORTANT: change this parameter so we wait longer for larger network
      Random uid_generator = new Random( DateTime.Now.Millisecond + local_ta.GetHashCode() + port);
      bytes = new byte[5];
      int target_index = 0, num_pings = 10, wait_time = 10000; //the wait_time is in ms
      double ping_time;
      PingWrapper pw = new PingWrapper();    
      
      while( target_index < network_configuration.Nodes.Count ){
 
 	  if(target_index != local_host_index){///we do not ping the local machine
	      NodeConfiguration target_node_configuration = (NodeConfiguration)network_configuration.Nodes[target_index];
	      TransportAddressConfiguration target_ta_configuration = (TransportAddressConfiguration)target_node_configuration.TransportAddresses[0];
	      short target_port = target_ta_configuration.Port;
	      double ping1 = pw.Ping(target_ta_configuration.Address, 10000);
	      double ping2 = pw.Ping(target_ta_configuration.Address, 10000);
	      if(ping1 >= 0 || ping2 >= 0){ //we gather the data only when the node is ping-able
		  sha = new SHA1CryptoServiceProvider();
		  String target_ta = target_ta_configuration.GetTransportAddressURI();
		  //We take the transport address plus the port number to be hashed to obtain a random AHAddress
		  hashedbytes = sha.ComputeHash(Encoding.UTF8.GetBytes(target_ta + target_port));
		  //inforce type 0
		  hashedbytes[Address.MemSize - 1] &= 0xFE;
		  AHAddress _target_ahaddress = new AHAddress(hashedbytes);	      
		  for(int i = 0; i < num_pings; i++){
		    //ping and Brunet-ping the target node for a number of times
		    int uid = uid_generator.Next(); //this is the unique id of the packet
		    // update the payload
		    // This is a request, so the first byte is greater than zero
		    bytes[0] = (byte) 1;
		    NumberSerializer.WriteInt(uid, bytes, 1);
                    p = new CopyList(PType.Protocol.AH,
                                 new AHHeader(0, 30, this_node.Address,
                                              _target_ahaddress, AHHeader.Options.Greedy),
                                 PType.Protocol.Echo, MemBlock.Reference(bytes));

		    this_node.Send(p);
		    ping_time = pw.Ping(target_ta_configuration.Address, wait_time); //wait wait_time number of ms
		    System.Console.WriteLine("Ping time: {0}",ping_time);
		    System.Threading.Thread.Sleep(wait_time); 
		  }//end of for-loop 
		}                  

          }//end of if-loop    

    
    	  target_index++;
       }//end of while-loop

     }
예제 #11
0
    // adds a node to the pool
    protected static void add_node(bool output) {
      AHAddress address = new AHAddress(new RNGCryptoServiceProvider());
      Node node = new StructuredNode(address, brunet_namespace);
      NodeMapping nm = new NodeMapping();
      nm.Node = node;
      nodes.Add((Address) address, nm);

      nm.Port = TakenPorts.Count;
      while(TakenPorts.Contains(nm.Port)) {
        nm.Port = rand.Next(0, 65535);
      }

      TAAuthorizer auth = null;
      if(broken != 0) {
        auth = new BrokenTAAuth(broken);
      }

      EdgeListener el = new SimulationEdgeListener(nm.Port, 0, auth, true);

      if(secure_edges || secure_senders) {
        byte[] blob = SEKey.ExportCspBlob(true);
        RSACryptoServiceProvider rsa_copy = new RSACryptoServiceProvider();
        rsa_copy.ImportCspBlob(blob);

        CertificateMaker cm = new CertificateMaker("United States", "UFL", 
          "ACIS", "David Wolinsky", "*****@*****.**", rsa_copy,
          address.ToString());
        Certificate cert = cm.Sign(CACert, SEKey);

        CertificateHandler ch = new CertificateHandler();
        ch.AddCACertificate(CACert.X509);
        ch.AddSignedCertificate(cert.X509);

        BrunetSecurityOverlord so = new BrunetSecurityOverlord(node, rsa_copy, node.Rrm, ch);
        so.Subscribe(node, null);
        node.GetTypeSource(SecurityOverlord.Security).Subscribe(so, null);
        nm.BSO = so;
        node.HeartBeatEvent += so.Heartbeat;
      }
      if(secure_edges) {
        el = new SecureEdgeListener(el, nm.BSO);
      }

      node.AddEdgeListener(el);

      if(broken != 0) {
        el = new TunnelEdgeListener(node);
        node.AddEdgeListener(el);
      }

      ArrayList RemoteTAs = new ArrayList();
      for(int i = 0; i < 5 && i < TakenPorts.Count; i++) {
        int rport = (int) TakenPorts.GetByIndex(rand.Next(0, TakenPorts.Count));
        RemoteTAs.Add(TransportAddressFactory.CreateInstance("brunet.function://127.0.0.1:" + rport));
      }
      node.RemoteTAs = RemoteTAs;

      TakenPorts[nm.Port] = nm.Port;

      if(output) {
        Console.WriteLine("Adding: " + nm.Node.Address);
      }
      node.Connect();
      network_size++;
    }
예제 #12
0
    /// <summary>Creates a Brunet.Node, the resulting node will be available in
    /// the class as _node.</summary>
    /// <remarks>The steps to creating a node are first constructing it with a
    /// namespace, optionally adding local ip addresses to bind to, specifying
    /// local end points, specifying remote end points, and finally registering
    /// the dht.</remarks>
    public virtual void CreateNode() {
      AHAddress address = null;
      try {
        address = (AHAddress) AddressParser.Parse(_node_config.NodeAddress);
      } catch {
        address = Utils.GenerateAHAddress();
      }

      _node = new StructuredNode(address, _node_config.BrunetNamespace);
      IEnumerable addresses = IPAddresses.GetIPAddresses(_node_config.DevicesToBind);

      if(_node_config.Security.Enabled) {
        if(_node_config.Security.SelfSignedCertificates) {
          SecurityPolicy.SetDefaultSecurityPolicy(SecurityPolicy.DefaultEncryptor,
              SecurityPolicy.DefaultAuthenticator, true);
        }

        byte[] blob = null;
        using(FileStream fs = File.Open(_node_config.Security.KeyPath, FileMode.Open)) {
          blob = new byte[fs.Length];
          fs.Read(blob, 0, blob.Length);
        }

        RSACryptoServiceProvider rsa_private = new RSACryptoServiceProvider();
        rsa_private.ImportCspBlob(blob);

        CertificateHandler ch = new CertificateHandler(_node_config.Security.CertificatePath);
        _bso = new ProtocolSecurityOverlord(_node, rsa_private, _node.Rrm, ch);
        _bso.Subscribe(_node, null);

        _node.GetTypeSource(SecurityOverlord.Security).Subscribe(_bso, null);
        _node.HeartBeatEvent += _bso.Heartbeat;

        if(_node_config.Security.TestEnable) {
          blob = rsa_private.ExportCspBlob(false);
          RSACryptoServiceProvider rsa_pub = new RSACryptoServiceProvider();
          rsa_pub.ImportCspBlob(blob);
          CertificateMaker cm = new CertificateMaker("United States", "UFL", 
              "ACIS", "David Wolinsky", "*****@*****.**", rsa_pub,
              "brunet:node:abcdefghijklmnopqrs");
          Certificate cacert = cm.Sign(cm, rsa_private);

          cm = new CertificateMaker("United States", "UFL", 
              "ACIS", "David Wolinsky", "*****@*****.**", rsa_pub,
              address.ToString());
          Certificate cert = cm.Sign(cacert, rsa_private);
          ch.AddCACertificate(cacert.X509);
          ch.AddSignedCertificate(cert.X509);
        }
      }

      Brunet.EdgeListener el = null;
      foreach(NodeConfig.EdgeListener item in _node_config.EdgeListeners) {
        int port = item.port;
        if(item.type == "tcp") {
          try {
            el = new TcpEdgeListener(port, addresses);
          }
          catch {
            el = new TcpEdgeListener(0, addresses);
          }
        } else if(item.type == "udp") {
          try {
            el = new UdpEdgeListener(port, addresses);
          }
          catch {
            el = new UdpEdgeListener(0, addresses);
          }
        } else if(item.type == "function") {
          port = port == 0 ? (new Random()).Next(1024, 65535) : port;
          el = new FunctionEdgeListener(port, 0, null);
        } else {
          throw new Exception("Unrecognized transport: " + item.type);
        }
        if(_node_config.Security.SecureEdgesEnabled) {
          el = new SecureEdgeListener(el, _bso);
        }
        _node.AddEdgeListener(el);
      }

      ArrayList RemoteTAs = null;
      if(_node_config.RemoteTAs != null) {
        RemoteTAs = new ArrayList();
        foreach(String ta in _node_config.RemoteTAs) {
          RemoteTAs.Add(TransportAddressFactory.CreateInstance(ta));
        }
        _node.RemoteTAs = RemoteTAs;
      }

      ITunnelOverlap ito = null;
      if(_node_config.NCService.Enabled) {
        _ncservice = new NCService(_node, _node_config.NCService.Checkpoint);

        if (_node_config.NCService.OptimizeShortcuts) {
          _node.Ssco.TargetSelector = new VivaldiTargetSelector(_node, _ncservice);
        }
        ito = new NCTunnelOverlap(_ncservice);
      } else {
        ito = new SimpleTunnelOverlap();
      }

      el = new Tunnel.TunnelEdgeListener(_node, ito);
      if(_node_config.Security.SecureEdgesEnabled) {
        _node.EdgeVerifyMethod = EdgeVerify.AddressInSubjectAltName;
        el = new SecureEdgeListener(el, _bso);
      }
      _node.AddEdgeListener(el);


      new TableServer(_node);
      _dht = new Dht(_node, 3, 20);
      _dht_proxy = new RpcDhtProxy(_dht, _node);
    }
예제 #13
0
        /// <summary>
        /// Constructor for the class, it initializes various objects
        /// </summary>
        /// <param name="node">Takes in a structured node</param>
        public RpcAddressResolverAndDNS(StructuredNode node, DHCPServer dhcp, MemBlock local_ip)
            : base(MemBlock.Reference(dhcp.BaseIP), MemBlock.Reference(dhcp.Netmask))
        {
            _node = node;
              _rpc = _node.Rpc;
              _dns_a = new Hashtable();
              _dns_ptr = new Hashtable();
              _ip_addr = new Hashtable();
              _addr_ip = new Hashtable();
              _blocked_addrs = new Hashtable();
              mcast_addr = new ArrayList();

              _dhcp = dhcp;
              _local_ip = local_ip;

              _rpc.AddHandler("RpcIpopNode", this);
        }
예제 #14
0
  public static int Main(string[] args) {

    /**
     * Get the arguments
     */
    if( args.Length < 2 ) {
      Console.Error.WriteLine("usage: SNodeExample.exe [tcp|udp] port remota_ta0 remote_ta1 ...");
      return 0;
    }

    /**
     * Make the edge listener:
     */
    Brunet.EdgeListener el = null;
    int port = Int32.Parse( args[1] );
    if( args[0].ToLower() == "tcp" ) {
      el = new Brunet.TcpEdgeListener(port);
    }
    else if( args[0].ToLower() == "udp" ) {
      el = new Brunet.UdpEdgeListener(port);
    }
    /**
     * Create a random address for our node.
     * Some other application might want to select the address
     * a particular way, or reuse a previously selected random
     * address.  If the addresses are not random (or the output
     * of secure hashes) the network might not behave correctly.
     */
    RandomNumberGenerator rng = new RNGCryptoServiceProvider();
    Brunet.AHAddress tmp_add = new Brunet.AHAddress(rng);
    /**
     * Make the node that lives in a particular
     * namespace (or realm) called "testspace"
     */
    Brunet.Node tmp_node = new Brunet.StructuredNode(tmp_add, "testspace");
    /**
     * Add the EdgeListener
     */
    tmp_node.AddEdgeListener( el );
    /**
     * Tell the node who it can connect to:
     */
    for(int i = 2; i < args.Length; i++) {
      tmp_node.RemoteTAs.Add( Brunet.TransportAddressFactory.CreateInstance( args[i] ) );
    }
    /**
     * Now we connect, this blocks until Disconnect is called (in some
     * other thread or by some IDataHandler subscribed (see below).
     *
     * If you want to start Connect in its own thread do:
     * System.Threading.Thread t = new System.Threading.Thread(
     *    delegate() { tmp_node.Connect(); } );
     * t.Start();
     */
    tmp_node.Connect();
    
    /**
     * In a real application, we would create some IDataHandler 
     * objects and do:
     * tmp_node.GetTypeSource(PType...).Subscribe(my_handler, my_state)
     *
     * Then we can send some packets using AHSender, AHExactSender, etc...
     */
	 
    return 1;
  }
예제 #15
0
  public static int Main(string[] args) {

    /**
     * Get the arguments
     */
    if( args.Length < 2 ) {
      Console.Error.WriteLine("usage: SNodeExample.exe [tcp|udp] port remota_ta0 remote_ta1 ...");
      return 0;
    }

    /**
     * Make the edge listener:
     */
    Brunet.EdgeListener el = null;
    int port = Int32.Parse( args[1] );
    if( args[0].ToLower() == "tcp" ) {
      el = new Brunet.TcpEdgeListener(port);
    }
    else if( args[0].ToLower() == "udp" ) {
      el = new Brunet.UdpEdgeListener(port);
    }
    /**
     * Create a random address for our node.
     * Some other application might want to select the address
     * a particular way, or reuse a previously selected random
     * address.  If the addresses are not random (or the output
     * of secure hashes) the network might not behave correctly.
     */
    RandomNumberGenerator rng = new RNGCryptoServiceProvider();
    Brunet.AHAddress tmp_add = new Brunet.AHAddress(rng);
    Console.WriteLine("Address: {0}", tmp_add);
    /**
     * Make the node that lives in a particular
     * namespace (or realm) called "testspace"
     */
    Brunet.Node tmp_node = new Brunet.StructuredNode(tmp_add, "testspace");
    Brunet.ReqrepManager rrman = Brunet.ReqrepManager.GetInstance(tmp_node);
    ReqrepExample irh = new ReqrepExample();
    tmp_node.GetTypeSource(PType.Protocol.Chat).Subscribe(irh, tmp_node);
    /**
     * Add the EdgeListener
     */
    tmp_node.AddEdgeListener( el );
    /**
     * Tell the node who it can connect to:
     */
    for(int i = 2; i < args.Length; i++) {
      tmp_node.RemoteTAs.Add( TransportAddressFactory.CreateInstance( args[i] ) );
    }
    /**
     * Now we connect
     */
    tmp_node.Connect();
    Console.WriteLine("Connected");
    /**
     * In a real application, we would create some IAHPacketHandler
     * objects and do:
     * tmp_node.Subscribe( )
     * finally, we could send packets using tmp_node.Send( ) or
     * tmp_node.SendTo( )
     */
    string msg = "";
    System.Text.Encoding coder = new System.Text.ASCIIEncoding();
    while( true ) {
     Console.Write("To: ");
     msg = Console.ReadLine();
     if ( msg == "q" ) { break; }
     Address dest = AddressParser.Parse(msg);
     while( msg != "." ) {
      msg = Console.ReadLine();
      int length = coder.GetByteCount(msg);
      byte[] payload = new byte[length];
      coder.GetBytes(msg, 0, msg.Length, payload, 0);
      ISender sender = new AHSender(tmp_node, dest);
      rrman.SendRequest(sender, ReqrepManager.ReqrepType.Request,
                        new CopyList(PType.Protocol.Chat, MemBlock.Reference(payload)),
			irh , null);
     }
    }
	 
    return 1;
  }
예제 #16
0
 public Information(StructuredNode node, String type, SecurityOverlord so) :
   this(node, type)
 {
   _so = so;
 }
예제 #17
0
파일: IpopNode.cs 프로젝트: xujyan/ipop
        /// <summary>Creates an IpopNode given a NodeConfig and an IpopConfig.
        /// Also sets up the Information, Ethernet device, and subscribes
        /// to Brunet for IP Packets</summary>
        /// <param name="node_config">The path to a NodeConfig xml file</param>
        /// <param name="ipop_config">The path to a IpopConfig xml file</param>
        public IpopNode(NodeConfig node_config, IpopConfig ipop_config,
        DHCPConfig dhcp_config)
            : base(node_config)
        {
            CreateNode();
              this.Brunet = _node;
              _ipop_config = ipop_config;

              Ethernet = new Ethernet(_ipop_config.VirtualNetworkDevice);
              Ethernet.Subscribe(this, null);

              _info = new Information(Brunet, "IpopNode");
              _info.UserData["IpopNamespace"] = _ipop_config.IpopNamespace;

              if(_ipop_config.EndToEndSecurity && _bso != null) {
            _secure_senders = true;
              } else {
            _secure_senders = false;
              }
              Brunet.GetTypeSource(PType.Protocol.IP).Subscribe(this, null);

              _sync = new object();
              _lock = 0;

              _ether_to_ip = new Dictionary<MemBlock, MemBlock>();
              _ip_to_ether = new Dictionary<MemBlock, MemBlock>();

              _dhcp_server_port = _ipop_config.DHCPPort != 0 ? _ipop_config.DHCPPort : 67;
              _dhcp_client_port = _dhcp_server_port + 1;
              ProtocolLog.WriteIf(IpopLog.DHCPLog, String.Format(
              "Setting DHCP Ports to: {0},{1}", _dhcp_server_port, _dhcp_client_port));
              _ether_to_dhcp_server = new Dictionary<MemBlock, DHCPServer>();
              _static_mapping = new Dictionary<MemBlock, SimpleTimer>();
              _dhcp_config = dhcp_config;
              if(_dhcp_config != null) {
            SetDNS();
            _dhcp_server = GetDHCPServer();
              }
              _checked_out = new Hashtable();

              Brunet.HeartBeatEvent += CheckNode;
              _last_check_node = DateTime.UtcNow;
        }
예제 #18
0
  static void Main(string[] args)  
  {
   
    RandomNumberGenerator rng = new RNGCryptoServiceProvider();
    
    //Initialize hosts
    Console.WriteLine("\n\n---------------------------------------\n\n");
    int port = 20287;
    int net_size = 3;
    string net_type = "function";
    if( args.Length > 0 ) {
      net_size = Int32.Parse(args[0]);
    }
    if( args.Length > 1 ) {
      net_type = args[1];
    }
    int ms_sleep = 0;
    if( args.Length > 2 ) {
      ms_sleep = Int32.Parse(args[2]);
    }
    bool wait_after_connect = true;
    if( args.Length > 3 ) {
      ///@todo we really need better option parsing here
      wait_after_connect = false;
    }
    ArrayList node_list = new ArrayList();
    Hashtable add_to_node = new Hashtable();
    
    for (int loop=0;loop<net_size;loop++)
    {
      //create and initialize new host
      //create one new node for each host
      AHAddress tmp_add = new AHAddress(rng);
      Node tmp_node = new StructuredNode(tmp_add, "bstland");
      //Node tmp_node = new HybridNode(tmp_add, "bstland");
      
      node_list.Add(tmp_node);
      add_to_node[tmp_add] = tmp_node;
      
      //long small_add = 2*(loop+1);
      //Node tmp_node = new StructuredNode(new AHAddress( new BigInteger(small_add)) );
      switch(net_type) {
        case "tcp":
		tmp_node.AddEdgeListener(new TcpEdgeListener(port+loop));
	        break;
        case "udp":
		tmp_node.AddEdgeListener(new UdpEdgeListener(port+loop));
		break;
	case "function":
                tmp_node.AddEdgeListener(new FunctionEdgeListener(port+loop));
                break;
	default:
		throw new Exception("Unknown net type: " + net_type);
      }
      //tmp_node.AddEdgeListener(new FunctionEdgeListener(port+loop));
      for (int loop2=0;loop2<net_size;loop2++)
      {
      if (loop != loop2)
      {
          int other_port = port+loop2;
	  string ta_str = null;
          switch(net_type) {
            case "tcp":
		ta_str = "brunet.tcp://127.0.0.1:";
	        break;
            case "udp":
		ta_str = "brunet.udp://127.0.0.1:";
	        break;
            case "udp-as":
		ta_str = "brunet.udp://127.0.0.1:";
	        break;
	    case "function":
		ta_str = "brunet.function://localhost:";
                break;
	    default:
		throw new Exception("Unknown net type: " + net_type);
          }
	  ta_str = ta_str + other_port.ToString();
	  TransportAddress this_ta =
	                    TransportAddressFactory.CreateInstance(ta_str);
          tmp_node.RemoteTAs.Add(this_ta);
          }
      }
    }
    
    //This logs the changes in connection table
    BootStrapTester bst = new BootStrapTester(node_list);
    if( bst != null ) {
    //This is just here to prevent a warning for
    //not using bst, which is just an observer
    }
    //Get Connected:
    int total_started = 0;
    ArrayList rnd_list = (ArrayList)node_list.Clone();
    Random rnd = new Random();
    for(int j = 0; j < rnd_list.Count; j++) {
          //Swap the j^th position with this position:
          int i = rnd.Next(j, rnd_list.Count);
          if( i != j ) {
            object o = rnd_list[i];
            rnd_list[i] = rnd_list[j];
            rnd_list[j] = o;
          }
    }
    ArrayList c_threads = new ArrayList(); 
    foreach( Node item in rnd_list)
    {
      Thread t = new Thread( item.Connect );
      c_threads.Add(t);
      t.Start();
      Console.WriteLine(item.Address.ToString()
		      + " RemoteTAs count: " + item.RemoteTAs.Count);
      total_started++;
      Console.WriteLine("Started: " + total_started.ToString());
      //Thread.Sleep(10000);
      Thread.Sleep(ms_sleep);
      //Console.ReadLine();
      //foreach (TransportAddress item2 in item.RemoteTAs)
      //  Console.WriteLine(item2);
    
    }

    System.Console.Out.WriteLine("Finished with BootStrapTester.Main");
    string[] this_command = new string[] { "Q" };
    if( wait_after_connect) {
      Console.WriteLine("Enter Q to stop");
      this_command = Console.ReadLine().Split(' ');
    }
    while( this_command[0] != "Q" ) {
      if( this_command[0] == "D" ) { 
        //Disconnect a node:
        int node = -1;
        try {
          node = Int32.Parse(this_command[1]);
          Node to_disconnect = (Node)node_list[node];
          Console.WriteLine("About to Disconnect: {0}", to_disconnect.Address);
	        to_disconnect.Disconnect();
          bst.Remove(to_disconnect);
        }
        catch(Exception) {
 
        }
      }
      if( this_command[0] == "abort" ) { 
        //Disconnect a node:
        int node = -1;
        try {
          node = Int32.Parse(this_command[1]);
          Node to_abort = (Node)node_list[node];
          Console.WriteLine("About to Abort: {0}", to_abort.Address);
	        to_abort.Abort();
          bst.Remove(to_abort);
        }
        catch(Exception) {
 
        }
      }
      if( this_command[0] == "P" ) {
        //Pick a random pair of nodes to ping:
	Ping(node_list);
      }
      if( this_command[0] == "T" ) {
        //Pick a random pair of nodes to ping:
	TraceRoute(node_list);
      }
      if( wait_after_connect ) {
        this_command = Console.ReadLine().Split(' ');
      }
    }
    
    foreach(Node n in node_list)
    {
      n.Disconnect();
    }
    //Block until all Connect threads finish.
    //foreach(Thread t in c_threads) {
    //  t.Join();
    //}

  }
예제 #19
0
    public BrunetTester(int p, NetworkConfiguration nc, StreamWriter fs)
    { 
      int desired_port = p;
      _port = (short)p;
      _sw = fs;
      int local_host_index = nc.GetLocalHostIndex(desired_port); 
      NodeConfiguration this_node_configuration = (NodeConfiguration)nc.Nodes[local_host_index];

      TransportAddressConfiguration local_ta_configuration = 
        (TransportAddressConfiguration)this_node_configuration.TransportAddresses[0];
      short this_port = local_ta_configuration.Port;

      SHA1 sha = new SHA1CryptoServiceProvider();
      String local_ta = local_ta_configuration.GetTransportAddressURI();
      //We take the local transport address plus the port number to be hashed to obtain a random AHAddress
      byte[] hashedbytes = sha.ComputeHash(Encoding.UTF8.GetBytes(local_ta + desired_port));
      //inforce type 0
      hashedbytes[Address.MemSize - 1] &= 0xFE;
      AHAddress _local_ahaddress = new AHAddress(hashedbytes);
      //Node this_node = new HybridNode( _local_ahaddress );
      Node this_node = new StructuredNode( _local_ahaddress );

      node = this_node;
      if ( local_ta_configuration.Protocol == "tcp" ) {
        node.AddEdgeListener( new TcpEdgeListener(this_port) );
      } 
      else if( local_ta_configuration.Protocol == "udp" ) {
        node.AddEdgeListener( new UdpEdgeListener(this_port) );        
      }

      int remote_node_index = local_host_index-1;
      int num_remote_ta = 150; //20 nodes on the list to try to bootstrap to

      if (local_host_index!=0) {
        NodeConfiguration remote_node_configuration = (NodeConfiguration)nc.Nodes[0];
        TransportAddressConfiguration remote_ta_configuration = 
          (TransportAddressConfiguration)remote_node_configuration.TransportAddresses[0];

        String remote_ta = remote_ta_configuration.GetTransportAddressURI(); 
        node.RemoteTAs.Add( TransportAddressFactory.CreateInstance( remote_ta  ) );
      }

      while ( (remote_node_index>=0) && (num_remote_ta>=0) ) { 
        NodeConfiguration remote_node_configuration = (NodeConfiguration)nc.Nodes[remote_node_index];
        TransportAddressConfiguration remote_ta_configuration = 
          (TransportAddressConfiguration)remote_node_configuration.TransportAddresses[0];

        String remote_ta = remote_ta_configuration.GetTransportAddressURI(); 
        node.RemoteTAs.Add(
	             TransportAddressFactory.CreateInstance( remote_ta  ) );

        //System.Console.WriteLine("Adding {0}", remote_ta);

        remote_node_index--;
        num_remote_ta--;
      }

      //String file_string = "./data/brunetadd" + Convert.ToString(desired_port) + ".log";
      fs.WriteLine( "local_address " + node.Address.ToBigInteger().ToString() 
          + " " + Dns.GetHostName() + ":" + desired_port);
      fs.Write( DateTime.Now.ToUniversalTime().ToString("MM'/'dd'/'yyyy' 'HH':'mm':'ss") + 
          ":" + DateTime.Now.ToUniversalTime().Millisecond +
          "  Start  Start  " + node.Address.ToBigInteger().ToString() + '\n'); 
      fs.Flush(); 
      //bool log_rdp = false;	  

#if PACKET_LOG
      String file_packet = "./data/packet" + Convert.ToString(desired_port) + ".log";
      StreamWriter packet_sw = new StreamWriter(file_packet, false);
      packet_sw.WriteLine("Local_node: {0}:{1} start_time_GMT: {2}:{3} local_address {4}", Dns.GetHostName(), 
          desired_port, DateTime.Now.ToUniversalTime().ToString("MM'/'dd'/'yyyy' 'HH':'mm':'ss"), 
          DateTime.Now.ToUniversalTime().Millisecond, node.Address.ToBigInteger().ToString() ); 
      packet_sw.Close(); 
#endif

    }
예제 #20
0
 /**
  * Constructor.
  * @param node the p2p node.
  * @param localUser the local user object.
  * @param friends the list of friends.
  */
 public SocialRpcHandler(StructuredNode node, SocialUser localUser,
                    Dictionary<string, SocialUser> friends,
                    BlockingQueue queue, SocialDnsManager sdm)
 {
     _node = node;
       _rpc = node.Rpc;
       _rpc.AddHandler("SocialVPN", this);
       _local_user = localUser;
       _friends = friends;
       _queue = queue;
       _sdm = sdm;
 }
예제 #21
0
    public static void Main(string []args) {
      if (args.Length < 1) {
        Console.WriteLine("please specify the number of p2p nodes."); 
        Environment.Exit(0);
      }
      else if (args.Length < 2) {
        Console.WriteLine("please specify the number of missing edges."); 
        Environment.Exit(0);
      }

      int base_port = 54111;
      int network_size = Int32.Parse(args[0]);
      int missing_edges_count = Int32.Parse(args[1]);
      string brunet_namespace = "testing";
      SortedList nodes = new SortedList();
      Console.WriteLine("Initializing...");

      ArrayList RemoteTA = new ArrayList();
      for(int i = 0; i < network_size; i++) {
        RemoteTA.Add(TransportAddressFactory.CreateInstance("brunet.udp://127.0.0.1:" + (base_port + i)));
      }

      Random rand = new Random();
      for(int i = 0; i < network_size; i++) {
        Console.WriteLine("Starting node: {0}", i);
        AHAddress address = new AHAddress(new RNGCryptoServiceProvider());
        Node node = new StructuredNode(address, brunet_namespace);
        ArrayList arr_tas = new ArrayList();
        for(int j = 0; j < missing_edges_count; j++) {
          int remote_port = 0;
          do {
            remote_port = rand.Next(0, network_size - 1) + base_port;
          } while(remote_port == base_port + i);
          PortTAAuthorizer port_auth = new PortTAAuthorizer(remote_port);
          arr_tas.Add(port_auth);
        }
        arr_tas.Add(new ConstantAuthorizer(TAAuthorizer.Decision.Allow));
        TAAuthorizer ta_auth = new SeriesTAAuthorizer(arr_tas);
        node.AddEdgeListener(new UdpEdgeListener(base_port + i, null, ta_auth));
        node.AddEdgeListener(new Tunnel.TunnelEdgeListener(node));
        node.RemoteTAs = RemoteTA;
        Thread t = new Thread(new ThreadStart(node.Connect));
        t.Start();
        nodes.Add((Address) address, node);
        Console.WriteLine("Sleeping for 2 seconds");
        System.Threading.Thread.Sleep(2000);        
      }

      //wait for 60 more seconds
      int count = 0;
      while(true) {
        Console.WriteLine("Going to sleep for 5 seconds.");
        System.Threading.Thread.Sleep(5000);

        Console.WriteLine("Checking ring...");
        Address start_addr = (Address) nodes.GetKeyList()[0];
        Address curr_addr = start_addr;

        for (int i = 0; i < network_size; i++) {
          Node node = (Node) nodes[curr_addr];
          ConnectionTable con_table = node.ConnectionTable;
          Connection con = con_table.GetLeftStructuredNeighborOf((AHAddress) curr_addr);
          Console.WriteLine("Hop {2}\t Address {0}\n\t Connection to left {1}\n", curr_addr, con, i);
          Address next_addr = con.Address;

          if (next_addr == null) {
            Console.WriteLine("Found disconnection.");
            break;
          }

          Connection lc = ((Node)nodes[next_addr]).ConnectionTable.GetRightStructuredNeighborOf((AHAddress) next_addr);
          if( (lc == null) || !curr_addr.Equals(lc.Address)) {
            Address left_addr = lc.Address;
            Console.WriteLine(curr_addr + " != " + left_addr);
            Console.WriteLine("Right had edge, but left has no record of it!\n{0} != {1}", con, lc);
            break;
          }
          else if(next_addr.Equals(start_addr) && i != network_size -1) {
            Console.WriteLine("Completed circle too early.  Only {0} nodes in the ring.",
                              (i + 1));
            break;
          }
          curr_addr = next_addr;
        }
        count++;
        if(start_addr.Equals(curr_addr)) {
          Console.WriteLine("Ring properly formed!");
          Console.WriteLine("This only took .... {0} seconds", (count * 5));
          break;
        }
      }

      count = 0;
      while(true) {
        Console.WriteLine("Going to sleep for 5 seconds.");
        System.Threading.Thread.Sleep(5000);

        Console.WriteLine("Checking ring...");
        Address start_addr = (Address) nodes.GetKeyList()[0];
        Address curr_addr = start_addr;

        for (int i = 0; i < network_size; i++) {
          Node node = (Node) nodes[curr_addr];
          ConnectionTable con_table = node.ConnectionTable;
          Connection con = con_table.GetRightStructuredNeighborOf((AHAddress) curr_addr);
          Console.WriteLine("Hop {2}\t Address {0}\n\t Connection to right {1}\n", curr_addr, con, i);
          Address next_addr = con.Address;

          if (next_addr == null) {
            Console.WriteLine("Found disconnection.");
          }
          Connection left_con = ((Node)nodes[next_addr]).ConnectionTable.GetLeftStructuredNeighborOf((AHAddress) next_addr);
          if(left_con == null) {
            Console.WriteLine("Found disconnection.");
          }
          else if(!curr_addr.Equals(left_con.Address)) {
            Address left_addr = left_con.Address;
            Console.WriteLine(curr_addr + " != " + left_addr);
            Console.WriteLine("Left had edge, but right has no record of it! {0}", left_con);
            break;
          }
          else if(next_addr.Equals(start_addr) && i != network_size -1) {
            Console.WriteLine("Completed circle too early.  Only " + count + " nodes in the ring.");
            break;
          }
          curr_addr = next_addr;
        }
        count++;
        if(start_addr.Equals(curr_addr)) {
          Console.WriteLine("Ring properly formed!");
          Console.WriteLine("This only took .... {0} seconds", (count * 5));
          break;
        }
      }

      foreach(DictionaryEntry de in nodes) {
        Node node = (Node)de.Value;
        node.Disconnect();
      }
    }
예제 #22
0
    /**
    <summary>Creates a Brunet.Node, the resulting node will be available in
    the class as _node.</summary>
    <remarks>The steps to creating a node are first constructing it with a
    namespace, optionally adding local ip addresses to bind to, specifying
    local end points, specifying remote end points, and finally registering
    the dht.</remarks>
    */
    public virtual void CreateNode(string type) {
      NodeConfig node_config = null;
      StructuredNode current_node = null;
      AHAddress address = null;
      if (type == "cache") {
        node_config = _c_node_config;
        address = (AHAddress) AddressParser.Parse(node_config.NodeAddress);
        current_node = new StructuredNode(address, node_config.BrunetNamespace);
      }
      else if ( type == "query" ) {
        node_config = _q_node_config;
        address = (AHAddress) AddressParser.Parse(node_config.NodeAddress);
        current_node = new StructuredNode(address, node_config.BrunetNamespace);
      }
      else {
        throw new Exception("Unrecognized node type: " + type);
      }
      IEnumerable addresses = IPAddresses.GetIPAddresses(node_config.DevicesToBind);

      Brunet.EdgeListener el = null;
      foreach(NodeConfig.EdgeListener item in node_config.EdgeListeners) {
        int port = item.port;
        if (item.type =="tcp") {
          try {
            el = new TcpEdgeListener(port, addresses);
          }
          catch {
            el = new TcpEdgeListener(0, addresses);
          }
        }
        else if (item.type == "udp") {
          try {
            el = new UdpEdgeListener(port, addresses);
          }
          catch {
            el = new UdpEdgeListener(0, addresses);
          }
        }
        else {
          throw new Exception("Unrecognized transport: " + item.type);
        }
	current_node.AddEdgeListener(el);
      }
      el = new TunnelEdgeListener(current_node);
      current_node.AddEdgeListener(el);

      ArrayList RemoteTAs = null;
      if(node_config.RemoteTAs != null) {
        RemoteTAs = new ArrayList();
        foreach(String ta in node_config.RemoteTAs) {
          RemoteTAs.Add(TransportAddressFactory.CreateInstance(ta));
        }
	current_node.RemoteTAs = RemoteTAs;
      }

      try {
        if (node_config.NCService.Enabled) {
	  if (type == "cache") {
            _c_ncservice = new NCService(current_node, node_config.NCService.Checkpoint);
            if (node_config.NCService.OptimizeShortcuts) {
              current_node.Sco.TargetSelector = new VivaldiTargetSelector(current_node, _c_ncservice);
	    }
	  }
	  else {
            _q_ncservice = new NCService(current_node, node_config.NCService.Checkpoint);
            if (node_config.NCService.OptimizeShortcuts) {
              current_node.Sco.TargetSelector = new VivaldiTargetSelector(current_node, _q_ncservice);
	    }
	  }

        }
      } catch {}

      if (type == "cache") {
        _c_dht = new Dht(current_node, 3, 20);
        _cs = new CacheList(current_node);
        current_node.MapReduce.SubscribeTask(new MapReduceCache(current_node,_cs));
        current_node.MapReduce.SubscribeTask(new MapReduceCrawl(current_node));
	_c_node = current_node;
      }
      else {
        _q_dht = new Dht(current_node, 3, 20);
	CacheList q_cs = new CacheList(current_node);
        current_node.MapReduce.SubscribeTask(new MapReduceQuery(current_node,_cs));
        current_node.MapReduce.SubscribeTask(new MapReduceCrawl(current_node));
	_q_node = current_node;
      }

    }
예제 #23
0
파일: Simulator.cs 프로젝트: xujyan/brunet
    // adds a node to the pool
    protected static void add_node(bool output) {
      AHAddress address = new AHAddress(new RNGCryptoServiceProvider());
      Node node = new StructuredNode(address, brunet_namespace);
      NodeMapping nm = new NodeMapping();
      nm.Node = node;
      nodes.Add((Address) address, nm);

      nm.Port = TakenPorts.Count;
      while(TakenPorts.Contains(nm.Port)) {
        nm.Port = rand.Next(0, 65535);
      }

      TAAuthorizer auth = null;
      if(broken != 0) {
        auth = new BrokenTAAuth(broken);
      }

      EdgeListener el = new FunctionEdgeListener(nm.Port, 0, auth, true);
      node.AddEdgeListener(el);

      if(broken != 0) {
        el = new TunnelEdgeListener(node);
        node.AddEdgeListener(el);
      }

      ArrayList RemoteTAs = new ArrayList();
      for(int i = 0; i < 5 && i < TakenPorts.Count; i++) {
        int rport = (int) TakenPorts.GetByIndex(rand.Next(0, TakenPorts.Count));
        RemoteTAs.Add(TransportAddressFactory.CreateInstance("brunet.function://127.0.0.1:" + rport));
      }
      node.RemoteTAs = RemoteTAs;

      TakenPorts[nm.Port] = nm.Port;

      if(output) {
        Console.WriteLine("Adding: " + nm.Node.Address);
      }
      node.Connect();
      network_size++;
    }
        /// <summary>
        /// Constructor for the class, it initializes various objects
        /// </summary>
        /// <param name="node">Takes in a structured node</param>
        public ManagedAddressResolverAndDNS(StructuredNode node, DHCPServer dhcp, MemBlock local_ip, string dns_server, bool RA)
            : base(MemBlock.Reference(dhcp.BaseIP), MemBlock.Reference(dhcp.Netmask), dns_server, RA)
        {
            _node = node;
              _dns_a = new Hashtable();
              _dns_ptr = new Hashtable();
              _ip_addr = new Hashtable();
              _addr_ip = new Hashtable();
              _blocked_addrs = new Hashtable();
              mcast_addr = new ArrayList();

              _dhcp = dhcp;
              _local_ip = local_ip;
        }
예제 #25
0
파일: DhtTest.cs 프로젝트: johnynek/brunet
    public void Init() {
      Console.WriteLine("Initializing...");
      ArrayList RemoteTA = new ArrayList();
      for(int i = 0; i < network_size; i++) {
        RemoteTA.Add(TransportAddressFactory.CreateInstance("brunet.udp://127.0.0.1:" + (base_port + i)));
      }

      for(int i = 0; i < network_size; i++) {
        Address addr = (Address) new AHAddress(new RNGCryptoServiceProvider());
        Node node = new StructuredNode((AHAddress) addr, brunet_namespace);
        nodes.Add(addr, node);
        node.AddEdgeListener(new UdpEdgeListener(base_port + i));
        node.RemoteTAs = RemoteTA;
        tables[addr] = new TableServer(node);
        (new Thread(node.Connect)).Start();
//        if(i < network_size / ((Dht)dhts.GetByIndex(i)).DEGREE) {
//          ((Dht)dhts.GetByIndex(i)).debug = true;
//        }
      }
      default_dht = new Dht((Node) nodes.GetByIndex(0), degree);
    }
예제 #26
0
    public static void Main(string []args) {
      if (args.Length < 1) {
	Console.WriteLine("please specify the number edge protocol."); 
        Environment.Exit(0);
      }
      if (args.Length < 2) {
        Console.WriteLine("please specify the number of p2p nodes."); 
        Environment.Exit(0);
      }
      if (args.Length < 3) {
        Console.WriteLine("please specify the number of missing edges."); 
        Environment.Exit(0);
      }
      string proto = "function";
      try {
	proto = args[0].Trim();
      } catch(Exception) {}

      bool tunnel = false;
      int base_port = 54000;
      int network_size = Int32.Parse(args[1]);
      int missing_count = Int32.Parse(args[2]);
      try {
	tunnel = args[3].Trim().Equals("tunnel");
      } catch (Exception) {}

      Console.WriteLine("use tunnel edges: {0}", tunnel);

      Random rand = new Random();

      ArrayList missing_edges = new ArrayList();
      for (int i = 0; i < missing_count; i++) {
	int idx = -1;
	int left, right;
	do {
	  idx = rand.Next(0, network_size);
	  left = (idx + 1)%network_size;
	  if (idx == 0) {
	    right = network_size - 1;
	  } else {
	    right = idx - 1;
	  }
	} while (missing_edges.Contains(idx));// ||
	//missing_edges.Contains(left) ||
	//missing_edges.Contains(right));
	
	Console.WriteLine("Will drop a left edge on idx {0}: ", idx);
	missing_edges.Add(idx);
      }
      
      //
      // Sort missing edges.
      //
      missing_edges.Sort();
      SortedList dist = new SortedList();
      //
      // Compute the average distance between missing edges. 
      //
      if (missing_count > 1) {
	for (int i = 0; i < missing_count; i++) {
	  int idx = (int) missing_edges[i];
	  int idx_next;
	  int d;
	  if (i == missing_count - 1) {
	    idx_next = (int) missing_edges[0];
	    d = (network_size - 1) - idx + idx_next;
	  } else {
	    idx_next = (int) missing_edges[i+1];
	    d = idx_next - idx - 1;
	  }
	  if (!dist.Contains(d)) {
	    dist[d] = 0;
	  } else {
	    int c = (int) dist[d];
	    dist[d] = c + 1;
	  }
	}
      }
      double sum = 0.0;
      int num = 0;
      Console.WriteLine("distribution of missing edges separation");
      foreach(DictionaryEntry de in dist) {
	int k = (int) de.Key;
	int c = (int) de.Value;
	Console.WriteLine("{0} {1}", k, c);
	sum = sum + k*c;
	num = num + c;
      }

      Console.WriteLine("average separation: {0}", (double) sum/num);
      string brunet_namespace = "testing";
      Console.WriteLine("Initializing...");

      ArrayList RemoteTA = new ArrayList();
      for(int i = 0; i < network_size; i++) {
	if (proto.Equals("udp")) {
	  RemoteTA.Add(TransportAddressFactory.CreateInstance("brunet.udp://localhost:" + (base_port + i)));
	} else if (proto.Equals("function")) { 
	  RemoteTA.Add(TransportAddressFactory.CreateInstance("brunet.function://localhost:" + (base_port + i)));
	}
      }

      for(int i = 0; i < network_size; i++) {
        AHAddress address = new AHAddress(new RNGCryptoServiceProvider());
        Node node = new StructuredNode(address, brunet_namespace);
        _sorted_node_list.Add((Address) address, node);
	_node_list.Add(node);
	RouteTestHandler test_handler = new RouteTestHandler();
	node.GetTypeSource(new PType(routing_test)).Subscribe(test_handler, address.ToMemBlock());
	RpcManager rpc_man = RpcManager.GetInstance(node);
	rpc_man.AddHandler("rpc_routing_test", new  RpcRoutingTestHandler(node));
      }

      for (int i = 0; i < network_size; i++) {
	Node node = (Node) _sorted_node_list.GetByIndex(i);
	Console.WriteLine("Configuring node: {0} ", node.Address);
	TAAuthorizer ta_auth = null;
	if (missing_edges.Contains(i)) {
	  int remote_port;
	  if (i == network_size - 1) {
	    remote_port = base_port;
	  } else {
	    remote_port = base_port + i + 1;
	  }

	  PortTAAuthorizer port_auth = new PortTAAuthorizer(remote_port);
	  Console.WriteLine("Adding a port TA authorizer at: {0} for remote port: {1}", base_port + i, remote_port);
	  ArrayList arr_tas = new ArrayList();
	  arr_tas.Add(port_auth);
	  arr_tas.Add(new ConstantAuthorizer(TAAuthorizer.Decision.Allow));
	  ta_auth = new SeriesTAAuthorizer(arr_tas);
	}
	
	if (proto.Equals("udp")) { 
	  node.AddEdgeListener(new UdpEdgeListener(base_port + i, null, ta_auth));
	} else if(proto.Equals("function")) {
	  node.AddEdgeListener(new FunctionEdgeListener(base_port + i, -1.00, ta_auth));
	}
	
	if (tunnel) {
	  Console.WriteLine("Adding a tunnel edge listener");
	  node.AddEdgeListener(new Tunnel.TunnelEdgeListener(node));
	}
	_node_to_port[node] = base_port + i;
        node.RemoteTAs = RemoteTA;	
      }

      //start nodes one by one.
      for (int i  = 0; i < network_size; i++) {
	Node node = (Node) _node_list[i];
	Console.WriteLine("Starting node: {0}, {1}", i, node.Address);
        node.Connect();
	Console.WriteLine("Going to sleep for 2 seconds.");
        System.Threading.Thread.Sleep(2000);
      }

      //wait for 300000 more seconds
      Console.WriteLine("Going to sleep for 300000 seconds.");
      System.Threading.Thread.Sleep(300000);
      bool complete = CheckStatus();

      int count = 0;
      //
      // Send a large number of packets as exact packets to random destinations
      // and make sure exact routing is perfect.
      //
      
      for (int i = 0; i < network_size; i++) {
	for (int j = 0; j < network_size; j++) {
	  
	  int src_idx = i;
	  int dest_idx = j;
	  Node src_node = (Node) _sorted_node_list.GetByIndex(src_idx);
	  Node dest_node = (Node) _sorted_node_list.GetByIndex(dest_idx);
	  //Console.WriteLine("{0} -> {1}", src_idx, dest_idx);
	  Address dest_address = (Address) dest_node.Address;
	  ISender s = new AHExactSender(src_node, dest_address);
	  MemBlock p = dest_address.ToMemBlock();
	  s.Send(new CopyList(new PType(routing_test), p));
	  _sent++;
	  //System.Threading.Thread.Sleep(10);
	  s.Send(new CopyList(new PType(routing_test), p));
	  _sent++;
	  //System.Threading.Thread.Sleep(10);
	}
      }
      //wait for 10 more seconds
      Console.WriteLine("Going to sleep for 10 seconds.");
      System.Threading.Thread.Sleep(10000);      
      Console.WriteLine("Final statistics");
      lock(_class_lock) {
	Console.WriteLine("Sent: {0}, Received: {1}, Wrongly routed: {2}", 
			  _sent, _received, _wrongly_routed);
      }

      int missing_rpcs = 0;
      int correct_rpcs = 0;
      int incorrect_rpcs = 0;
      Hashtable queue_to_address = new Hashtable();
      for (int i = 0; i < network_size; i++) {
	for (int j = 0; j < network_size; j++) {
	  
	  int src_idx = i;
	  int dest_idx = j;
	  Node src_node = (Node) _sorted_node_list.GetByIndex(src_idx);
	  Node dest_node = (Node) _sorted_node_list.GetByIndex(dest_idx);
	  //Console.WriteLine("{0} -> {1}", src_idx, dest_idx);
	  Address dest_address = (Address) dest_node.Address;
	  ISender s = new AHExactSender(src_node, dest_address);
	  RpcManager rpc_man = RpcManager.GetInstance(src_node);
	  Channel q = new Channel();
	  lock (_class_lock) {
	    queue_to_address[q] = dest_address;
	  }
	  q.CloseAfterEnqueue();
	  q.CloseEvent += delegate(object o, EventArgs cargs) {
	    lock(_class_lock) {
	      Channel qu = (Channel) o;
	      if (qu.Count == 0) {
		missing_rpcs++;
	      }
	      queue_to_address.Remove(qu);
	    }
	  };
	  q.EnqueueEvent += delegate(object o, EventArgs cargs) {
	    lock(_class_lock) {
	      Channel qu = (Channel) o;
	      RpcResult rpc_reply = (RpcResult) qu.Peek();
	      byte []result = (byte[]) rpc_reply.Result;
	      Address target = new AHAddress(result);
	      if (target.Equals(queue_to_address[qu])) {
		correct_rpcs++;
	      } else {
		incorrect_rpcs++;
	      }
	    }
	  };
	  rpc_man.Invoke(s, q, "rpc_routing_test.GetIdentification", new object[]{});
	}
      }
      
      //wait for 10 more seconds
      while (true) {
	int c = -1;
	lock(_class_lock) {
	  c = incorrect_rpcs + missing_rpcs + correct_rpcs;
	}
	if (c < network_size*network_size) {
	  Console.WriteLine("Going to sleep for 10 seconds.");
	  System.Threading.Thread.Sleep(10000);
	} else {
	  break;
	}
      }
      
      Console.WriteLine("Final statistics");
      Console.WriteLine("correct rpcs: {0}, incorrect rpcs: {1}, missing rpcs: {2}", 
			correct_rpcs, incorrect_rpcs, missing_rpcs);
      
      System.Environment.Exit(1);
    }
예제 #27
0
파일: SystemTest.cs 프로젝트: xujyan/brunet
    // adds a node to the pool
    private static void add_node(bool output) {
      AHAddress address = new AHAddress(new RNGCryptoServiceProvider());
      Node node = new StructuredNode(address, brunet_namespace);
      NodeMapping nm = new NodeMapping();
      nm.Node = node;
      nodes.Add((Address) address, nm);

      nm.Port = rand.Next(1024, 65535);
      while(TakenPorts.Contains(nm.Port)) {
        nm.Port = rand.Next(1024, 65535);
      }

      EdgeListener el = null;
      if(edge_type.Equals("function")) {
        el = new FunctionEdgeListener(nm.Port, 0, null);
      }
      else if(edge_type.Equals("tcp")) {
        el = new TcpEdgeListener(nm.Port);
      }
      else if(edge_type.Equals("udp")) {
        el = new UdpEdgeListener(nm.Port);
      }
      node.AddEdgeListener(el);

      if(!discovery) {
        ArrayList RemoteTAs = new ArrayList();
        for(int i = 0; i < 5 && i < TakenPorts.Count; i++) {
          int rport = (int) TakenPorts.GetByIndex(rand.Next(0, TakenPorts.Count));
          RemoteTAs.Add(TransportAddressFactory.CreateInstance("brunet." + edge_type + "://127.0.0.1:" + rport));
        }
        node.RemoteTAs = RemoteTAs;
      }
      TakenPorts[nm.Port] = nm.Port;

      if(dht_enabled) {
        nm.Dht = new Dht(node, 3);
      }

      if(output) {
        Console.WriteLine("Adding: " + nm.Node.Address);
      }
      (new Thread(node.Connect)).Start();
      network_size++;
    }
예제 #28
0
  /** Constructor. 
   * @param a_user The local user who will being chatting
   * @param chat_config Serializable meta-data 
   */
  public BrunetChatMain(User a_user, ChatConfigSerialization chat_config)
  {
    string fname = "BrunetChat.glade";
    string root = "windowBrunetChatMain";
    Glade.XML gxml = new Glade.XML (fname, root, null);
    //Glade.XML gxml = new Glade.XML (null,fname, root, null);
    gxml.Autoconnect(this);
    
    _current_user = a_user;
    //We make the node in the "chatrealm" so it won't interfere with
    //testing of any other Brunet nodes.
    _brunet_node = new StructuredNode(a_user.Address, "chatrealm");

    _chat_config = chat_config;
    _chat_config.BuddyListFilename = "Buddylist.xml";
    _chat_config.RemoteTAsFilename = "RemoteTransportAddresses.xml";
    _chat_config.LocalTcpPortFilename = "LocalTcpPort.xml";
    
    _chat_config.DeserializeLocalTcpPort();
    _brunet_node.AddEdgeListener( 
        new TcpEdgeListener(_chat_config.LocalTcpPort.TcpPort) );
    
    treeviewBuddies = (TreeView)gxml["treeviewBuddies"];
    _store = new ListStore(typeof(string),typeof(string),typeof(string));
    treeviewBuddies.Model = _store;

    //Here is the first column
    _buddy_col = new TreeViewColumn ();
    CellRenderer buddyrenderer = new CellRendererText ();
    _buddy_col.Title = "Buddy";
    _buddy_col.PackStart (buddyrenderer, true);
    _buddy_col.AddAttribute (buddyrenderer, "text", 0);
    treeviewBuddies.AppendColumn (_buddy_col);
    
    //Here is the second column
    _email_col = new TreeViewColumn ();
    CellRenderer emailrenderer = new CellRendererText ();
    _email_col.Title = "Email";
    _email_col.PackStart (emailrenderer, true);
    _email_col.AddAttribute (emailrenderer, "text", 1);
    treeviewBuddies.AppendColumn (_email_col);
    
    //Here is the third column
    _status_col = new TreeViewColumn ();
    CellRenderer statusrenderer = new CellRendererText ();
    _status_col.Title = "Status";
    _status_col.PackStart (statusrenderer, true);
    _status_col.AddAttribute (statusrenderer, "text", 2);
    treeviewBuddies.AppendColumn (_status_col);
   
    _message_sinks = new Hashtable();
    
    _chat_config.DeserializeBuddyList();
    this.Buddies.Node = _brunet_node;
    this.Buddies.User = CurrentUser;
    //Handle the chat events locally
    this.Buddies.ChatEvent += this.IncomingChatHandler;
    foreach (Buddy bud in Buddies){
      if( bud.Sender != null ) {
        bud.Node = _brunet_node;
        bud.User = CurrentUser;
        bud.StatusChanged += this.BuddyChangeHandler;
        _store.AppendValues(bud.Alias, bud.Email, bud.Status);
      }
    }
    
    _chat_config.DeserializeRemoteTAs();
    string[] tas = _chat_config.RemoteTAs.TAs;
    foreach (string ta in tas)
    {
      _brunet_node.RemoteTAs.Add(TransportAddressFactory.CreateInstance(ta) );
      //Console.WriteLine(ta);
    }
    _brunet_node.ConnectionTable.ConnectionEvent += this.OnConnectionChange;
    _brunet_node.ConnectionTable.DisconnectionEvent += this.OnConnectionChange;
    _brunet_node.Connect();
  }