Пример #1
0
 def __init__(self, request, response):
   self.request = request
   self.response = response
   self.page_ref = ''
   self.ts_start = request.ts_connect
   ended_datetime = datetime.fromtimestamp(response.ts_end)
   # calculate other timings
   self.time_blocked = -1
   self.time_dnsing = -1
   if request.dns_start_ts != -1:
     dns_sec = request.ts_connect - request.dns_start_ts
     if dns_sec < 0:
       logging.warning("url=%s connct=%f dns=%f", request.url,
                       request.ts_connect, request.dns_start_ts)
     else:
       self.ts_start = request.dns_start_ts
       self.time_dnsing = int(dns_sec * 1000)
   self.started_datetime = datetime.fromtimestamp(self.ts_start)
   self.time_connecting = ms_from_dpkt_time(
       request.ts_start - request.ts_connect)
   self.time_sending = \
     ms_from_dpkt_time(request.ts_end - request.ts_start)
   self.time_waiting = \
     ms_from_dpkt_time(response.ts_start - request.ts_end)
   self.time_receiving = \
     ms_from_dpkt_time(response.ts_end - response.ts_start)
   self.total_time = ms_from_timedelta(
     ended_datetime - self.started_datetime
   )
Пример #2
0
 def __init__(self, request, response):
     self.request = request
     self.response = response
     self.pageref = None
     self.ts_start = int(request.ts_connect*1000)
     self.startedDateTime = datetime.utcfromtimestamp(request.ts_connect)
     # calculate other timings
     self.time_blocked = -1
     self.time_dnsing = -1
     self.time_connecting = (
         ms_from_dpkt_time(request.ts_start - request.ts_connect))
     self.time_sending = (
         ms_from_dpkt_time(request.ts_end - request.ts_start))
     if response is not None:
         self.time_waiting = (
             ms_from_dpkt_time(response.ts_start - request.ts_end))
         self.time_receiving = (
             ms_from_dpkt_time(response.ts_end - response.ts_start))
         endedDateTime = datetime.utcfromtimestamp(response.ts_end)
         self.total_time = ms_from_timedelta(
             endedDateTime - self.startedDateTime
         )
     else:
         # this can happen if the request never gets a response
         self.time_waiting = -1
         self.time_receiving = -1
         self.total_time = -1
Пример #3
0
    def add_dns(self, dns_query):
        '''
        Adds the info from the dns.Query to this entry

        Assumes that the dns.Query represents the DNS query required to make
        the request. Or something like that.
        '''
        if self.time_dnsing == -1:
            self.time_dnsing = ms_from_dpkt_time(dns_query.duration())
        else:
            self.time_dnsing += ms_from_dpkt_time(dns_query.duration())
Пример #4
0
    def __init__(self, request, response):
        self.request = request
        self.response = response
        self.pageref = None
        self.ts_start = ms_from_dpkt_time(request.ts_connect)

        if request.ts_connect is None:
            self.startedDateTime = None
        else:
            self.startedDateTime = datetime.utcfromtimestamp(request.ts_connect)
        # calculate other timings
        self.time_blocked = -1
        self.time_dnsing = -1
        self.time_waiting = -1
        self.time_receiving = -1
        self.time = -1
        self.total_time = -1

        self.time_connecting = (
            ms_from_dpkt_time_diff(request.ts_connect_end, request.ts_connect))
        self.time_gap = (
            ms_from_dpkt_time_diff(request.ts_start, request.ts_connect_end))
        self.time_sending = (
            ms_from_dpkt_time_diff(request.ts_end, request.ts_start))

        if response is not None:
            self.time_waiting = (
                ms_from_dpkt_time_diff(response.ts_start, request.ts_end))
            self.time_receiving = (
                ms_from_dpkt_time_diff(response.ts_end, response.ts_start))
            if request.ts_connect:
                self.time = ms_from_dpkt_time_diff(response.ts_end, request.ts_connect)
Пример #5
0
    def add_dns(self, dns_query):
        '''
        Adds the info from the dns.Query to this entry

        Assumes that the dns.Query represents the DNS query required to make
        the request. Or something like that.
        '''
        self.time_dnsing = ms_from_dpkt_time(dns_query.duration())
Пример #6
0
 def __init__(self, request, response):
     self.request = request
     self.response = response
     self.pageref = None
     self.ts_start = int(request.ts_connect * 1000)
     self.startedDateTime = datetime.fromtimestamp(request.ts_connect)
     endedDateTime = datetime.fromtimestamp(response.ts_end)
     self.total_time = ms_from_timedelta(endedDateTime - self.startedDateTime)  # plus connection time, someday
     # calculate other timings
     self.time_blocked = -1
     self.time_dnsing = -1
     self.time_connecting = ms_from_dpkt_time(request.ts_start - request.ts_connect)
     self.time_sending = ms_from_dpkt_time(request.ts_end - request.ts_start)
     self.time_waiting = ms_from_dpkt_time(response.ts_start - request.ts_end)
     self.time_receiving = ms_from_dpkt_time(response.ts_end - response.ts_start)
     # check if timing calculations are consistent
     if self.time_sending + self.time_waiting + self.time_receiving != self.total_time:
         pass
Пример #7
0
 def __init__(self, request, response):
     self.request = request
     self.response = response
     self.pageref = None
     self.ts_start = int(request.ts_connect*1000)
     self.startedDateTime = datetime.fromtimestamp(request.ts_connect)
     endedDateTime = datetime.fromtimestamp(response.ts_end)
     self.total_time = ms_from_timedelta(
         endedDateTime - self.startedDateTime # plus connection time, someday
     )
     # calculate other timings
     self.time_blocked = -1
     self.time_dnsing = -1
     self.time_connecting = ms_from_dpkt_time(request.ts_start -
                                              request.ts_connect)
     self.time_sending = \
         ms_from_dpkt_time(request.ts_end - request.ts_start)
     self.time_waiting = \
         ms_from_dpkt_time(response.ts_start - request.ts_end)
     self.time_receiving = \
         ms_from_dpkt_time(response.ts_end - response.ts_start)
     # check if timing calculations are consistent
     if self.time_sending + self.time_waiting + self.time_receiving != self.total_time:
         pass
Пример #8
0
 def __init__(self, request, response):
     self.request = request
     self.response = response
     self.page_ref = ""
     self.ts_start = int(request.ts_connect * 1000)
     self.startedDateTime = datetime.fromtimestamp(request.ts_connect)
     endedDateTime = datetime.fromtimestamp(response.ts_end)
     self.total_time = ms_from_timedelta(endedDateTime - self.startedDateTime)  # plus connection time, someday
     # calculate other timings
     self.time_blocked = -1
     self.time_dnsing = -1
     if request.dns_start_ts != -1:
         self.started_datetime = datetime.fromtimestamp(request.ts_connect)
         dns_sec = request.ts_connect - request.dns_start_ts
         if dns_sec < 0:
             logging.error("url=%s connct=%f dns=%f", request.url, request.ts_connect, request.dns_start_ts)
         self.time_dnsing = int(dns_sec * 1000)
     self.time_connecting = ms_from_dpkt_time(request.ts_start - request.ts_connect)
     self.time_sending = ms_from_dpkt_time(request.ts_end - request.ts_start)
     self.time_waiting = ms_from_dpkt_time(response.ts_start - request.ts_end)
     self.time_receiving = ms_from_dpkt_time(response.ts_end - response.ts_start)
     # check if timing calculations are consistent
     if self.time_sending + self.time_waiting + self.time_receiving != self.total_time:
         pass
Пример #9
0
    def __init__(self, request, response, client_addr, remote_addr):
        self.request = request
        self.response = response
        self.pageref = None
        self.ts_start = ms_from_dpkt_time(request.ts_connect)
        if request.ts_connect is None:
            self.startedDateTime = None
        else:
            self.startedDateTime = datetime.utcfromtimestamp(
                request.ts_connect)
        # calculate other timings
        self.time_blocked = -1
        self.time_dnsing = -1
        self.time_connecting = (ms_from_dpkt_time_diff(request.ts_start,
                                                       request.ts_connect))
        self.time_sending = (ms_from_dpkt_time_diff(request.ts_end,
                                                    request.ts_start))
        if response is not None:
            self.time_waiting = (ms_from_dpkt_time_diff(
                response.ts_start, request.ts_end))
            self.time_receiving = (ms_from_dpkt_time_diff(
                response.ts_end, response.ts_start))
            endedDateTime = datetime.utcfromtimestamp(response.ts_end)
            self.total_time = ms_from_dpkt_time_diff(response.ts_end,
                                                     request.ts_connect)
        else:
            # this can happen if the request never gets a response
            self.time_waiting = -1
            self.time_receiving = -1
            self.total_time = -1

        self.serverIPAddress = None
        # First try ipv4 and then ipv6
        try:
            self.serverIPAddress = socket.inet_ntop(socket.AF_INET,
                                                    remote_addr[0])
        except ValueError:
            self.serverIPAddress = socket.inet_ntop(socket.AF_INET6,
                                                    remote_addr[0])