mirror of
https://github.com/samba-team/samba.git
synced 2025-01-18 06:04:06 +03:00
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>
This commit is contained in:
parent
c672a92261
commit
3c10cecac1
@ -1277,16 +1277,22 @@ class TrafficModel(object):
|
|||||||
|
|
||||||
return c
|
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):
|
persistence=0):
|
||||||
"""Generate a list of conversation descriptions from the model."""
|
"""Generate a list of conversation descriptions from the model."""
|
||||||
|
|
||||||
# We run the simulation for ten times as long as our desired
|
# We run the simulation for ten times as long as our desired
|
||||||
# duration, and take the section at the end.
|
# duration, and take the section at the end.
|
||||||
lead_in = 9 * duration
|
lead_in = 9 * duration
|
||||||
rate_n, rate_t = self.packet_rate
|
target_packets = int(packet_rate * duration)
|
||||||
target_packets = int(duration * scale * rate_n / rate_t)
|
|
||||||
|
|
||||||
conversations = []
|
conversations = []
|
||||||
n_packets = 0
|
n_packets = 0
|
||||||
|
|
||||||
@ -1310,8 +1316,10 @@ class TrafficModel(object):
|
|||||||
conversations.append(c)
|
conversations.append(c)
|
||||||
n_packets += len(c)
|
n_packets += len(c)
|
||||||
|
|
||||||
print(("we have %d packets (target %d) in %d conversations at scale %f"
|
scale = self.packet_rate_to_scale(packet_rate)
|
||||||
% (n_packets, target_packets, len(conversations), scale)),
|
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)
|
file=sys.stderr)
|
||||||
conversations.sort() # sorts by first element == start time
|
conversations.sort() # sorts by first element == start time
|
||||||
return conversations
|
return conversations
|
||||||
|
@ -79,8 +79,11 @@ def main():
|
|||||||
'These options alter the traffic '
|
'These options alter the traffic '
|
||||||
'generated by the model')
|
'generated by the model')
|
||||||
model_group.add_option('-S', '--scale-traffic', type='float', default=1.0,
|
model_group.add_option('-S', '--scale-traffic', type='float', default=1.0,
|
||||||
help='Increase the number of conversations by '
|
help=('Increase the number of conversations by '
|
||||||
'this factor')
|
'this factor (or use -T)'))
|
||||||
|
parser.add_option('-T', '--packets-per-second', type=float,
|
||||||
|
help=('attempt this many packets per second '
|
||||||
|
'(alternative to -S)'))
|
||||||
parser.add_option('--old-scale',
|
parser.add_option('--old-scale',
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help='emulate the old scale for traffic')
|
help='emulate the old scale for traffic')
|
||||||
@ -227,6 +230,11 @@ def main():
|
|||||||
logger.error("--group-memberships requires --number-of-groups")
|
logger.error("--group-memberships requires --number-of-groups")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
if opts.scale_traffic is not None and opts.packets_per_second is not None:
|
||||||
|
logger.error("--scale-traffic and --packets-per-second "
|
||||||
|
"are incompatible. Use one or the other.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if opts.timing_data not in ('-', None):
|
if opts.timing_data not in ('-', None):
|
||||||
try:
|
try:
|
||||||
open(opts.timing_data, 'w').close()
|
open(opts.timing_data, 'w').close()
|
||||||
@ -272,9 +280,14 @@ def main():
|
|||||||
logger.info(("Using the specified model file to "
|
logger.info(("Using the specified model file to "
|
||||||
"generate conversations"))
|
"generate conversations"))
|
||||||
|
|
||||||
|
if opts.scale_traffic:
|
||||||
|
packets_per_second = model.scale_to_packet_rate(opts.scale_traffic)
|
||||||
|
else:
|
||||||
|
packets_per_second = opts.packets_per_second
|
||||||
|
|
||||||
conversations = \
|
conversations = \
|
||||||
model.generate_conversation_sequences(
|
model.generate_conversation_sequences(
|
||||||
opts.scale_traffic,
|
packets_per_second,
|
||||||
opts.duration,
|
opts.duration,
|
||||||
opts.replay_rate,
|
opts.replay_rate,
|
||||||
opts.conversation_persistence)
|
opts.conversation_persistence)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user