acsicuib / YAFS

Yet Another Fog Simulator (YAFS)
MIT License
101 stars 73 forks source link

Link buffer #10

Closed MrrMayhem closed 5 years ago

MrrMayhem commented 5 years ago

hello,

I m working on a algorithm that route the messages in most free path (best latency), You have mentioned in your documentation that the buffer is an integer value that represents the number of messages in the whole network that are waiting for a link service, is there anyway to get the number of waiting message (buffer) on each link ?

Best regards.

wisaaco commented 5 years ago

Hello,

There is an indicator that shows the degree of saturation of a link with easy operation, but there is not an explicit counter that indicates the number of messages waiting. The problem with the counter lies in controlling the decrement function. It can be implemented but in this version the simulator was designed to manage events over time, that is, to know the next event when the message would be served.

In core.py file, the function def __network_process(self) has this variable.

self.last_busy_time = {}  # dict(zip(edges, [0.0] * len(edges))) 

It is a dictionary that in each key (|link|) has the time when the link will be free to process another transmission. Then, you have to combine current time (sim.env.now), the next tranmission time and the BW/PR attributtes to have the number of messages in each link:

In other words, a simple example: (simulation or self).env.now = 100t #current time last_busy_time={(0,1):200t} latency_msg_link = 10t where:

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

Number of waiting messages in (0,1) link = (200t-100t)/10t = 10 messages

My suggestions:

MrrMayhem commented 5 years ago

Thank you for this clear explanation, actually i think degree of saturation in each link would be enough for my application, if i understand correctly i should use the the self.last_busy_time variable minus self.env.now to get the exact saturation information in each link, one last question if you permit, i'm using a large scale environnement with thousands of generators and the simulation is getting quite slow , i know that python is slow and can't handle multi CPUs processing, the multiprocessing programmation would take significant effort cause it needs to change many things in yafs, so is their any quick solution to speed up the simulation thank you very much !

wisaaco commented 5 years ago

Unfortunately, the design of this implementation relies on SimPy library. It would be necessary to analyze the parallelization in it.