-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
energy model #5
base: master
Are you sure you want to change the base?
energy model #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work!
I left some remarks..
maybe you can also add some central logging to indicate when a node goes out of power (once)
def __repr__(self) -> str: | ||
return str(self) | ||
|
||
def on_receive(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function name should match the one in node.py from where it is called, e.g., on_recv
"""handling message receive""" | ||
self.energy -= self._receive | ||
|
||
def on_forward(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function name should match the one in node.py from where it is called, e.g., on_send
forwarding is something from the routing side, on the lower levels its just a transmission that consumes energy
|
||
def on_receive(self): | ||
"""handling message receive""" | ||
self.energy -= self._receive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is the transmission time? sending costs a specific amount of energy per time. so a large chunk of data might need several minutes and thus should consume more power
|
||
def on_forward(self): | ||
"""handling message forward""" | ||
self.energy -= self._forward |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is the transmission time? sending costs a specific amount of energy per time. so a large chunk of data might need several minutes and thus should consume more power
self.max_energy: float = max_energy | ||
self._idle: float = idle | ||
self._receive: float = receive | ||
self._forward: float = forward |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be sending or tx
net = [] | ||
if energy_model is None: | ||
energy_model = pons.DefaultEnergyModel() | ||
if isinstance(energy_model, pons.EnergyModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe some errorhandling here would be nice with user feedback
self.netsim.routing_stats['relayed'] += 1 | ||
if not self.is_msg_known(msg): | ||
self.remember(remote_id, msg) | ||
msg.hops += 1 | ||
self.store_add(msg) | ||
if msg.dst == self.my_id: | ||
# self.log("msg arrived", self.my_id) | ||
# print("msg arrived", self.my_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you replace the central logging with a print statement?
@@ -68,7 +66,8 @@ def start(self, netsim: pons.NetSim, my_id: int): | |||
self.env.process(self.scan()) | |||
|
|||
def scan(self): | |||
while True: | |||
node = self.netsim.nodes[self.my_id] | |||
while node.energy_model.energy > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why have this check here? isn't it enough to have an energy check in the send and receive functions of node.py so the router or any other upper layers are not relevant any more? ofc the scan loop can also contain the check to avoid some CPU cycles but deactivating the node functions is the safe bet to ensure that no further communication happens
@@ -88,14 +87,16 @@ def scan(self): | |||
yield self.env.timeout(self.scan_interval) | |||
|
|||
def on_scan_received(self, msg: pons.Message, remote_id: int): | |||
if self.netsim.nodes[self.my_id].energy_model.energy <= 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why have this check here? isn't it enough to have an energy check in the send and receive functions of node.py so the router or any other upper layers are not relevant any more? ofc the scan loop can also contain the check to avoid some CPU cycles but deactivating the node functions is the safe bet to ensure that no further communication happens
No description provided.