From ba93ed7d7596221ff24ef763a6652eba591e2eee Mon Sep 17 00:00:00 2001 From: Magnus Harder <26723180+MJHC@users.noreply.github.com> Date: Tue, 20 May 2025 08:54:25 +0200 Subject: [PATCH 1/3] reply rate and range --- README.md | 3 ++- src/sam_dispatcher/state.py | 12 ++++++++++++ tests/test_state.py | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 47c1f87..412cf99 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,9 @@ 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 "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..4f531e1 100644 --- a/src/sam_dispatcher/state.py +++ b/src/sam_dispatcher/state.py @@ -20,6 +20,8 @@ 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") report: str = Field(alias="report", default="report.json") @@ -34,9 +36,11 @@ 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") friends: Dict[str, Friend] @@ -201,6 +205,8 @@ def _init_client( tick_millis: int, duration_ticks: int, denim_prob: float, + reply_prob: float, + reply_rate: int, ): return Client( username=username, @@ -210,6 +216,8 @@ def _init_client( tickMillis=tick_millis, durationTicks=duration_ticks, denimProbability=denim_prob, + replyProbability=reply_prob, + replyRate=reply_rate, friends=dict(), ) @@ -225,6 +233,8 @@ 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) + reply_prob = random.uniform(*self.scenario.reply_probability) clients[username] = State._init_client( username, self.scenario.type, @@ -233,6 +243,8 @@ async def init_state(self): tick_millis, duration_ticks, self.scenario.denim_probability, + reply_prob=reply_prob, + reply_rate=reply_rate, ) self.clients = clients diff --git a/tests/test_state.py b/tests/test_state.py index d59794a..17f7aa6 100644 --- a/tests/test_state.py +++ b/tests/test_state.py @@ -22,6 +22,8 @@ messageSizeRange=(10, 20), denimProbability=0.1, sendRateRange=(1, 5), + replyRateRange=(1, 2), + replyProbability=(0.5, 0.95), ), ] From 831024d59837b8677cb601dd0216948f916d94fe Mon Sep 17 00:00:00 2001 From: Magnus Harder <26723180+MJHC@users.noreply.github.com> Date: Tue, 20 May 2025 10:47:58 +0200 Subject: [PATCH 2/3] fix typo --- README.md | 1 + src/sam_dispatcher/state.py | 5 +++++ tests/test_state.py | 1 + 3 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 412cf99..fde9b3e 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ options: "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 "replyRateRange": [1, 2], // how fast a client will reply to a message + "staleReply": 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 4f531e1..b153ae5 100644 --- a/src/sam_dispatcher/state.py +++ b/src/sam_dispatcher/state.py @@ -22,6 +22,7 @@ class Scenario(BaseModel): 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: int = Field(alias="staleReply") report: str = Field(alias="report", default="report.json") @@ -41,6 +42,7 @@ class Client(BaseModel): 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] @@ -207,6 +209,7 @@ def _init_client( denim_prob: float, reply_prob: float, reply_rate: int, + stale_reply: int, ): return Client( username=username, @@ -218,6 +221,7 @@ def _init_client( denimProbability=denim_prob, replyProbability=reply_prob, replyRate=reply_rate, + staleReply=stale_reply, friends=dict(), ) @@ -245,6 +249,7 @@ async def init_state(self): self.scenario.denim_probability, reply_prob=reply_prob, reply_rate=reply_rate, + stale_reply=self.scenario.stale_reply, ) self.clients = clients diff --git a/tests/test_state.py b/tests/test_state.py index 17f7aa6..e8c278d 100644 --- a/tests/test_state.py +++ b/tests/test_state.py @@ -24,6 +24,7 @@ sendRateRange=(1, 5), replyRateRange=(1, 2), replyProbability=(0.5, 0.95), + staleReply=1, ), ] From f4e10cc2c9a42b339459b15089ac71378cf17a4c Mon Sep 17 00:00:00 2001 From: Magnus Harder <26723180+MJHC@users.noreply.github.com> Date: Tue, 20 May 2025 10:58:15 +0200 Subject: [PATCH 3/3] made stale reply a range --- README.md | 2 +- src/sam_dispatcher/state.py | 5 +++-- tests/test_state.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fde9b3e..10cc2e5 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ options: "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 "replyRateRange": [1, 2], // how fast a client will reply to a message - "staleReply": 1, // ticks before a client wont 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 b153ae5..6cebcd8 100644 --- a/src/sam_dispatcher/state.py +++ b/src/sam_dispatcher/state.py @@ -22,7 +22,7 @@ class Scenario(BaseModel): 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: int = Field(alias="staleReply") + stale_reply_range: tuple[int, int] = Field(alias="staleReplyRange") report: str = Field(alias="report", default="report.json") @@ -238,6 +238,7 @@ async def init_state(self): 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, @@ -249,7 +250,7 @@ async def init_state(self): self.scenario.denim_probability, reply_prob=reply_prob, reply_rate=reply_rate, - stale_reply=self.scenario.stale_reply, + stale_reply=stale_reply, ) self.clients = clients diff --git a/tests/test_state.py b/tests/test_state.py index e8c278d..efb1480 100644 --- a/tests/test_state.py +++ b/tests/test_state.py @@ -24,7 +24,7 @@ sendRateRange=(1, 5), replyRateRange=(1, 2), replyProbability=(0.5, 0.95), - staleReply=1, + staleReplyRange=(1, 1), ), ]