captcp icon indicating copy to clipboard operation
captcp copied to clipboard

Printing one data file with throughput multiple flows

Open natale-p opened this issue 10 years ago • 3 comments

Actually, if I have 3 flows and want to plot their throughput, I need to run 3 times captcp, using each time a different -f parameter .

What about adding a range capability for the -f parameter ? The output .dat file will be something like

Time Throughput flow 1 Throughput flow 2
0.0 0.0 0.0 1.0 100.0 85.0 2.0 120.0 95.0

.....

Thank you

natale-p avatar Mar 11 '14 16:03 natale-p

-f

Mhh, ok. But this needs some major rewriting of the code. Any patches?

hgn avatar Mar 11 '14 17:03 hgn

diff --git i/captcp.py w/captcp.py index a63f71a..0644442 100755 --- i/captcp.py +++ w/captcp.py @@ -2699,10 +2699,14 @@ class ThroughputMod(Mod):

 def initialize(self):
     self.parse_local_options()
  •    self.end_time = self.start_time = False
    
  •    self.start_time = {}
    
  •    self.end_time = {}
    
  •    self.last_sample = {}
    
  •    self.data = {}
    
  •    self.output_row = {}
     self.total_data_len = 0
     self.time_clipping_delta = 0.0
    
  •    self.first_packet_seen = None
    
  •    self.first_packet_seen = []
     if not self.opts.stdio:
         # no need to check and generate Gnuplot
         # environment
    

    @@ -2791,11 +2795,29 @@ class ThroughputMod(Mod): (self.opts.unit, self.opts.samplelength)) self.logger.warning("Use --per-second (-p) option if you want per-second average")

  • def output_data(self, time, amount):

  •    if self.opts.stdio:
    
  •        sys.stdout.write("%5.1f  %10.1f\n" % (time, amount))
    
  •    else:
    
  •        self.throughput_file.write("%.5f %.8f\n" % (time, amount))
    
  • def output_data(self, connection_id, time, amount):

  •    if time not in self.output_row:
    
  •        self.output_row[time] = {}
    
  •    self.output_row[time][connection_id] = amount
    
  •    if len(self.output_row[time]) == len(self.ids):
    
  •        fmt = '{} '
    
  •        for i in range(0, len(self.ids)):
    
  •            fmt += '{} '
    
  •        fmt += '\n'
    
  •        values = (str(time),)
    
  •        for c_id in range(1, len(self.ids)+1):
    
  •            values = values + (str(self.output_row[time][c_id]),)
    
  •        if self.opts.stdio:
    
  •            sys.stdout.write(fmt.format(*values))
    
  •        else:
    
  •            self.throughput_file.write(fmt.format(*values))
    
  •        del self.output_row[time]
    

Initial patch.

Problem: it breaks backward compatibility, and not works without -f . Suggestions?

natale-p avatar Mar 13 '14 11:03 natale-p

Mhh, I will think about this! Thank you

hgn avatar Mar 19 '14 22:03 hgn