Exemplo n.º 1
0
        public SimulationEdgeListener(int id, double loss_prob, TAAuthorizer ta_auth,
                                      bool use_delay, TransportAddress.TAType type, INat nat)
        {
            _edges      = new Dictionary <Edge, Edge>();
            _use_delay  = use_delay;
            LocalID     = id;
            _ploss_prob = loss_prob;
            if (ta_auth == null)
            {
                _ta_auth = new ConstantAuthorizer(TAAuthorizer.Decision.Allow);
            }
            else
            {
                _ta_auth = ta_auth;
            }
            _ta_type = type;

            Nat         = nat;
            _is_started = false;
        }
Exemplo n.º 2
0
 /**
  * @param port the local port to bind to
  * @param local_tas an IEnumerable object which gives the list of local
  * IPs.  This is consulted every time LocalTAs is accessed, so it can
  * change as new interfaces are added
  * @param ta_auth the TAAuthorizer for packets incoming
  */
 public UdpEdgeListener(int port, IEnumerable local_config_ips, TAAuthorizer ta_auth)
 {
   _s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
   ipep = new IPEndPoint(IPAddress.Any, port);
   _s.Bind(ipep);
   _port = port = ((IPEndPoint) (_s.LocalEndPoint)).Port;
   /**
    * We get all the IPAddresses for this computer
    */
   if( local_config_ips == null ) {
     _tas = TransportAddressFactory.CreateForLocalHost(TransportAddress.TAType.Udp, _port);
   }
   else {
     _tas = TransportAddressFactory.Create(TransportAddress.TAType.Udp, _port, local_config_ips);
   }
   _nat_hist = null;
   _nat_tas = new NatTAs( _tas, _nat_hist );
   _ta_auth = ta_auth;
   if( _ta_auth == null ) {
     //Always authorize in this case:
     _ta_auth = new ConstantAuthorizer(TAAuthorizer.Decision.Allow);
   }
   //We start out expecting around 30 edges with
   //a load factor of 0.15 (to make edge lookup fast)
   _id_ht = new Hashtable(30, 0.15f);
   _remote_id_ht = new Hashtable();
   _sync = new object();
   _running = 0;
   _isstarted = 0;
   ///@todo, we need a system for using the cryographic RNG
   _rand = new Random();
   _send_handler = this;
   _listen_finished_event = new ManualResetEvent(false);
   _listen_thread = new Thread( new ThreadStart(this.ListenThread) );
 }
Exemplo n.º 3
0
    public FunctionEdgeListener(int id, double loss_prob, TAAuthorizer ta_auth)
    {
      _listener_id = id;
      _ploss_prob = loss_prob;
      if (ta_auth == null) {
        _ta_auth = new ConstantAuthorizer(TAAuthorizer.Decision.Allow);
      } else {
	_ta_auth = ta_auth;
      }
      _tas = new ArrayList();
      _tas.Add(TransportAddressFactory.CreateInstance("brunet.function://localhost:" +
                                     _listener_id.ToString()) );
      _queue = new BC.LFBlockingQueue<FQEntry>();
      _queue_thread = new Thread(new ThreadStart(StartQueueProcessing));
    }