Package net.tomp2p.peers

Examples of net.tomp2p.peers.PeerAddress


        byte[] me11 = new byte[] { 1, 1 };
        byte[] me12 = new byte[] { 2, 2 };
        byte[] me13 = new byte[] { 3, 3 };
        byte[] me14 = new byte[] { 4, 4 };
        Map<PeerAddress, Map<Number640, Data>> rawData = new HashMap<PeerAddress, Map<Number640, Data>>();
        PeerAddress pa1 = Utils2.createAddress(19);
        Map<Number640, Data> test1 = new HashMap<Number640, Data>();
        test1.put(new Number640(new Number160(12),new Number160(12),new Number160(12),new Number160(0)), new Data(me12));
        test1.put(new Number640(new Number160(13),new Number160(13),new Number160(13),new Number160(0)), new Data(me13));
        test1.put(new Number640(new Number160(14),new Number160(14),new Number160(14),new Number160(0)), new Data(me14));
        rawData.put(pa1, test1);
        //
        PeerAddress pa2 = Utils2.createAddress(20);
        Map<Number640, Data> test2 = new HashMap<Number640, Data>();
        test2.put(new Number640(new Number160(12),new Number160(12),new Number160(12),new Number160(0)), new Data(me12));
        test2.put(new Number640(new Number160(13),new Number160(13),new Number160(13),new Number160(0)), new Data(me13));
        rawData.put(pa2, test2);
        //
        PeerAddress pa3 = Utils2.createAddress(21);
        Map<Number640, Data> test3 = new HashMap<Number640, Data>();
        test3.put(new Number640(new Number160(11),new Number160(11),new Number160(11),new Number160(0)), new Data(me11));
        test3.put(new Number640(new Number160(13),new Number160(13),new Number160(13),new Number160(0)), new Data(me13));
        test3.put(new Number640(new Number160(14),new Number160(14),new Number160(14),new Number160(0)), new Data(me14));
        rawData.put(pa3, test3);
View Full Code Here


        byte[] me11 = new byte[] { 1, 1 };
        byte[] me12 = new byte[] { 2, 2 };
        byte[] me13 = new byte[] { 3, 3 };
        byte[] me14 = new byte[] { 4, 4 };
        Map<PeerAddress, Map<Number640, Data>> rawData = new HashMap<PeerAddress, Map<Number640, Data>>();
        PeerAddress pa1 = Utils2.createAddress(19);
        Map<Number640, Data> test1 = new HashMap<Number640, Data>();
        test1.put(new Number640(new Number160(12),new Number160(12),new Number160(12),new Number160(0)), new Data(me12));
        test1.put(new Number640(new Number160(13),new Number160(13),new Number160(13),new Number160(0)), new Data(me13));
        test1.put(new Number640(new Number160(14),new Number160(14),new Number160(14),new Number160(0)), new Data(me14));
        rawData.put(pa1, test1);
        //
        PeerAddress pa2 = Utils2.createAddress(20);
        Map<Number640, Data> test2 = new HashMap<Number640, Data>();
        test2.put(new Number640(new Number160(12),new Number160(12),new Number160(12),new Number160(0)), new Data(me11));
        test2.put(new Number640(new Number160(13),new Number160(13),new Number160(13),new Number160(0)), new Data(me13));
        rawData.put(pa2, test2);
        //
        PeerAddress pa3 = Utils2.createAddress(21);
        Map<Number640, Data> test3 = new HashMap<Number640, Data>();
        test3.put(new Number640(new Number160(11),new Number160(11),new Number160(11),new Number160(0)), new Data(me11));
        test3.put(new Number640(new Number160(13),new Number160(13),new Number160(13),new Number160(0)), new Data(me13));
        test3.put(new Number640(new Number160(14),new Number160(14),new Number160(14),new Number160(0)), new Data(me14));
       
View Full Code Here

      conf.addPeerFilter(new DefaultPeerFilter()).maintenance(new DefaultMaintenance(0, new int[] {}));
      PeerMap peerMap = new PeerMap(conf);

      Statistics statistics = new Statistics(peerMap);
      for (int i = 0; i < nr; i++) {
        PeerAddress pa = Utils2.createAddress(new Number160(rnd));
        peerMap.peerFound(pa, null, null);
      }

      double diff = nr / statistics.estimatedNumberOfNodes();
      System.err.println("diff: " + diff);
View Full Code Here

   
    public static PeerAddress createAddress(Number160 idSender, String inetSender, int tcpPortSender,
            int udpPortSender, boolean firewallUDP, boolean firewallTCP) throws UnknownHostException {
        InetAddress inetSend = InetAddress.getByName(inetSender);
        PeerSocketAddress peerSocketAddress = new PeerSocketAddress(inetSend, tcpPortSender, udpPortSender);
        PeerAddress n1 = new PeerAddress(idSender, peerSocketAddress, firewallTCP, firewallUDP, false, false, false,
                PeerAddress.EMPTY_PEER_SOCKET_ADDRESSES);
        return n1;
    }
View Full Code Here

    Message message = new Message();
    message.command(Commands.values()[rnd.nextInt(Commands.values().length)].getNr());
    message.type(Type.values()[rnd.nextInt(Type.values().length)]);
    message.recipientSocket(new InetSocketAddress(0));
    message.recipient(new PeerAddress(new Number160(rnd), message.recipientSocket()));
    message.senderSocket(new InetSocketAddress(0));
    message.sender(new PeerAddress(new Number160(rnd), message.senderSocket()));
    return message;
  }
View Full Code Here

      }
    }

    // Test setting up relay peers
    unreachable = new PeerBuilder(Number160.createHash(RND.nextInt())).ports(PORTS + 1).start();
    PeerAddress pa = unreachable.peerBean().serverPeerAddress();
    pa = pa.changeFirewalledTCP(true).changeFirewalledUDP(true);
    unreachable.peerBean().serverPeerAddress(pa);
   
    // find neighbors
    FutureBootstrap futureBootstrap = unreachable.bootstrap().peerAddress(peers[0].peerAddress()).start();
    futureBootstrap.awaitUninterruptibly();
View Full Code Here

    List<PeerSocketAddress> relays = new ArrayList<PeerSocketAddress>();
    relays.add(new PeerSocketAddress(InetAddress.getLocalHost(), 8000, 9000));
    relays.add(new PeerSocketAddress(InetAddress.getLocalHost(), 8001, 9001));
    relays.add(new PeerSocketAddress(InetAddress.getLocalHost(), 8002, 9002));

    PeerAddress sender = UtilsNAT.createAddress().changeRelayed(true).changePeerSocketAddresses(relays)
        .changeFirewalledTCP(true).changeFirewalledUDP(true);
    message.sender(sender);
    message.senderSocket(sender.createSocketTCP());
   
    PeerAddress receiver = UtilsNAT.createAddress();
    message.recipient(receiver);
    message.recipientSocket(receiver.createSocketTCP());
   
    Buffer encoded = RelayUtils.encodeMessage(message, signature);
    Message decoded = RelayUtils.decodeMessage(encoded, message.recipientSocket(), message.senderSocket(), signature);
    Assert.assertEquals(message.peerSocketAddresses().size(), decoded.peerSocketAddresses().size());
  }
View Full Code Here

   * @throws TimeoutException
   */
  private void handleRconSetup(final Message message, final Responder responder) throws TimeoutException {
    if (!message.neighborsSetList().isEmpty()) {
      // extract the PeerAddress from the reachable peer
      final PeerAddress originalSender = (PeerAddress) message.neighborsSetList().get(0).neighbors().toArray()[0];
      // create new PeerConnectin to the reachable peer
      final FuturePeerConnection fpc = peer.createPeerConnection(originalSender);
      fpc.addListener(new BaseFutureAdapter<FuturePeerConnection>() {
        @Override
        public void operationComplete(final FuturePeerConnection future) throws Exception {
View Full Code Here

    public static PeerAddress createAddress(Number160 idSender, String inetSender, int tcpPortSender,
            int udpPortSender, boolean firewallUDP, boolean firewallTCP) throws UnknownHostException {
        InetAddress inetSend = InetAddress.getByName(inetSender);
        PeerSocketAddress peerSocketAddress = new PeerSocketAddress(inetSend, tcpPortSender, udpPortSender);
        PeerAddress n1 = new PeerAddress(idSender, peerSocketAddress, firewallTCP, firewallUDP, false, false, false,
            PeerAddress.EMPTY_PEER_SOCKET_ADDRESSES);
        return n1;
    }
View Full Code Here

    System.out.println("Client started and Listening to: " + DiscoverNetworks.discoverInterfaces(b));
    System.out.println("address visible to outside is " + client.peerAddress());

    InetAddress address = Inet4Address.getByName(ipAddress);
    int masterPort = 4000;
    PeerAddress pa = new PeerAddress(Number160.ZERO, address, masterPort, masterPort);

    System.out.println("PeerAddress: " + pa);
   
    // Future Discover
    FutureDiscover futureDiscover = client.discover().inetAddress(address).ports(masterPort).start();
View Full Code Here

TOP

Related Classes of net.tomp2p.peers.PeerAddress

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.