samples/sample-simulator.py
author Florian Westphal <fw@strlen.de>
Wed, 03 Sep 2008 23:24:59 +0200
changeset 3595 693faf7f4e9b
parent 3408 2cc40b3e4fa5
child 6721 e85ecc17279a
permissions -rw-r--r--
nsc: Fix build problem if gtk config store is disabled gtk config store pulled in libdl.so for us, so things fail to link of the config store isn't enabled. This makes nsc pull in libdl itself when its enabled.

# -*- Mode:Python; -*-

import ns3 as ns


class MyModel(object):

    def Start(self):
        ns.Simulator.Schedule(ns.Seconds(10.0), self.DealWithEvent, ns.Simulator.Now().GetSeconds())

    def DealWithEvent(self, value):
        print "Member method received event at ", ns.Simulator.Now().GetSeconds(), \
            "s started at ", value, "s"

def random_function(model):
    print "random function received event at ", ns.Simulator.Now().GetSeconds(), "s"
    model.Start()


def main(dummy_argv):
    model = MyModel()
    ns.Simulator.Schedule(ns.Seconds(10.0), random_function, model)
    ns.Simulator.Run()
    ns.Simulator.Destroy()

if __name__ == '__main__':
    import sys
    main(sys.argv)