Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ options:
"durationTicks": 500, // time of experiment
"messageSizeRange": [200, 500], // the size range clients will be sending messages in
"denimProbability": 1, // how probable a client will be to send a denim message
"replyProbability": [0.5, 0.95], // how probable a client will be to reply to a message
"sendRateRange": [1, 5], // how fast a client will send a message, each client gets a random send rate, faster send rate will have less data in the messages and vice versa
"startEpoch": 10, // seconds to start, when all clients are ready
"replyRateRange": [1, 2], // how fast a client will reply to a message
"staleReplyRange": [1, 1], // ticks before a client wont reply to a message
"report": "report.json" // final report is saved to report/<name>.json
}
```
Expand Down
18 changes: 18 additions & 0 deletions src/sam_dispatcher/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class Scenario(BaseModel):
message_size_range: Tuple[int, int] = Field(alias="messageSizeRange")
denim_probability: float = Field(alias="denimProbability")
send_rate_range: Tuple[int, int] = Field(alias="sendRateRange")
reply_rate_range: Tuple[int, int] = Field(alias="replyRateRange")
reply_probability: tuple[float, float] = Field(alias="replyProbability")
stale_reply_range: tuple[int, int] = Field(alias="staleReplyRange")
report: str = Field(alias="report", default="report.json")


Expand All @@ -34,9 +37,12 @@ class Client(BaseModel):
client_type: str = Field(alias="clientType")
message_size_range: Tuple[int, int] = Field(alias="messageSizeRange")
send_rate: int = Field(alias="sendRate")
reply_rate: int = Field(alias="replyRate")
tick_millis: int = Field(alias="tickMillis")
duration_ticks: int = Field(alias="durationTicks")
denim_probability: float = Field(alias="denimProbability")
reply_probability: float = Field(alias="replyProbability")
stale_reply: int = Field(alias="staleReply")
friends: Dict[str, Friend]


Expand Down Expand Up @@ -201,6 +207,9 @@ def _init_client(
tick_millis: int,
duration_ticks: int,
denim_prob: float,
reply_prob: float,
reply_rate: int,
stale_reply: int,
):
return Client(
username=username,
Expand All @@ -210,6 +219,9 @@ def _init_client(
tickMillis=tick_millis,
durationTicks=duration_ticks,
denimProbability=denim_prob,
replyProbability=reply_prob,
replyRate=reply_rate,
staleReply=stale_reply,
friends=dict(),
)

Expand All @@ -225,6 +237,9 @@ async def init_state(self):
for _ in range(total_clients):
username = str(uuid.uuid4())
msg_range, send_rate = self._get_sizes_and_rate()
reply_rate = random.randint(*self.scenario.reply_rate_range)
stale_reply = random.randint(*self.scenario.stale_reply_range)
reply_prob = random.uniform(*self.scenario.reply_probability)
clients[username] = State._init_client(
username,
self.scenario.type,
Expand All @@ -233,6 +248,9 @@ async def init_state(self):
tick_millis,
duration_ticks,
self.scenario.denim_probability,
reply_prob=reply_prob,
reply_rate=reply_rate,
stale_reply=stale_reply,
)

self.clients = clients
Expand Down
3 changes: 3 additions & 0 deletions tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
messageSizeRange=(10, 20),
denimProbability=0.1,
sendRateRange=(1, 5),
replyRateRange=(1, 2),
replyProbability=(0.5, 0.95),
staleReplyRange=(1, 1),
),
]

Expand Down