Beispiel #1
0
  /**
   * Initializes an instance of the CacheEntry class using the specified HTTP request and response
   * information, cache diagnosis value, and number of bytes in the cache.
   *
   * @param request An HttpRequestResponseInfo object containing the request. This parameter can be
   *     null if the response is not matched to the request.
   * @param response An HttpRequestResponseInfo object containing the response. This parameter
   *     cannot be null
   * @param diagnosis A CacheEntry.Diagnosis enumeration value that identifies the diagnosis (or
   *     category) of this cache entry.
   * @param bytesInCache The number of bytes in the cache. This parameter is used for responses with
   *     data partially in the cache.
   * @param sessionFirstPacket The first packet of session.
   */
  public CacheEntry(
      HttpRequestResponseInfo request,
      HttpRequestResponseInfo response,
      Diagnosis diagnosis,
      long bytesInCache,
      PacketInfo sessionFirstPacket) {
    if (request != null) {
      this.request = request;
      this.rawBytes += request.getRawSize();
    }

    if (request != null) {
      this.timeStamp = 0.0; // request.getTimeStamp();
      this.httpObjectName = request.getObjName();
      this.hostName = request.getHostName();
      httpRequestResponse = request.getAssocReqResp();
    } else {
      this.httpObjectName = "";
      this.hostName = "";
    }

    // Response cannot be null
    this.response = response;
    this.rawBytes += response.getRawSize();

    this.contentLength = getResponse().getContentLength();
    this.diagnosis = diagnosis;
    this.bytesInCache = Math.min(bytesInCache, rawBytes);
    this.bytesNotInCache = Math.max(0, rawBytes - bytesInCache);
    this.sessionFirstPacket = sessionFirstPacket;
  }
Beispiel #2
0
 /**
  * Compares the specified CacheEntry object to this CacheEntry object are returns a value that
  * indicates if they are the same.
  *
  * @see java.lang.Comparable#compareTo(java.lang.Object)
  */
 @Override
 public int compareTo(CacheEntry entry) {
   return response.compareTo(entry.response);
 }
Beispiel #3
0
 /**
  * Returns a value that indicates whether the HTTP request/response has cache headers.
  *
  * @return A boolean value that is true if the HTTP request/response has cache headers, and is
  *     false if it does not.
  */
 public boolean hasCacheHeaders() {
   return response.isHasCacheHeaders() || (request != null && request.isHasCacheHeaders());
 }
  /** Burst data's analyzed to categorize the periodic bursts. */
  private void diagnosisPeriodicRequest() {

    Map<String, List<Double>> requestHost2tsList = new HashMap<String, List<Double>>();
    Map<String, List<Double>> requestObj2tsList = new HashMap<String, List<Double>>();
    Map<InetAddress, List<Double>> connIP2tsList = new HashMap<InetAddress, List<Double>>();
    Set<String> hostPeriodicInfoSet = new HashSet<String>();
    periodicCount = 0;
    diffPeriodicCount = 0;
    minimumPeriodicRepeatTime = 0.0;

    for (TCPSession b : analysis.getTcpSessions()) {

      // Get a list of timestamps of established sessions with each remote
      // IP
      PacketInfo p = b.getPackets().get(0);
      if (p.getTcpInfo() == TcpInfo.TCP_ESTABLISH) {
        List<Double> res = connIP2tsList.get(b.getRemoteIP());
        if (res == null) {
          res = new ArrayList<Double>();
          connIP2tsList.put(b.getRemoteIP(), res);
        }
        res.add(Double.valueOf(p.getTimeStamp()));
      }

      // Get a list of timestamps of HTTP requests to hosts/object names
      for (HttpRequestResponseInfo rr : b.getRequestResponseInfo()) {
        PacketInfo pkt = rr.getFirstDataPacket();
        if (rr.getDirection() == HttpRequestResponseInfo.Direction.REQUEST) {
          Double ts0 = Double.valueOf(pkt.getTimeStamp());
          if (rr.getHostName() != null) {
            List<Double> tempRequestHostEventList = requestHost2tsList.get(rr.getHostName());
            if (tempRequestHostEventList == null) {
              tempRequestHostEventList = new ArrayList<Double>();
              requestHost2tsList.put(rr.getHostName(), tempRequestHostEventList);
            }
            tempRequestHostEventList.add(ts0);
          }

          if (rr.getObjName() != null) {
            String objName = rr.getObjNameWithoutParams();
            List<Double> tempRequestObjEventList = requestObj2tsList.get(objName);

            if (tempRequestObjEventList == null) {
              tempRequestObjEventList = new ArrayList<Double>();
              requestObj2tsList.put(objName, tempRequestObjEventList);
            }
            tempRequestObjEventList.add(ts0);
          }
        }
      }
    }

    Set<String> hostList = new HashSet<String>();
    for (Map.Entry<String, List<Double>> iter : requestHost2tsList.entrySet()) {
      if (SelfCorr(iter.getValue())) {
        hostList.add(iter.getKey());
      }
    }

    Set<String> objList = new HashSet<String>();
    for (Map.Entry<String, List<Double>> iter : requestObj2tsList.entrySet()) {
      if (SelfCorr(iter.getValue())) {
        objList.add(iter.getKey());
      }
    }

    Set<InetAddress> ipList = new HashSet<InetAddress>();
    for (Map.Entry<InetAddress, List<Double>> iter : connIP2tsList.entrySet()) {
      if (SelfCorr(iter.getValue())) {
        ipList.add(iter.getKey());
      }
    }

    for (Burst burst : burstCollection) {
      if (!burst.getBurstInfos().contains(BurstInfo.BURST_CLIENT_DELAY)) {
        continue;
      }
      Packet beginPacket = burst.getBeginPacket().getPacket();
      if (beginPacket instanceof IPPacket) {
        IPPacket ip = (IPPacket) beginPacket;
        if (ipList.contains(ip.getDestinationIPAddress())
            || ipList.contains(ip.getSourceIPAddress())) {
          periodicCount++;
          burst.setBurstInfo(BurstInfo.BURST_PERIODICAL);
          if (ipList.contains(ip.getDestinationIPAddress())) {
            hostPeriodicInfoSet.add(ip.getDestinationIPAddress().toString());
          } else {
            hostPeriodicInfoSet.add(ip.getSourceIPAddress().toString());
          }
          continue;
        }
      }

      PacketInfo firstUplinkPayloadPacket = null;
      for (PacketInfo p : burst.getPackets()) {
        if (p.getDir() == Direction.UPLINK && p.getPayloadLen() > 0) {
          firstUplinkPayloadPacket = p;
          break;
        }
      }

      for (TCPSession session : analysis.getTcpSessions()) {
        for (HttpRequestResponseInfo rr : session.getRequestResponseInfo()) {
          if (rr.getDirection() == HttpRequestResponseInfo.Direction.REQUEST
              && (hostList.contains(rr.getHostName())
                  || objList.contains(rr.getObjNameWithoutParams()))) {
            if (rr.getFirstDataPacket() == firstUplinkPayloadPacket) {
              periodicCount++;
              burst.setBurstInfo(BurstInfo.BURST_PERIODICAL);
              burst.setFirstUplinkDataPacket(firstUplinkPayloadPacket);
              if (hostList.contains(rr.getHostName())) {
                hostPeriodicInfoSet.add(rr.getHostName());
              } else {
                hostPeriodicInfoSet.add(rr.getObjNameWithoutParams());
              }
              continue;
            }
          }
        }
      }
    }
    diffPeriodicCount = hostPeriodicInfoSet.size();
  }