-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainFile.py
81 lines (61 loc) · 1.58 KB
/
mainFile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""
.. module:: mainFile
:platform: Unix, Windows
:synopsis: Call functions to build, visualize, and run the model.
.. note:: This is a simple note.
.. warning:: This is a warning
.. versionadded:: version
.. versionchanged:: version
.. seealso:: see this as well
.. moduleauthor:: Laurentiu Marinovici
"""
__license__ = "BSD"
__revision__ = " $Id: $ "
__docformat__ = 'reStructuredText'
import pprint
try:
import ns.core
import ns.flow_monitor
from fnssTopology import *
from ns3Model import *
except ImportError:
pass
try:
import ns.visualizer
except ImportError:
pass
pp = pprint.PrettyPrinter(indent = 2)
def main(argv):
'''
This is the main function.
Args:
argv(str): just a fake argument for testing purposes
'''
SimTime = 20
flowName = "n-node-ppp.xml"
cmd = ns.core.CommandLine()
cmd.ExampleType = None
cmd.AddValue("ExampleType", "The type of example running.")
cmd.Parse(argv)
if cmd.ExampleType == None:
print("\nRunning no argument case\n")
elif cmd.ExampleType == "Type1":
print("\nRunning Type 1\n")
else:
print("\nRunning any other\n")
'''
:buildFNSStopology: build network topology using FNSS
'''
topo = buildFNSStopology()
plotTopology(topo)
buildNS3model(topo)
flowMon = ns.flow_monitor.FlowMonitor()
flowMonHelper = ns.flow_monitor.FlowMonitorHelper()
flowMon = flowMonHelper.InstallAll()
ns.core.Simulator.Stop(ns.core.Seconds(SimTime))
ns.core.Simulator.Run()
flowMon.SerializeToXmlFile(flowName, True, True)
ns.core.Simulator.Destroy()
if __name__ == "__main__":
import sys
main(sys.argv)