コード例 #1
0
  /// findOptimizedPath function
  /// It finds an optimized path for transfering data by continuously
  ///     call StatMux class findNextNode method
  private int[] findOptimizedPath(int src, int dst, PacketType typeP) {
    int i = 1;
    int[] a = new int[5];

    a[0] = src;

    for (int j = 1; j < 5; j++) {
      a[j] = statMux.findNextNode(a[j - 1], dst, typeP);
    }

    return a;
  }
コード例 #2
0
  // getDelay function
  // It takes in an optimized path and packet type as input.
  // Based on input, the function calculates delay occured when traveling
  // through the optimized path
  public double getDelay(int[] opath, PacketType type) {
    double delay = 0;

    for (int i = 1; i < 4; i++) {
      Router temp = statMux.getRouter(opath[i] - 4);
      int flow = temp.getFlowLevel();
      int delayR = temp.getDelay();
      int priority = temp.getPriority(type);
      int thr = temp.getThroughput();
      packThrough[i - 1] = thr;

      if (priority == 1) {
        loss[i - 1] = thr / 10.0;
      }
      if (priority == 2) {
        loss[i - 1] = thr / 5.0;
      }

      delay += numPack / thr + delayR + priority * flow;
    }

    return delay;
  }