Example #1
0
        static public Node AddNode(Simulator sim, NatTypes type0, NatTypes type1, bool relay)
        {
            Node node = sim.AddNode();

            NatFactory.AddNat(node.EdgeListenerList, type0);

            if (relay)
            {
                Relay.IRelayOverlap ito = new Relay.SimpleRelayOverlap();
                EdgeListener        el  = new Relay.RelayEdgeListener(node, ito);
                node.AddEdgeListener(el);
                el.Start();
            }

            if (type1 != NatTypes.Disabled)
            {
                NodeMapping            nm  = sim.Nodes[node.Address];
                int                    id  = nm.ID;
                string                 tas = SimulationTransportAddress.GetString(TransportAddress.TAType.SO, id);
                INat                   nat = GetNat(TransportAddressFactory.CreateInstance(tas), type1);
                SimulationEdgeListener el  = new SimulationEdgeListener(id, 0, null,
                                                                        true, TransportAddress.TAType.SO, nat);
                node.AddEdgeListener(el);
                el.Start();
            }
            return(node);
        }
Example #2
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;
        }
    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;
    }