Enable() static public method

static public Enable ( ) : void
return void
Esempio n. 1
0
        public void Test()
        {
            SimulationTransportAddress.Enable();
            SimulationTransportAddressOther.Enable();
            TransportAddress tas = TransportAddressFactory.CreateInstance("b.s://234580");

            Assert.AreEqual(tas.ToString(), "b.s://234580", "Simulation string");
            Assert.AreEqual((tas as SimulationTransportAddress).ID, 234580, "Simulation id");
            Assert.AreEqual(TransportAddress.TAType.S, tas.TransportAddressType, "Simulation ta type");

            TransportAddress taso = TransportAddressFactory.CreateInstance("b.so://234580");

            Assert.AreEqual(taso.ToString(), "b.so://234580", "Simulation string");
            Assert.AreEqual((taso as SimulationTransportAddressOther).ID, 234580, "Simulation id");
            Assert.AreEqual(TransportAddress.TAType.SO, taso.TransportAddressType, "Simulation ta type");

            Assert.AreNotEqual(taso, tas, "TAs not equal");
            Assert.AreNotEqual(taso.TransportAddressType, tas.TransportAddressType, "Type not equal");

            var tas1 = TransportAddressFactory.CreateInstance("b.s://-234581");

            Assert.AreEqual(-234581, (tas1 as SimulationTransportAddress).ID);
            var tas2 = (tas as SimulationTransportAddress).Invert();

            Assert.AreEqual(tas1, tas2, "Invert equal");
        }
Esempio n. 2
0
        public void Test()
        {
            SimulationTransportAddress.Enable();
            SimulationTransportAddressOther.Enable();
            var ta  = TransportAddressFactory.CreateInstance("b.s://234580") as SimulationTransportAddress;
            var tai = ta.Invert();

            TransportAddress[] tas = new TransportAddress[2] {
                tai, ta
            };
            var ta_oth  = TransportAddressFactory.CreateInstance("b.s://234581");
            var ta_oth0 = TransportAddressFactory.CreateInstance("b.s://234582");
            var nat     = new SymmetricNat(ta, 30000);

            Assert.IsFalse(nat.Incoming(ta_oth), "No outbound yet...");
            Assert.IsTrue(nat.Outgoing(ta_oth), "outbound...");
            Assert.IsFalse(nat.AllowingIncomingConnections, "SymmetricNat does not allow incoming cons");
            Assert.AreEqual(nat.InternalTransportAddresses, nat.KnownTransportAddresses, "ITA and KTA match");

            nat.UpdateTAs(ta_oth, ta);
            Assert.IsTrue(nat.Incoming(ta_oth), "Allowed incoming");
            Assert.IsFalse(nat.Incoming(ta_oth0), "Port mapped systems must send out a packet first...");
            Assert.IsFalse(nat.AllowingIncomingConnections, "SymmetricNat does not allow incoming cons");
            Assert.AreEqual(tas, nat.KnownTransportAddresses, "Two TAs!");
            Assert.IsTrue(nat.Outgoing(ta_oth0), "outbound...");

            Brunet.Util.SimpleTimer.RunSteps(7500);
            Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
            Brunet.Util.SimpleTimer.RunSteps(7500);
            Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
            Brunet.Util.SimpleTimer.RunSteps(7500);
            Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
            Brunet.Util.SimpleTimer.RunSteps(7500);
            Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
            Assert.IsFalse(nat.AllowingIncomingConnections, "SymmetricNat does not allow incoming cons");
            Assert.AreEqual(tas, nat.KnownTransportAddresses, "Two TAs!");

            Brunet.Util.SimpleTimer.RunSteps(60000);
            Assert.IsFalse(nat.AllowingIncomingConnections, "SymmetricNat does not allow incoming cons");
            Assert.IsFalse(nat.Incoming(ta_oth), "Incoming:  Timed out....");
        }
Esempio n. 3
0
        public void Test()
        {
            SimulationTransportAddress.Enable();
            SimulationTransportAddressOther.Enable();
            var ta  = TransportAddressFactory.CreateInstance("b.s://234580") as SimulationTransportAddress;
            var tai = ta.Invert();

            TransportAddress[] tas = new TransportAddress[2] {
                tai, ta
            };
            var     ta_oth  = TransportAddressFactory.CreateInstance("b.s://234581");
            var     ta_oth0 = TransportAddressFactory.CreateInstance("b.s://234582");
            ConeNat nat     = new ConeNat(ta, 30000);

            Assert.IsFalse(nat.Incoming(ta_oth), "No outbound yet...");
            Assert.IsTrue(nat.Outgoing(ta_oth), "outbound...");
            Assert.IsFalse(nat.AllowingIncomingConnections, "Have not received external ta.");
            Assert.AreEqual(nat.InternalTransportAddresses, nat.KnownTransportAddresses, "ITA and KTA match");

            nat.UpdateTAs(ta_oth, ta);
            Assert.IsTrue(nat.Incoming(ta_oth), "Allowed incoming");
            Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
            Assert.IsTrue(nat.AllowingIncomingConnections, "Have received external ta.");
            Assert.AreEqual(tas, nat.KnownTransportAddresses, "Two TAs!");

            Brunet.Util.SimpleTimer.RunSteps(7500);
            Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
            Brunet.Util.SimpleTimer.RunSteps(7500);
            Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
            Brunet.Util.SimpleTimer.RunSteps(7500);
            Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
            Brunet.Util.SimpleTimer.RunSteps(7500);
            Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
            Assert.IsTrue(nat.AllowingIncomingConnections, "Have received external ta.");
            Assert.AreEqual(tas, nat.KnownTransportAddresses, "Two TAs!");

            Brunet.Util.SimpleTimer.RunSteps(60000);
            Assert.IsFalse(nat.AllowingIncomingConnections, "AllowIC:  Timed out...");
            Assert.IsFalse(nat.Incoming(ta_oth), "Incoming:  Timed out....");
        }