acsicuib / YAFS

Yet Another Fog Simulator (YAFS)
MIT License
98 stars 72 forks source link

Inconsistency between unit of measurement used for message size definition and latency calculation #38

Open MarkoRimac opened 3 years ago

MarkoRimac commented 3 years ago

Constructor of Message class in application.py module is defined like this:

def __init__(self, name, src, dst, instructions=0, bytes=0,broadcasting=False):

Clearly it states that message size is suppose to be defined in bytes. But then again, looking at the core.py module, calculation of latency goes like this:

size_bits = message.bytes
# size_bits = message.bytes * 8
try:
  #  transmit = size_bits / (self.topology.get_edge(link)[Topology.LINK_BW] * 1000000.0)  # MBITS!
    transmit = size_bits / (self.topology.get_edge(link)[Topology.LINK_BW] * 1000000.0)  # MBITS!
    propagation = self.topology.get_edge(link)[Topology.LINK_PR]
    latency_msg_link = transmit + propagation

Here transmit has a comment at the end of a line that it's defined in MBITS (Mb) but in fact its presented in MBAJTS (MB) because size_bits variable is actually presented in bytes (we can see that in 1st line of code).

For specific use-cases this confused me because I thought latency was calculated using bits and not bytes because of the comment # MBITS! and variable name size_bits

wisaaco commented 3 years ago

Thanks Marko for your point. That function is a little mesh and the name of the variables does not help. I will try to fix with the right nomenclature since the idea is to work with Bytes, and MB.