1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-01 04:58:35 +03:00

traffic: rename packet_rate -> replay_speed for accuracy and room

We are soon going to have a self.packet_rate, and replay_speed is more
accurate in this case.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall 2018-12-03 13:32:59 +13:00 committed by Douglas Bagnall
parent a352060f97
commit a430b11ca2

View File

@ -1233,7 +1233,7 @@ class TrafficModel(object):
self.conversation_rate = d['conversation_rate'] self.conversation_rate = d['conversation_rate']
def construct_conversation(self, timestamp=0.0, client=2, server=1, def construct_conversation(self, timestamp=0.0, client=2, server=1,
hard_stop=None, packet_rate=1): hard_stop=None, replay_speed=1):
"""Construct a individual converation from the model.""" """Construct a individual converation from the model."""
c = Conversation(timestamp, (server, client)) c = Conversation(timestamp, (server, client))
@ -1244,6 +1244,7 @@ class TrafficModel(object):
p = random.choice(self.ngrams.get(key, NON_PACKET)) p = random.choice(self.ngrams.get(key, NON_PACKET))
if p == NON_PACKET: if p == NON_PACKET:
break break
if p in self.query_details: if p in self.query_details:
extra = random.choice(self.query_details[p]) extra = random.choice(self.query_details[p])
else: else:
@ -1252,11 +1253,11 @@ class TrafficModel(object):
protocol, opcode = p.split(':', 1) protocol, opcode = p.split(':', 1)
if protocol == 'wait': if protocol == 'wait':
log_wait_time = int(opcode) + random.random() log_wait_time = int(opcode) + random.random()
wait = math.exp(log_wait_time) / (WAIT_SCALE * packet_rate) wait = math.exp(log_wait_time) / (WAIT_SCALE * replay_speed)
timestamp += wait timestamp += wait
else: else:
log_wait = random.uniform(*NO_WAIT_LOG_TIME_RANGE) log_wait = random.uniform(*NO_WAIT_LOG_TIME_RANGE)
wait = math.exp(log_wait) / packet_rate wait = math.exp(log_wait) / replay_speed
timestamp += wait timestamp += wait
if hard_stop is not None and timestamp > hard_stop: if hard_stop is not None and timestamp > hard_stop:
break break
@ -1266,7 +1267,7 @@ class TrafficModel(object):
return c return c
def generate_conversations(self, rate, duration, packet_rate=1): def generate_conversations(self, rate, duration, replay_speed=1):
"""Generate a list of conversations from the model.""" """Generate a list of conversations from the model."""
# We run the simulation for at least ten times as long as our # We run the simulation for at least ten times as long as our
@ -1289,7 +1290,7 @@ class TrafficModel(object):
client, client,
server, server,
hard_stop=(duration2 * 5), hard_stop=(duration2 * 5),
packet_rate=packet_rate) replay_speed=replay_speed)
c.forget_packets_outside_window(start, end) c.forget_packets_outside_window(start, end)
c.renormalise_times(start) c.renormalise_times(start)