Ejemplo n.º 1
0
    def configure_stint(self, stint, tps):
        """ Configure stint. """

        rate = float(stint['bitrate_mbps'] * 1000000)
        size = float(stint['packetsize_bytes'] * 8)

        duration = stint['duration_s']

        self._packet_rate = int(rate / size)
        self._packetsize_bytes = stint['packetsize_bytes']
        self._limit = self._packet_rate * duration

        bps = bps_to_human(stint['bitrate_mbps'] * 1000000)

        logging.info("will send a total of %u packets", self._limit)
        logging.info("payload length is %u bytes", self._packetsize_bytes)
        logging.info("transmission rate set to %u pkt/s", self._packet_rate)
        logging.info("trasmitting time is %us", duration)
        logging.info("target bitrate is %s", bps)

        hlog(write_handler(self.address,
                           self.sender_control,
                           'src.length %u' % self._packetsize_bytes))

        hlog(write_handler(self.address,
                           self.sender_control,
                           'src.rate %u' % self._packet_rate))

        hlog(write_handler(self.address,
                           self.sender_control,
                           'src.limit %u' % self._limit))

        hlog(write_handler(self.address,
                           self.sender_control,
                           'sha.rate %u' % tps))
Ejemplo n.º 2
0
    def stop_stint(self):
        """ Stop stint. """

        logging.info("stopping probe (%s)", self.address)
        hlog(write_handler(self.address,
                           self.sender_control,
                           'src.active false'))
Ejemplo n.º 3
0
    def start_stint(self):
        """ Start stint. """

        logging.info("starting probe (%s)", self.address)
        hlog(write_handler(self.address,
                           self.sender_control,
                           'src.active true'))
Ejemplo n.º 4
0
    def generate_bins(self, model):
        """ Poll click process. """

        results = write_handler('127.0.0.1', 5555,
                                "%s.write_text_file /tmp/%s" % (model, model))
        if results[0] != '200':
            return np.array([])
        time.sleep(0.1)
        try:
            samples = np.genfromtxt('/tmp/%s' % model, dtype=int, comments="!")
        except IOError:
            samples = np.array([[]])
        bins = np.zeros(shape=(len(self.packet_sizes[model]),1))
        if np.ndim(samples) != 2:
            return bins
        for sample in samples:
            if len(sample) == 0:
                continue
            # account for ethernet (14), ip (20), and udp (8) headers
            size = sample[0] - 14 - 20 - 8
            count = sample[1]
            for i in range(0, len(self.packet_sizes[model])):
                if size <= self.packet_sizes[model][i]:
                    bins[i] = bins[i] + count
                    break
        return bins
Ejemplo n.º 5
0
    def configure_stint(self, stint, tps):
        
        self._packet_rate = int(float(stint['bitrate_mbps'] * 1000000) / float(stint['packetsize_bytes'] * 8))
        self._packetsize_bytes = stint['packetsize_bytes'] 
        self._duration = stint['duration_s']
        self._limit = self._packet_rate * self._duration 

        logging.info("will send a total of %u packets" % self._limit )
        logging.info("payload length is %u bytes" % self._packetsize_bytes )
        logging.info("transmission rate set to %u pkt/s" % self._packet_rate )
        logging.info("trasmitting time is %us" % self._duration )
        logging.info("target bitrate is %s" % bps_to_human(stint['bitrate_mbps'] * 1000000) )         

        self._dh(write_handler(self.ip, self.sender_control, 'src.length %u' % self._packetsize_bytes))
        self._dh(write_handler(self.ip, self.sender_control, 'src.rate %u' % self._packet_rate))
        self._dh(write_handler(self.ip, self.sender_control, 'src.limit %u' % self._limit))
        self._dh(write_handler(self.ip, self.sender_control, 'sha.rate %u' % tps))
Ejemplo n.º 6
0
    def reset(self):
        """ Reset probe. """

        logging.info('resetting click tx daemon (%s:%s)', self.address,
                                                          self.sender_control)

        hlog(write_handler(self.address,
                           self.sender_control,
                          'src.active false'))

        hlog(write_handler(self.address,
                           self.sender_control,
                           'src.reset'))

        hlog(write_handler(self.address,
                           self.sender_control,
                           'counter_client.reset'))

        hlog(write_handler(self.address,
                           self.sender_control,
                           'tr_client.reset'))

        logging.info('resetting click rx daemon (%s:%s)', self.address,
                                                          self.sender_control)

        hlog(write_handler(self.address,
                           self.receiver_control,
                           'counter_server.reset'))

        hlog(write_handler(self.address,
                           self.receiver_control,
                           'tr_server.reset'))

        self._packet_rate = 10
        self._packetsize_bytes = 64
Ejemplo n.º 7
0
 def reset(self):
     logging.info('resetting click send daemon (%s:%s)' % (self.ip, self.sender_control))
     self._dh(write_handler(self.ip, self.sender_control, 'src.active false'))
     self._dh(write_handler(self.ip, self.sender_control, 'src.reset'))
     self._dh(write_handler(self.ip, self.sender_control, 'counter_client.reset'))
     self._dh(write_handler(self.ip, self.sender_control, 'tr_client.reset'))
     logging.info('resetting click recv daemon (%s:%s)' % (self.ip, self.sender_control))
     self._dh(write_handler(self.ip, self.receiver_control, 'counter_server.reset'))
     self._dh(write_handler(self.ip, self.receiver_control, 'tr_server.reset'))
     self._packet_rate = 10
     self._packets_nb = 1000
     self._packetsize_bytes = 64 
     self._duration = 10 
Ejemplo n.º 8
0
 def generate_bins(self, model):
     results = write_handler('127.0.0.1', 5555, "%s.write_text_file /tmp/%s" % (model, model))
     if results[0] != '200':
         return np.array([])
     time.sleep(0.1)
     try:
         A = np.genfromtxt('/tmp/%s' % model, dtype=int, comments="!")
     except IOError:
         A = np.array([[]])
     bins = np.zeros(shape=(len(self.packet_sizes[model]),1))
     if np.ndim(A) != 2:
         return bins
     for a in A:
         if len(a) == 0:
             continue
         size = a[0]
         count = a[1]
         for i in range(0, len(self.packet_sizes[model])):
             if size <= self.packet_sizes[model][i]:
                 bins[i] = bins[i] + count
                 break
     return bins
Ejemplo n.º 9
0
 def stop_stint(self):
     logging.info("stopping probe (%s)" % self.ip)
     self._dh(write_handler(self.ip, self.sender_control, 'src.active false'))