示例#1
0
  void queueRouteErrorMessage(
      String unreachableNodeAddress, int unreachableSequenceNumber, ArrayList<String> precusors) {
    for (String destinationAdderss : precusors) {
      RouteError rrer =
          new RouteError(unreachableNodeAddress, unreachableSequenceNumber, destinationAdderss);

      sender.queueRoutingMessage(rrer);
    }
  }
示例#2
0
 void queueRetryRouteRequest(
     String destinationAddress, int destinationSequenceNumber, int retriesLeft) {
   RouteRequest rreq =
       new RouteRequest(
           node.getCurrentSequenceNumber(),
           node.getCurrentBroadcastID(),
           destinationAddress,
           destinationSequenceNumber,
           retriesLeft);
   sender.queueRoutingMessage(rreq);
   // debugResending(rreq);
 }
示例#3
0
  private boolean createOrUpdatePathTo(
      String destinationAddress, int destinationSequenceNumber, String nextHop, int hopCount) {

    try {

      return routingTable.updateRouteTo(
          destinationAddress, destinationSequenceNumber, nextHop, hopCount);
    } catch (InvalidRouteException e) {
      e.printStackTrace();
      sender.onNewNodeReachable(destinationAddress);
      return true;
    } catch (NoSuchRouteException e) {
      // e.printStackTrace();
      if (routingTable.createForwardRouteEntry(
          destinationAddress, destinationSequenceNumber, nextHop, hopCount)) {
        sender.onNewNodeReachable(destinationAddress);
        return true;
      }
    }
    return false;
  }
示例#4
0
  private void receiveRREQ(RouteRequest routeRequest) {
    if (BuildConfig.DEBUG) {
      Debug.debugMessage(routeRequest, getMyAddresses(), true, false);
    }

    createOrUpdatePathTo(
        routeRequest.getPreviousHop(),
        Constants.UNKNOWN_SEQUENCE_NUMBER,
        routeRequest.getPreviousHop(),
        1);

    if (routingTable.routeRequestExist(routeRequest)) {
      return;
    }

    routingTable.addRouteRequest(routeRequest, false);

    routeRequest.incrementHopCount();

    createOrUpdatePathTo(
        routeRequest.getSourceAddress(),
        routeRequest.getSourceSequenceNumber(),
        routeRequest.getPreviousHop(),
        routeRequest.getHopCount());

    RouteReply rrep = null;
    try {
      rrep = sendRREP(routeRequest);
    } catch (InvalidRouteException e) {
      routeRequest.setDestinationSequenceNumber(
          Math.max(e.getLastSequenceNumber(), routeRequest.getDestinationSequenceNumber()));
    } catch (NoSuchRouteException e) {
    } finally {
      if (rrep != null) {
        sender.queueRoutingMessage(rrep);
      } else {
        sender.queueRoutingMessage(routeRequest);
      }
    }
  }
示例#5
0
  @Override
  public void routeMessage(String destinationAddress, JSONObject message) throws RoutingException {
    List<String> myAddresses = null;
    if (BuildConfig.DEBUG) {
      myAddresses = new ArrayList<String>();
      myAddresses.add("Prop Node");
    }

    UserDataMessage dataMessage = new UserDataMessage(message);
    dataMessage.setDestinationAddress(destinationAddress);

    if (IRouter.destinationIsBroacast(destinationAddress)) {
      dataMessage.setNextHop(destinationAddress);
    }

    sender.queueMyDataMessage(dataMessage);
  }
示例#6
0
 void queueRouteErrorMessage(
     String unreachableNodeAddress, int unreachableSequenceNumber, String destinationAddress) {
   RouteError rrer =
       new RouteError(unreachableNodeAddress, unreachableSequenceNumber, destinationAddress);
   sender.queueRoutingMessage(rrer);
 }
示例#7
0
 public void onRouteEstablishmentFailure(String destinationAddress) {
   sender.onRouteEstablishmentFailure(destinationAddress);
   notifier.notifyAboutDestinationUnreachable(destinationAddress);
 }