acsicuib / YAFS

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

About user mobility #22

Closed jiaweiwangwang closed 4 years ago

jiaweiwangwang commented 5 years ago

Hello, I'm sorry to bother you again.I am not clear about the meaning of the parameters of the two json files(allocDefinition.json and workload.json) in mobileTutorial. I need your help to explain it for me

wisaaco commented 5 years ago

Hello,

Don't worry about that. You can ask anything you need of YAFS. It's a pleasure. This project (or better to say the new version of YAFS behind this idea) is not yet finished. Thus, some comments and analysis are not in the final stage.

In this new scenario, mobile and "fixed" devices can allocate services. For example, in "a car" you can deploy a service. This relationship is represented using allocDefinition.json file.

In allocDefinition.json file (see code below), the service 2_19 from application number 2 is deployed three times in different devices. In the first tuple, we allocate the service in the id_device, 0. And the next tuple is similar. We allocate the same service in another device, 6197472. This device is a "mobile entity". Note, we can scale multiple times the same services in different devices.

{
  "initialAllocation": [
    {
      "module_name": "2_19",
      "app": "2",
      "id_resource": 0
    },
    {
      "module_name": "2_19",
      "app": "2",
      "id_resource": 6197472
    },
    {
      "module_name": "2_19",
      "app": "2",
      "id_resource": 20604255
    }
  ]
}

Each tuple of the workload.json file represents a user. The user requests the service and it is linked/connected to specific nodes. In this project, users can be associated with mobile things. In this json file, the user is associated with the entity 6711313. This attribute: _"idresource": 0, is not necessary. I must remove it in this version. Thus, in this scenario, there is a user associated with the entity 6711313 that generates requests of the application number 2 and the request ratio is based on an exponential distribution.

{
  "sources": [
    {
      "id_resource": 0,
      "entity": 6711313,
      "distribution":"exponential_distribution",
      "args":{
        "lambd": 100

      },
      "app": "2",
      "message": "M.USER.APP.2"
    }, ...

These entities (6711313, 20604255, ...) are defined through trajectory files based on gpx-format. You can find these files in /exp/trajectories folder. Along the simulation execution, the mobile entities transform the communication network. I attach a snap as example. The network is shown in the upper left. The yellow triangles represent the mobile entities and the circles represent the fixed devices of the infrastructure.

snap_00025

wisaaco commented 5 years ago

I upload the repo with two animations. I hope it helps to understand the idea. https://github.com/acsicuib/YAFS/blob/master/README.md

jiaweiwangwang commented 5 years ago

Thank you so much for your assistance.

jiaweiwangwang commented 5 years ago

I would also like to ask whether this emulator can do the migration of applications?

wisaaco commented 5 years ago

Yes! But, you have to do two operations: remove and deploy.

In core.py, there are both functions:

You can find an example in examples/ConquestService project. (customStrategy.py)

jiaweiwangwang commented 5 years ago

Hello, I read an example in examples/ConquestService project. (customStrategy.py).I know that this example implements the application from the cloud to the location requested by the user.But what I want to do now is to migrate the application that was initially placed to the user's new location because of the user's mobility.I am a little weak in programming, I hope I can get your help. Thank you.

wisaaco commented 5 years ago

Hello,

I explain how to make a migration using the ConquestService example.

I suppose that the migration has to take place under some criteria or periodically throughout the execution. First, it is to define an event that interrupts the simulation where you can execute your code -the migration-:

In ConquestService/main.py

"""
CUSTOM EVOLUTION
"""
dStart = deterministicDistributionStartPoint(_START_TIME,_PERIOD_, name="Deterministic")
evol = CustomStrategy(pathResults)
s.deploy_monitor("EvolutionOfServices", evol, dStart, **{"sim": s, "routing": selectorPath,"case":case, "stop_time":stop_time, "it":it})

Second, this class is called like a function.

ConquestService/customStrategy.py:

def __call__(self, sim, routing,case, stop_time, it):
      self.activations  +=1
      <HERE_ in this point you can define your migration>

Inside that function, you include both operations. Note: a migration requires two operations: deployment and un-deployment.


service="2_19" #the name of your app'service
nextLocation = 234 #the id of the node
self.deploy_module(sim,service,nextLocation)

previousLocation = 23 
app_name ="2"
sim.undeploy_module(app_name,service_name,previousLocation)
jiaweiwangwang commented 5 years ago

Hello, Thank you very much for your help. With your help, I understand the application migration process. I will use YAFS to complete the experimental simulation of my paper. Thank you very much again.