diff --git a/README.md b/README.md index 47c1f87..10cc2e5 100644 --- a/README.md +++ b/README.md @@ -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/.json } ``` diff --git a/src/sam_dispatcher/state.py b/src/sam_dispatcher/state.py index 105ee61..6cebcd8 100644 --- a/src/sam_dispatcher/state.py +++ b/src/sam_dispatcher/state.py @@ -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") @@ -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] @@ -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, @@ -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(), ) @@ -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, @@ -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 diff --git a/tests/test_state.py b/tests/test_state.py index d59794a..efb1480 100644 --- a/tests/test_state.py +++ b/tests/test_state.py @@ -22,6 +22,9 @@ messageSizeRange=(10, 20), denimProbability=0.1, sendRateRange=(1, 5), + replyRateRange=(1, 2), + replyProbability=(0.5, 0.95), + staleReplyRange=(1, 1), ), ]