Incoming() 공개 메소드

public Incoming ( TransportAddress ta ) : bool
ta Brunet.Transport.TransportAddress
리턴 bool
예제 #1
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 RestrictedConeNat(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.IsFalse(nat.Incoming(ta_oth0), "Port mapped systems must send out a packet first...");
            Assert.IsTrue(nat.AllowingIncomingConnections, "Have received external ta.");
            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.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....");
        }
예제 #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 RestrictedConeNat(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.IsFalse(nat.Incoming(ta_oth0), "Port mapped systems must send out a packet first...");
      Assert.IsTrue(nat.AllowingIncomingConnections, "Have received external ta.");
      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.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....");
    }