Пример #1
0
 def _count_handshakes(self) -> int:
     """ Count the number of QUIC handshakes """
     tr = TraceAnalyzer(self._sim_log_dir.name + "/trace_node_left.pcap")
     # Determine the number of handshakes by looking at Handshake packets.
     # This is easier, since the DCID of Handshake packets doesn't changes.
     return len(set([p.scid
                     for p in tr.get_initial(Direction.FROM_SERVER)]))
Пример #2
0
 def _check_trace(self) -> bool:
   # check that (at least) one Retry packet was actually sent
   tr = TraceAnalyzer(self._sim_log_dir.name + "/trace_node_left.pcap")
   tokens = []
   cap_retry = tr.get_retry(Direction.FROM_SERVER)
   for p in cap_retry:
     tokens += [ p.quic.retry_token.replace(":", "") ]
   cap_retry.close()
   if len(tokens) == 0:
     logging.info("Didn't find any Retry packets.")
     return False
   
   # check that an Initial packet uses a token sent in the Retry packet(s)
   cap_initial = tr.get_initial(Direction.FROM_CLIENT)
   found = False
   for p in cap_initial:
     if p.quic.long_packet_type != "0" or p.quic.token_length == "0":
       continue
     token = p.quic.token.replace(":", "")
     if token in tokens:
       logging.debug("Check of Retry succeeded. Token used: %s", token)
       found = True
       break
   cap_initial.close()
   if not found:
     logging.info("Didn't find any Initial packet using a Retry token.")
   return found
Пример #3
0
 def _retry_sent(self) -> bool:
   tr = TraceAnalyzer(self._sim_log_dir.name + "/trace_node_left.pcap")
   cap = tr.get_retry()
   sent = True
   try: 
     cap.next()
   except StopIteration:
     sent = False
   cap.close()
   return sent
Пример #4
0
 def _retry_sent(self, log_dir: tempfile.TemporaryDirectory) -> bool:
     tr = TraceAnalyzer(log_dir.name + "/trace_node_left.pcap")
     cap = tr.get_retry()
     sent = True
     try:
         cap.next()
     except StopIteration:
         sent = False
     cap.close()
     return sent
Пример #5
0
    def check(self) -> bool:
        num_handshakes = self._count_handshakes()
        if num_handshakes != 1:
            logging.info("Expected exactly 1 handshake. Got: %d",
                         num_handshakes)
            return False
        if not self._check_files():
            return False

        packets = TraceAnalyzer(self._sim_log_dir.name +
                                "/trace_node_left.pcap").get_1rtt(
                                    Direction.FROM_SERVER)
        first, last = 0, 0
        for p in packets:
            if (first == 0):
                first = p.sniff_time
            last = p.sniff_time

        if (last - first == 0):
            return False
        time = (last - first) / timedelta(milliseconds=1)
        goodput = (8 * self.FILESIZE) / time
        logging.debug("Transfering %d MB took %d ms. Goodput: %d kbps",
                      self.FILESIZE / MB, time, goodput)
        self._result = goodput
        return True
Пример #6
0
 def check(self):
     tr = TraceAnalyzer(self._sim_log_dir.name + "/trace_node_left.pcap")
     initials = tr.get_initial(Direction.FROM_CLIENT)
     dcid = ""
     for p in initials:
         dcid = p.dcid
         break
     if dcid is "":
         logging.info("Didn't find an Initial / a DCID.")
         return False
     vnps = tr.get_vnp()
     for p in vnps:
         if p.scid == dcid:
             return True
     logging.info(
         "Didn't find a Version Negotiation Packet with matching SCID.")
     return False
Пример #7
0
  def check(self) -> bool:
    if not self._check_files():
      return False
    cap = TraceAnalyzer(self._sim_log_dir.name + "/trace_node_left.pcap").get_1rtt(Direction.FROM_SERVER)

    first, last = 0, 0
    for p in cap:
      if (first == 0):
        first = p.sniff_time
      last = p.sniff_time
    cap.close()

    if (last - first == 0):
      return False
    time = (last - first) / timedelta(milliseconds = 1)
    goodput = (8 * self.FILESIZE) / time
    logging.debug("Transfering %d MB took %d ms. Goodput: %d kbps", self.FILESIZE/MB, time, goodput)
    self._result = goodput
    return True
Пример #8
0
 def check(self):
   tr = TraceAnalyzer(self._sim_log_dir.name + "/trace_node_left.pcap")
   cap_initial = tr.get_initial(Direction.FROM_CLIENT)
   dcid = ""
   for p in cap_initial:
     dcid = p.quic.dcid
   cap_initial.close()
   if dcid is "":
     logging.info("Didn't find an Initial / a DCID.")
     return False
   cap_server = tr.get_vnp()
   conn_id_matches = False
   for p in cap_server:
     if p.quic.scid == dcid:
       conn_id_matches = True
   cap_server.close()
   if not conn_id_matches:
     logging.info("Didn't find a Version Negotiation Packet with matching SCID.")
   return conn_id_matches
Пример #9
0
    def _check_trace(self) -> bool:
        # check that (at least) one Retry packet was actually sent
        tr = TraceAnalyzer(self._sim_log_dir.name + "/trace_node_left.pcap")
        tokens = []
        retries = tr.get_retry(Direction.FROM_SERVER)
        for p in retries:
            tokens += [p.retry_token.replace(":", "")]
        if len(tokens) == 0:
            logging.info("Didn't find any Retry packets.")
            return False

        # check that an Initial packet uses a token sent in the Retry packet(s)
        initials = tr.get_initial(Direction.FROM_CLIENT)
        for p in initials:
            if p.token_length == "0":
                continue
            token = p.token.replace(":", "")
            if token in tokens:
                logging.debug("Check of Retry succeeded. Token used: %s",
                              token)
                return True
        logging.info("Didn't find any Initial packet using a Retry token.")
        return False
Пример #10
0
 def _server_trace(self):
     if self._cached_server_trace is None:
         self._cached_server_trace = TraceAnalyzer(
             self._sim_log_dir.name + "/trace_node_right.pcap",
             self._keylog_file())
     return self._cached_server_trace
Пример #11
0
 def _client_trace(self):
     if self._cached_client_trace is None:
         self._cached_client_trace = TraceAnalyzer(
             self._sim_log_dir.name + "/trace_node_left.pcap",
             self._keylog_file())
     return self._cached_client_trace
Пример #12
0
 def _server_trace(self):
     return TraceAnalyzer(self._sim_log_dir.name + "/trace_node_right.pcap",
                          self._keylog_file)
Пример #13
0
 def _client_trace(self):
     return TraceAnalyzer(self._sim_log_dir.name + "/trace_node_left.pcap",
                          self._keylog_file)
Пример #14
0
 def _get_versions(self) -> set:
     """ Get the QUIC versions """
     tr = TraceAnalyzer(self._sim_log_dir.name + "/trace_node_left.pcap")
     return set([p.version for p in tr.get_initial(Direction.FROM_SERVER)])
Пример #15
0
 def _retry_sent(self) -> bool:
     return len(
         TraceAnalyzer(self._sim_log_dir.name +
                       "/trace_node_left.pcap").get_retry()) > 0