akeranen / the-one

The Opportunistic Network Environment simulator
Other
208 stars 198 forks source link

Possible mistake with World class? #26

Closed ohnu93 closed 8 years ago

ohnu93 commented 8 years ago

Hi I'm using the latest version of the simulator and while I was trying to import NCCU trace data to the simulator, I kept getting the following error:

~\One>one.bat -b 1 nccu_setting.txt
one.bat -b 1 nccu_setting.txt

~\One>java -Xmx512M -cp target;lib/ECLA.jar;lib/DTNConsoleConnection.jar core.DTNSim -b 1 nccu_setting.txt 
Run 1/1
Running simulation 'nccu_scenario'
core.SimError: No host for address 110. Address range of 0-14 is valid
        at core.World.getNodeByAddress(World.java:256)
    at input.MessageCreateEvent.processEvent(MessageCreateEvent.java:41)
    at core.World.update(World.java:159)
    at ui.DTNSimTextUI.runSim(DTNSimTextUI.java:29)
    at ui.DTNSimUI.start(DTNSimUI.java:77)
    at core.DTNSim.main(DTNSim.java:85)

---
All done in 0.49s`

And I took a look at the World class and found this at line 255:

    if (address < 0 || address >= hosts.size()) {
        throw new SimError("No host for address " + address + ". Address " +
                "range of 0-" + (hosts.size()-1) + " is valid");
    }

Here, I got confused, because from what I understand, the hosts would be the "nodes" (the NCCU students) and comparing if the address, which I presume to be the coordinate values as integer, is greater than the total number of hosts does not make sense at all to me. Is this how this is supposed to be?

Thanks.

tk721 commented 8 years ago

You have defined fewer hosts in your settings than your trace contains, and therefore the trace cannot be mapped onto your simulation. So simply make sure your settings has a group configured with as many nodes as your trace.

Each host (node) in the simulation is assigned an address starting from 0 and increasing monotonically, this is what the "address" in the code refers to. So there is no bug in that code.

ohnu93 commented 8 years ago

Ahhh got it so address does not denote the coordinate values.

Thank you!