Package tahrir.io.net.udpV1

Examples of tahrir.io.net.udpV1.UdpNetworkInterface$QueuedPacket


    }

    logger.info("Set up UDP network interface");
    final Tuple2<RSAPublicKey, RSAPrivateKey> keyPair = Tuple2.of(getRemoteNodeAddress().publicKey,
        getPrivateNodeId().privateKey);
    final TrNetworkInterface uni = new UdpNetworkInterface(config.udp, keyPair);
    sessionMgr = new TrSessionManager(this, uni, config.capabilities.allowsUnsolicitiedInbound);

    logger.info("Set up peer manager");
    peerManager = new TrPeerManager(config.peers, this);
View Full Code Here


    final Tuple2<RSAPublicKey, RSAPrivateKey> kp2 = TrCrypto.createRsaKeyPair();

    logger.info("Done");

    final TrNetworkInterface iface1 = new UdpNetworkInterface(udpNetIfaceConf1, kp1);

    final TrNetworkInterface iface2 = new UdpNetworkInterface(udpNetIfaceConf2, kp2);

    final TrNodeConfig trCfg1 = new TrNodeConfig();
    setTrConfig(trCfg1);

    final TrNodeConfig trCfg2 = new TrNodeConfig();
View Full Code Here

  private static volatile boolean testDone = false;

  @BeforeTest
  public void setUpNodes() throws Exception {
    final UNIConfig udpNetIfaceConf1 = new UNIConfig();
    udpNetIfaceConf1.listenPort = 3912;
    udpNetIfaceConf1.maxUpstreamBytesPerSecond = 1024;

    final UNIConfig udpNetIfaceConf2 = new UNIConfig();
    udpNetIfaceConf2.listenPort = 3913;
    udpNetIfaceConf2.maxUpstreamBytesPerSecond = 1024;

    logger.info("Generating public-private keys");
View Full Code Here

  private Called receivedSuccessfully;
  private Called ackReceived;

  @BeforeMethod
  public void setUp() throws Exception {
    final UNIConfig conf1 = new UNIConfig();
    conf1.listenPort = TrUtils.rand.nextInt(10000)+10000;
    conf1.maxUpstreamBytesPerSecond = 1024;

    final Tuple2<RSAPublicKey, RSAPrivateKey> kp1 = TrCrypto.createRsaKeyPair();

    final Tuple2<RSAPublicKey, RSAPrivateKey> kp2 = TrCrypto.createRsaKeyPair();

    i1 = new UdpNetworkInterface(conf1, kp1);

    final UNIConfig conf2 = new UNIConfig();
    conf2.listenPort = conf1.listenPort+1;
    conf2.maxUpstreamBytesPerSecond = 1024;
    i2 = new UdpNetworkInterface(conf2, kp2);

    final UdpNetworkLocation ra1 = new UdpNetworkLocation(InetAddress.getByName("127.0.0.1"), conf1.listenPort);
View Full Code Here

    if (config.localHostName != null) {
      modifyPublicNodeId(new ModifyBlock<RemoteNodeAddress>() {

        public void run(final RemoteNodeAddress remoteNodeAddress, final Modified modified) {
          try {
            remoteNodeAddress.physicalLocation = new UdpNetworkLocation(InetAddress.getByName(config.localHostName),
                config.udp.listenPort);
          } catch (final UnknownHostException e) {
            logger.error("Failed to set local node address", e);
          }
        }
View Full Code Here

        }
    }

    public static RemoteNodeAddress genericRemoteNodeAddress() {
        final RSAPublicKey pubKey = TrCrypto.createRsaKeyPair().a;
        final PhysicalNetworkLocation location = new UdpNetworkLocation(genericInetAddress(), genericPort());
        return new RemoteNodeAddress(location, pubKey);
    }
View Full Code Here

    final TrSessionManager sessionMgr2 = new TrSessionManager(node2, iface2, false);

    sessionMgr2.registerSessionClass(TestSession.class, TestSessionImpl.class);

    final TrRemoteConnection one2two = sessionMgr1.connectionManager.getConnection(
        new RemoteNodeAddress(new UdpNetworkLocation(InetAddress.getByName("127.0.0.1"), udpNetIfaceConf2.listenPort), kp2.a), false,
        "sessionMgr1");
    final TrRemoteConnection two2one = sessionMgr2.connectionManager.getConnection(
        new RemoteNodeAddress(new UdpNetworkLocation(InetAddress.getByName("127.0.0.1"), udpNetIfaceConf1.listenPort), kp1.a), false,
        "sessionMgr2");

    remoteSession = sessionMgr1.getOrCreateRemoteSession(TestSession.class, one2two, 1234);
  }
View Full Code Here

    Assert.assertEquals(ot2.subObj.i, ot.subObj.i);
  }

  @Test
  public void trPeerInfoTest() throws Exception {
    final TrPeerInfo ot = new TrPeerInfo(new RemoteNodeAddress(new UdpNetworkLocation(InetAddress.getByName("127.0.0.1"), 1234), TrCrypto.createRsaKeyPair().a));
    final ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
    final DataOutputStream dos = new DataOutputStream(baos);
    TrSerializer.serializeTo(ot, dos);
    final DataInputStream dis = new DataInputStream(new ByteArrayInputStream(baos.toByteArray()));
    final TrPeerInfo ot2 = TrSerializer.deserializeFrom(TrPeerInfo.class, dis);
View Full Code Here

  @Override
  protected PhysicalNetworkLocation deserialize(final Type type, final DataInputStream dis) throws IOException,
  TrSerializableException {
    final byte raType = dis.readByte();
    if (raType == UDP_REMOTE_ADDRESS)
      return new UdpNetworkLocation(TrSerializer.deserializeFrom(InetAddress.class, dis), dis.readInt());
    else
      throw new TrSerializableException("Unrecognised TrRemoteAddress type: " + raType);
  }
View Full Code Here

  TrSerializableException {
    if (!(object instanceof UdpNetworkLocation))
      throw new TrSerializableException("Unrecognized TrRemoteAddress type: " + object.getClass());
    else {
      dos.writeByte(UDP_REMOTE_ADDRESS);
      final UdpNetworkLocation ura = (UdpNetworkLocation) object;
      TrSerializer.serializeTo(ura.inetAddress, dos);
      dos.writeInt(ura.port);
    }
  }
View Full Code Here

TOP

Related Classes of tahrir.io.net.udpV1.UdpNetworkInterface$QueuedPacket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.