diff options
author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2018-11-07 13:31:31 +1300 |
---|---|---|
committer | Douglas Bagnall <dbagnall@samba.org> | 2019-01-08 23:55:35 +0100 |
commit | 3c10cecac1005d1340f1a389284c30b88cd73910 (patch) | |
tree | 0e23bce2efd6a1c0add0276290896076a2c05349 /python | |
parent | c672a922618507d41e2630c3b3c1407b274b153d (diff) | |
download | samba-3c10cecac1005d1340f1a389284c30b88cd73910.tar.gz |
traffic_replay: use packets per second as primary scale
The old -S/--scale-traffic is relative to the original model, which made
its relationship to true traffic volumes quite opaque
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/samba/emulate/traffic.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/python/samba/emulate/traffic.py b/python/samba/emulate/traffic.py index 76c39efba56..03603759816 100644 --- a/python/samba/emulate/traffic.py +++ b/python/samba/emulate/traffic.py @@ -1277,16 +1277,22 @@ class TrafficModel(object): return c - def generate_conversation_sequences(self, scale, duration, replay_speed=1, + def scale_to_packet_rate(self, scale): + rate_n, rate_t = self.packet_rate + return scale * rate_n / rate_t + + def packet_rate_to_scale(self, pps): + rate_n, rate_t = self.packet_rate + return pps * rate_t / rate_n + + def generate_conversation_sequences(self, packet_rate, duration, replay_speed=1, persistence=0): """Generate a list of conversation descriptions from the model.""" # We run the simulation for ten times as long as our desired # duration, and take the section at the end. lead_in = 9 * duration - rate_n, rate_t = self.packet_rate - target_packets = int(duration * scale * rate_n / rate_t) - + target_packets = int(packet_rate * duration) conversations = [] n_packets = 0 @@ -1310,8 +1316,10 @@ class TrafficModel(object): conversations.append(c) n_packets += len(c) - print(("we have %d packets (target %d) in %d conversations at scale %f" - % (n_packets, target_packets, len(conversations), scale)), + scale = self.packet_rate_to_scale(packet_rate) + print(("we have %d packets (target %d) in %d conversations at %.1f/s " + "(scale %f)" % (n_packets, target_packets, len(conversations), + packet_rate, scale)), file=sys.stderr) conversations.sort() # sorts by first element == start time return conversations |