topologygenerator 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +49 -0
  6. data/Gemfile +10 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +35 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/lib/behaviors/serialize_behavior.rb +14 -0
  13. data/lib/builders_examples/pdm_builders/PhaseI/Flow_concrete_builder.rb +82 -0
  14. data/lib/builders_examples/pdm_builders/PhaseI/Host_concrete_builder.rb +24 -0
  15. data/lib/builders_examples/pdm_builders/PhaseI/Link_concrete_builder.rb +150 -0
  16. data/lib/builders_examples/pdm_builders/PhaseI/Router_concrete_builder.rb +24 -0
  17. data/lib/builders_examples/pdm_builders/PhaseI/output_concrete_builder.rb +86 -0
  18. data/lib/builders_examples/pdm_builders/PhaseI/pdm_constants.rb +111 -0
  19. data/lib/builders_examples/pdm_builders/PhaseIWithPriorityQueues/Flow_concrete_builder.rb +82 -0
  20. data/lib/builders_examples/pdm_builders/PhaseIWithPriorityQueues/Host_concrete_builder.rb +335 -0
  21. data/lib/builders_examples/pdm_builders/PhaseIWithPriorityQueues/Link_concrete_builder.rb +25 -0
  22. data/lib/builders_examples/pdm_builders/PhaseIWithPriorityQueues/Router_concrete_builder.rb +449 -0
  23. data/lib/builders_examples/pdm_builders/PhaseIWithPriorityQueues/output_concrete_builder.rb +229 -0
  24. data/lib/builders_examples/ruby_builders/Flow_concrete_builder.rb +5 -0
  25. data/lib/builders_examples/ruby_builders/Host_concrete_builder.rb +5 -0
  26. data/lib/builders_examples/ruby_builders/Link_concrete_builder.rb +5 -0
  27. data/lib/builders_examples/ruby_builders/Router_concrete_builder.rb +5 -0
  28. data/lib/builders_examples/ruby_builders/output_concrete_builder.rb +78 -0
  29. data/lib/command_line/command_line_arguments.rb +59 -0
  30. data/lib/createTopology.rb +10 -0
  31. data/lib/flows_distributions/constant_distribution.rb +7 -0
  32. data/lib/flows_distributions/exponential_distribution.rb +7 -0
  33. data/lib/flows_distributions/normal_distribution.rb +8 -0
  34. data/lib/flows_distributions/pareto_distribution.rb +9 -0
  35. data/lib/flows_distributions/split_distribution.rb +8 -0
  36. data/lib/network_entities/abstracts/flow.rb +27 -0
  37. data/lib/network_entities/abstracts/network_element.rb +19 -0
  38. data/lib/network_entities/abstracts/path.rb +16 -0
  39. data/lib/network_entities/physical/host.rb +10 -0
  40. data/lib/network_entities/physical/link.rb +36 -0
  41. data/lib/network_entities/physical/router.rb +12 -0
  42. data/lib/network_entities/topology.rb +69 -0
  43. data/lib/network_topologies_examples/PhaseI_onlyLAr_1FelixTo1SWROD.rb +93 -0
  44. data/lib/network_topologies_examples/octopus_topology.rb +66 -0
  45. data/lib/network_topologies_examples/phase1_topology_mininet/tdaq +4 -0
  46. data/lib/network_topologies_examples/phase1_topology_mininet/tdaq.py +99 -0
  47. data/lib/network_topologies_examples/sofisticated_octopus_topology.rb +121 -0
  48. data/lib/network_topologies_examples/tdaq_network_topology.rb +76 -0
  49. data/lib/network_topologies_examples/tdaq_topology_example.rb +119 -0
  50. data/lib/network_topologies_examples/tree_topology.rb +102 -0
  51. data/lib/output/FlowDefinitions.cpp +109 -0
  52. data/lib/output/copy_files.sh +8 -0
  53. data/lib/output/flows_definition.scilabParams +30 -0
  54. data/lib/output/hosts_definition.scilabParams +5 -0
  55. data/lib/output/links_definition.scilabParams +48 -0
  56. data/lib/output/routers_definition.scilabParams +24 -0
  57. data/lib/output/ruby_network_topology.rb +76 -0
  58. data/lib/output/topology.pdm +5321 -0
  59. data/lib/output_builder.rb +39 -0
  60. data/lib/providers/apis/onos_topology_provider.rb +146 -0
  61. data/lib/providers/customs/custom_topology_provider.rb +14 -0
  62. data/lib/providers/interface_topology_provider.rb +11 -0
  63. data/lib/topologygenerator/version.rb +3 -0
  64. data/lib/topologygenerator.rb +34 -0
  65. data/lib/utils/custom_files_utils.rb +16 -0
  66. data/topologygenerator.gemspec +45 -0
  67. metadata +188 -0
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env python
2
+
3
+ from mininet.topo import Topo
4
+ from mininet.cli import CLI
5
+ from mininet.net import Mininet
6
+ from mininet.node import RemoteController, OVSKernelSwitch
7
+ from mininet.log import setLogLevel
8
+
9
+
10
+ class TdaqTopo( Topo ):
11
+ """Create a leaf spine topology"""
12
+
13
+ def build( self, roSeg=2, roSegHosts=2, sdxHostCount=2 ):
14
+ SWDPID = 1000000000000000
15
+ HSWDPID = 2000000000000000
16
+ SEGMOD = 100
17
+ LOCMOD = 10000
18
+ ROSEGMENT = 1
19
+ USA15DEV = 2
20
+ SDXDEV = 3
21
+ roSegment = []
22
+ roSegmentHosts = []
23
+ usa15Spines = []
24
+ sdxSpines = []
25
+ sdxHostSwitch = []
26
+
27
+ # Create the spine switches
28
+ usa15Spines.append(self.addSwitch('usa15s1', dpid='%d' % (SWDPID + LOCMOD*USA15DEV + 1)))
29
+ usa15Spines.append(self.addSwitch('usa15s2', dpid='%d' % (SWDPID + LOCMOD*USA15DEV + 2)))
30
+ sdxSpines.append(self.addSwitch('sdxs1', dpid='%d' % (SWDPID + LOCMOD*SDXDEV + 1)))
31
+ sdxSpines.append(self.addSwitch('sdxs2', dpid='%d' % (SWDPID + LOCMOD*SDXDEV + 2)))
32
+
33
+ self.addLink(usa15Spines[0], sdxSpines[0])
34
+ self.addLink(usa15Spines[0], sdxSpines[1])
35
+ self.addLink(usa15Spines[1], sdxSpines[0])
36
+ self.addLink(usa15Spines[1], sdxSpines[1])
37
+
38
+ # Create roSegments
39
+ for i in range(1, roSeg+1):
40
+ roSwitch = []
41
+ roHostSwitch = []
42
+ print SWDPID
43
+ roSwitch.append(self.addSwitch('seg%dsw%d' % (i, 1), dpid='%d' % (SWDPID + LOCMOD*ROSEGMENT + i*SEGMOD + 1)))
44
+ roSwitch.append(self.addSwitch('seg%dsw%d' % (i, 2), dpid='%d' % (SWDPID + LOCMOD*ROSEGMENT + i*SEGMOD + 2)))
45
+ self.addLink(roSwitch[0], roSwitch[1])
46
+ self.addLink(roSwitch[0], usa15Spines[0])
47
+ self.addLink(roSwitch[1], usa15Spines[1])
48
+ for j in range(1, roSegHosts+1):
49
+ roHostSwitch.append(self.addSwitch('swhseg%dh%d' % (i, j), dpid='%d' % (HSWDPID + LOCMOD*ROSEGMENT + SEGMOD*i + j)))
50
+ host = self.addHost('seg%dh%d' % (i, j), ip='10.%d.%d.%d' % (ROSEGMENT, i, j))
51
+ self.addLink(roHostSwitch[j-1], host)
52
+ self.addLink(roHostSwitch[j-1], roSwitch[0])
53
+ self.addLink(roHostSwitch[j-1], roSwitch[1])
54
+
55
+ # Create the SDX hosts
56
+ for i in range(1, sdxHostCount +1):
57
+ sdxHostSwitch.append(self.addSwitch('swhsdx%d' % i, dpid='%d' % (HSWDPID + LOCMOD*SDXDEV + i)))
58
+ host = self.addHost('sdxh%d' % (i), ip='10.%d.0.%d' % (SDXDEV, i))
59
+ self.addLink(sdxHostSwitch[i-1], host)
60
+ self.addLink(sdxHostSwitch[i-1], sdxSpines[0])
61
+ self.addLink(sdxHostSwitch[i-1], sdxSpines[1])
62
+
63
+
64
+ # Create two links between the spine switches
65
+ #self.addLink(spines[0], spines[1])
66
+ #TODO add second link between spines when multi-link topos are supported
67
+ #self.addLink(spines[0], spines[1])
68
+
69
+ # Now create the leaf switches, their hosts and connect them together
70
+ #i = 1
71
+ #c = 0
72
+ # while i <= k:
73
+ # leaves.append(self.addSwitch('s1%d' % i))
74
+ # for spine in spines:
75
+ # self.addLink(leaves[i-1], spine)
76
+
77
+ # j = 1
78
+ # while j <= h:
79
+ # hosts.append(self.addHost('h%d%d' % (i, j), ip='192.168.%d.%d' %(i, j)))
80
+ # self.addLink(hosts[c], leaves[i-1])
81
+ # j+=1
82
+ # c+=1
83
+
84
+ # i+=1
85
+
86
+ topos = { 'tdaq': TdaqTopo }
87
+
88
+
89
+
90
+ def run():
91
+ topo = TdaqTopo()
92
+ net = Mininet( topo=topo, controller=RemoteController, autoSetMacs=True )
93
+ net.start()
94
+ CLI( net )
95
+ net.stop()
96
+
97
+ if __name__ == '__main__':
98
+ setLogLevel( 'info' )
99
+ run()
@@ -0,0 +1,121 @@
1
+ #PhaseITopologyPriorityQueues
2
+
3
+ =begin
4
+ http://asciiflow.com
5
+
6
+ +-------------+ +----------------+
7
+ | | | |
8
+ | Host0 | | Host1 |
9
+ +-------------+ +---+----------------+
10
+ | |
11
+ | |
12
+ | |
13
+ ++-------+-+
14
+ | |
15
+ | +-----------------------------+
16
+ +----------+Switch0 +-------------+ |
17
+ | +-------+--+ | |
18
+ | | | |
19
+ +----+---+ +----+---+ +---+-----+ +----+-----+
20
+ | | | | | | | |
21
+ |Switch1 | +------+Switch2 | |Switch3 | |Switch4 |
22
+ +------------+---+ | +------+-+--+ +---+-----++ +----------++
23
+ | | | | | | | | |
24
+ | | | +---+----+ | | +------+-+ ++------+ +-+--------+
25
+ +---+----+ +----+---+ | |Host4 | | | | | | | | |
26
+ | | | | | | +----+-+--+ | | Host9 | |Host10 | | Host11 |
27
+ |Host2 | | Host3 | | +-----Host5 | | +--------+ +-------+ +----------+
28
+ +--------+ +--------+ | | +----+-+-+
29
+ | +------Host6 |
30
+ | | +---+-----+
31
+ | +----+Host7 |
32
+ | | +----+---+
33
+ +----------------+------Host8 |
34
+ | | |
35
+ +---------------------+--------+
36
+
37
+
38
+ =end
39
+
40
+ module NetworkTopology
41
+ def get_topology
42
+ return @topology.topology_elements if @topology.topology_elements.size != 0
43
+
44
+ routers = []
45
+ hosts = []
46
+
47
+ # Routers
48
+ for i in 0..4
49
+ router = @topology.add_router "MyRouter#{i}"
50
+ routers.push router
51
+ end
52
+
53
+ # Hosts
54
+ for i in 0..11
55
+ host = @topology.add_host "Host#{i}"
56
+ hosts.push host
57
+ end
58
+
59
+ #Links (starting from the flows that goes from top to bottom)
60
+ @topology.add_link "Link1", hosts[0], 0, routers[0], 0
61
+ @topology.add_link "Link2", hosts[1], 0, routers[0], 1
62
+
63
+ @topology.add_link "Link3", routers[0], 0, routers[1], 0
64
+ @topology.add_link "Link4", routers[0], 1, routers[2], 0
65
+ @topology.add_link "Link5", routers[0], 2, routers[3], 0
66
+ @topology.add_link "Link6", routers[0], 3, routers[4], 0
67
+
68
+ @topology.add_link "Link7", routers[1], 0, hosts[2], 0
69
+ @topology.add_link "Link8", routers[1], 1, hosts[3], 0
70
+
71
+ @topology.add_link "Link9", routers[2], 0, hosts[4], 0
72
+ @topology.add_link "Link10", routers[2], 1, hosts[5], 0
73
+ @topology.add_link "Link11", routers[2], 2, hosts[6], 0
74
+ @topology.add_link "Link12", routers[2], 3, hosts[7], 0
75
+ @topology.add_link "Link13", routers[2], 4, hosts[8], 0
76
+
77
+ @topology.add_link "Link14", routers[3], 0, hosts[9], 0
78
+ @topology.add_link "Link15", routers[3], 1, hosts[10], 0
79
+
80
+ @topology.add_link "Link16", routers[4], 0, hosts[11], 0
81
+
82
+ #Links (flows that goes from bottom to top)
83
+ @topology.add_link "Link17", hosts[2], 0, routers[1], 1
84
+ @topology.add_link "Link18", hosts[3], 0, routers[1], 2
85
+
86
+ @topology.add_link "Link19", hosts[4], 0, routers[2], 1
87
+ @topology.add_link "Link20", hosts[5], 0, routers[2], 2
88
+ @topology.add_link "Link21", hosts[6], 0, routers[2], 3
89
+ @topology.add_link "Link22", hosts[7], 0, routers[2], 4
90
+ @topology.add_link "Link23", hosts[8], 0, routers[2], 5
91
+
92
+ @topology.add_link "Link24", hosts[9], 0, routers[3], 1
93
+ @topology.add_link "Link25", hosts[10], 0, routers[3], 2
94
+
95
+ @topology.add_link "Link26", hosts[11], 0, routers[4], 1
96
+
97
+ @topology.add_link "Link27", routers[1], 2, routers[0], 2
98
+ @topology.add_link "Link28", routers[2], 5, routers[0], 3
99
+ @topology.add_link "Link29", routers[3], 2, routers[0], 4
100
+ @topology.add_link "Link30", routers[4], 1, routers[0], 5
101
+
102
+ @topology.add_link "Link31", routers[0], 4, hosts[0], 0
103
+ @topology.add_link "Link32", routers[0], 5, hosts[1], 0
104
+
105
+
106
+ @topology.topology_elements
107
+ end
108
+
109
+ def get_path_between(source, destination)
110
+ raise Exception, "Source must be either from class Router or class Host to ask for a path" unless [Host, Router].include? source.class
111
+ raise Exception, "Destination must be either from class Router or class Host to ask for a path" unless [Host, Router].include? destination.class
112
+
113
+ #TODO: Implement this function seriously :P
114
+ path = Path.new(source,destination)
115
+ links = @topology.topology_elements.select { |elem| elem.is_a? Link }
116
+ links.each do |link|
117
+ path.add_link link
118
+ end
119
+ path
120
+ end
121
+ end
@@ -0,0 +1,76 @@
1
+ module NetworkTopology
2
+ def get_topology
3
+ return @topology.topology_elements if @topology.topology_elements.size != 0
4
+ hosts = []
5
+ routers = []
6
+ links = []
7
+
8
+
9
+ routers.push @topology.add_router "of:2000000000010101", [1]
10
+ routers.push @topology.add_router "of:2000000000010201", [1]
11
+ routers.push @topology.add_router "of:2000000000010102", [1]
12
+ routers.push @topology.add_router "of:2000000000010202", [1]
13
+ routers.push @topology.add_router "of:1000000000020001", [1]
14
+ routers.push @topology.add_router "of:2000000000030001", [1]
15
+ routers.push @topology.add_router "of:2000000000030002", [1]
16
+ routers.push @topology.add_router "of:1000000000020002", [1]
17
+ routers.push @topology.add_router "of:1000000000030002", [1]
18
+ routers.push @topology.add_router "of:1000000000030001", [1]
19
+ routers.push @topology.add_router "of:1000000000010201", [1]
20
+ routers.push @topology.add_router "of:1000000000010102", [1]
21
+ routers.push @topology.add_router "of:1000000000010202", [1]
22
+ routers.push @topology.add_router "of:1000000000010101", [1]
23
+
24
+ @topology.add_link "Link1", routers[7], 4, routers[12], 2, 500000000
25
+ @topology.add_link "Link2", routers[12], 2, routers[7], 4, 500000000
26
+ @topology.add_link "Link3", routers[3], 3, routers[12], 4, 500000000
27
+ @topology.add_link "Link4", routers[1], 2, routers[10], 3, 500000000
28
+ @topology.add_link "Link5", routers[11], 1, routers[13], 1, 500000000
29
+ @topology.add_link "Link6", routers[3], 2, routers[10], 4, 500000000
30
+ @topology.add_link "Link7", routers[9], 4, routers[6], 2, 500000000
31
+ @topology.add_link "Link8", routers[10], 1, routers[12], 1, 500000000
32
+ @topology.add_link "Link9", routers[13], 4, routers[2], 2, 500000000
33
+ @topology.add_link "Link10", routers[0], 2, routers[13], 3, 500000000
34
+ @topology.add_link "Link11", routers[2], 3, routers[11], 4, 500000000
35
+ @topology.add_link "Link12", routers[2], 2, routers[13], 4, 500000000
36
+ @topology.add_link "Link13", routers[13], 2, routers[4], 3, 500000000
37
+ @topology.add_link "Link14", routers[4], 2, routers[8], 1, 500000000
38
+ @topology.add_link "Link15", routers[4], 3, routers[13], 2, 500000000
39
+ @topology.add_link "Link16", routers[5], 2, routers[9], 3, 500000000
40
+ @topology.add_link "Link17", routers[6], 3, routers[8], 4, 500000000
41
+ @topology.add_link "Link18", routers[10], 3, routers[1], 2, 500000000
42
+ @topology.add_link "Link19", routers[12], 4, routers[3], 3, 500000000
43
+ @topology.add_link "Link20", routers[6], 2, routers[9], 4, 500000000
44
+ @topology.add_link "Link21", routers[12], 3, routers[1], 3, 500000000
45
+ @topology.add_link "Link22", routers[4], 4, routers[10], 2, 500000000
46
+ @topology.add_link "Link23", routers[10], 2, routers[4], 4, 500000000
47
+ @topology.add_link "Link24", routers[5], 3, routers[8], 3, 500000000
48
+ @topology.add_link "Link25", routers[10], 4, routers[3], 2, 500000000
49
+ @topology.add_link "Link26", routers[13], 1, routers[11], 1, 500000000
50
+ @topology.add_link "Link27", routers[4], 1, routers[9], 1, 500000000
51
+ @topology.add_link "Link28", routers[7], 2, routers[8], 2, 500000000
52
+ @topology.add_link "Link29", routers[7], 1, routers[9], 2, 500000000
53
+ @topology.add_link "Link30", routers[0], 3, routers[11], 3, 500000000
54
+ @topology.add_link "Link31", routers[11], 4, routers[2], 3, 500000000
55
+ @topology.add_link "Link32", routers[13], 3, routers[0], 2, 500000000
56
+ @topology.add_link "Link33", routers[11], 3, routers[0], 3, 500000000
57
+ @topology.add_link "Link34", routers[12], 1, routers[10], 1, 500000000
58
+ @topology.add_link "Link35", routers[8], 1, routers[4], 2, 500000000
59
+ @topology.add_link "Link36", routers[8], 2, routers[7], 2, 500000000
60
+ @topology.add_link "Link37", routers[8], 4, routers[6], 3, 500000000
61
+ @topology.add_link "Link38", routers[9], 1, routers[4], 1, 500000000
62
+ @topology.add_link "Link39", routers[9], 3, routers[5], 2, 500000000
63
+ @topology.add_link "Link40", routers[8], 3, routers[5], 3, 500000000
64
+ @topology.add_link "Link41", routers[9], 2, routers[7], 1, 500000000
65
+ @topology.add_link "Link42", routers[11], 2, routers[7], 3, 500000000
66
+ @topology.add_link "Link43", routers[1], 3, routers[12], 3, 500000000
67
+ @topology.add_link "Link44", routers[7], 3, routers[11], 2, 500000000
68
+
69
+ @topology.topology_elements
70
+ end
71
+
72
+ def get_path_between(source, destination)
73
+ #Think how to implement it!
74
+ Path.new(source,destination)
75
+ end
76
+ end
@@ -0,0 +1,119 @@
1
+ #PhaseITopologyPriorityQueues
2
+
3
+ =begin
4
+ http://asciiflow.com
5
+
6
+ +---------+ +-----------+ +-----------+
7
+ | | | | | |
8
+ | (Host0)| |(Host1) | | (Host2) |
9
+ | FelixServer1 |DCS | | Ctrl |
10
+ | | | | | |
11
+ +----+----+ +------+----+ +----+------+
12
+ | | |
13
+ | | |
14
+ | | |
15
+ | | |
16
+ | +-----+-------+ |
17
+ | | | |
18
+ +-----------------+ | |
19
+ | Router0 +-------------+
20
+ | |
21
+ +-----+-------+
22
+ |
23
+ |
24
+ |
25
+ +-----+-------+
26
+ | |
27
+ | |
28
+ +--------------------+ Router1 +-----------------+
29
+ | | | |
30
+ | +------+------+ |
31
+ | | |
32
+ | | |
33
+ +-----+------+ +--------+-----+ +-------+--------+
34
+ | | | | | |
35
+ | | | (Host4) | | (Host5) |
36
+ | (Host3) | | Dst2 | | Dst3 |
37
+ | Dst1 | | | | |
38
+ | | | | | |
39
+ +------------+ +--------------+ +----------------+
40
+
41
+
42
+ =end
43
+
44
+ module NetworkTopology
45
+ def get_topology
46
+ return @topology.topology_elements if @topology.topology_elements.size != 0
47
+
48
+ routers = []
49
+ hosts = []
50
+
51
+ for i in 0..1
52
+ routers.push @topology.add_router "MyRouter#{i}", [6,3,1,1,1,1,1,1]
53
+ end
54
+
55
+ for i in 0..5
56
+ host = @topology.add_host "Host#{i}"
57
+ hosts.push host
58
+ end
59
+
60
+ # In these examples, we dont need the links that goes from dst to FelixServer, DCS or control
61
+ # since the dst host's are never source.
62
+
63
+ #Links (starting from the flows that goes from top to bottom)
64
+ link1 = @topology.add_link "Link1", hosts[0], 0, routers[0], 0, 3*1000*1000 # 500 Mb/s
65
+ link2 = @topology.add_link "Link2", hosts[1], 0, routers[0], 1, 3*1000*1000 # 500 Mb/s
66
+ link3 = @topology.add_link "Link3", hosts[2], 0, routers[0], 2, 3*1000*1000 # 500 Mb/s
67
+
68
+ link4 = @topology.add_link "Link4", routers[0], 0, routers[1], 0, 2*1000*1000 # 500 Mb/s
69
+
70
+ link5 = @topology.add_link "Link5", routers[1], 0, hosts[3], 0, 3*1000*1000 # 500 Mb/s
71
+ link6 = @topology.add_link "Link6", routers[1], 1, hosts[4], 0, 3*1000*1000 # 500 Mb/s
72
+ link7 = @topology.add_link "Link7", routers[1], 2, hosts[5], 0, 3*1000*1000 # 500 Mb/s
73
+
74
+ flow_1_path = Path.new hosts[0], hosts[3]
75
+ flow_1_path.add_link link1
76
+ flow_1_path.add_link link4
77
+ flow_1_path.add_link link5
78
+ @topology.add_flow "Flow1",
79
+ 0,
80
+ flow_1_path,
81
+ (ConstantDistribution.new 0.001), #distribution rate in seconds
82
+ (ConstantDistribution.new 1*1000) #distribution size in bits
83
+
84
+ flow_2_path = Path.new hosts[1], hosts[4]
85
+ flow_2_path.add_link link2
86
+ flow_2_path.add_link link4
87
+ flow_2_path.add_link link6
88
+ @topology.add_flow "Flow2",
89
+ 1,
90
+ flow_2_path,
91
+ (ConstantDistribution.new 0.001), #distribution rate in seconds
92
+ (ConstantDistribution.new 1*1000) #distribution size in bits
93
+
94
+ flow_3_path = Path.new hosts[2], hosts[5]
95
+ flow_3_path.add_link link3
96
+ flow_3_path.add_link link4
97
+ flow_3_path.add_link link7
98
+ @topology.add_flow "Flow3",
99
+ 2,
100
+ flow_3_path,
101
+ (ConstantDistribution.new 0.001), #distribution rate in seconds
102
+ (ConstantDistribution.new 1*1000) #distribution size in bits
103
+
104
+ @topology.topology_elements
105
+ end
106
+
107
+ def get_path_between(source, destination)
108
+ raise Exception, "Source must be either from class Router or class Host to ask for a path" unless [Host, Router].include? source.class
109
+ raise Exception, "Destination must be either from class Router or class Host to ask for a path" unless [Host, Router].include? destination.class
110
+
111
+ first_link = @topology.topology_elements.select { |elem| (elem.is_a? Link) && (elem.src_element == source) }.first
112
+ second_link = @topology.topology_elements.select { |elem| (elem.is_a? Link) && (elem.dst_element == destination) }.first
113
+
114
+ path = Path.new(source,destination)
115
+ path.add_link first_link
116
+ path.add_link second_link
117
+ path
118
+ end
119
+ end
@@ -0,0 +1,102 @@
1
+ #PhaseITopologyPriorityQueues
2
+
3
+ =begin
4
+ http://asciiflow.com
5
+
6
+ +---------+ +----------+
7
+ | | | |
8
+ | | | |
9
+ | Host 0 | | |
10
+ | | |Host 1 |
11
+ +--------++ +----+-----+
12
+ | |
13
+ | +-----------+ |
14
+ | | | |
15
+ +---+ +--------+
16
+ |Router 0 |
17
+ | |
18
+ +------+----+
19
+ |
20
+ |
21
+ |
22
+ |
23
+ +-------+-----+
24
+ | |
25
+ | |
26
+ | Host 2 |
27
+ | |
28
+ +-------------+
29
+
30
+
31
+ =end
32
+
33
+ module NetworkTopology
34
+ def get_topology
35
+ return @topology.topology_elements if @topology.topology_elements.size != 0
36
+
37
+ routers = []
38
+ hosts = []
39
+
40
+ router = @topology.add_router "MyRouter1"
41
+ routers.push router
42
+
43
+ for i in 0..2
44
+ host = @topology.add_host "Host#{i}"
45
+ hosts.push host
46
+ end
47
+
48
+ #Links (starting from the flows that goes from top to bottom)
49
+ link1 = @topology.add_link "Link1", hosts[0], 0, routers[0], 0
50
+ link2 = @topology.add_link "Link2", hosts[1], 0, routers[0], 1
51
+
52
+ link3 = @topology.add_link "Link3", routers[0], 0, hosts[2], 0
53
+
54
+ #Links (flows that goes from bottom to top)
55
+ link4 = @topology.add_link "Link4", hosts[2], 0, routers[0], 2
56
+
57
+ link5 = @topology.add_link "Link5", routers[0], 1, hosts[0], 0
58
+ link6 = @topology.add_link "Link6", routers[0], 2, hosts[1], 0
59
+
60
+ flow_1_path = Path.new hosts[0], hosts[2]
61
+ flow_1_path.add_link link1
62
+ flow_1_path.add_link link3
63
+ @topology.add_flow "Flow1",
64
+ 10,
65
+ flow_1_path,
66
+ (ExponentialDistribution.new 1.0/6875),
67
+ (ConstantDistribution.new 1000*8)
68
+
69
+ flow_2_path = Path.new hosts[1], hosts[2]
70
+ flow_2_path.add_link link2
71
+ flow_2_path.add_link link3
72
+ @topology.add_flow "Flow2",
73
+ 15,
74
+ flow_2_path,
75
+ (ExponentialDistribution.new 1.0/6875),
76
+ (ConstantDistribution.new 1000*8)
77
+
78
+ flow_3_path = Path.new hosts[2], hosts[1]
79
+ flow_3_path.add_link link4
80
+ flow_3_path.add_link link5
81
+ @topology.add_flow "Flow3",
82
+ 20,
83
+ flow_3_path,
84
+ (ExponentialDistribution.new 1.0/6875),
85
+ (ConstantDistribution.new 1000*8)
86
+
87
+ @topology.topology_elements
88
+ end
89
+
90
+ def get_path_between(source, destination)
91
+ raise Exception, "Source must be either from class Router or class Host to ask for a path" unless [Host, Router].include? source.class
92
+ raise Exception, "Destination must be either from class Router or class Host to ask for a path" unless [Host, Router].include? destination.class
93
+
94
+ first_link = @topology.topology_elements.select { |elem| (elem.is_a? Link) && (elem.src_element == source) }.first
95
+ second_link = @topology.topology_elements.select { |elem| (elem.is_a? Link) && (elem.dst_element == destination) }.first
96
+
97
+ path = Path.new(source,destination)
98
+ path.add_link first_link
99
+ path.add_link second_link
100
+ path
101
+ end
102
+ end
@@ -0,0 +1,109 @@
1
+ #include "FlowDefinitions.h"
2
+
3
+ std::multimap<std::string, std::shared_ptr<Flow>> FlowDefinitions::Flows;
4
+
5
+ void FlowDefinitions::defineFlows(){
6
+
7
+
8
+ ///// definition of flow Flow0_1
9
+ auto flowFlow0_1PeriodDistribution = readDistributionParameter("flowFlow0_1.periodDistribution");
10
+ auto flowFlow0_1PacketSizeDistribution = readDistributionParameter("flowFlow0_1.packetSizeDistribution");
11
+ auto flowFlow0_1 = std::make_shared<Flow>("Flow0_1", 0 /*startTime*/, 0 /*typeOfService*/, flowFlow0_1PeriodDistribution, flowFlow0_1PacketSizeDistribution);
12
+ // routes for flow Flow0_1
13
+ auto flowFlow0_1_route0 = std::make_shared<Route>( std::deque<Route::Node>{
14
+ {0, "lar_felix_0.Routing"},
15
+ {2, "lar_switch_01.Routing"},
16
+ {0, "lar_swrod_0.Routing"}
17
+ });
18
+ auto flowFlow0_1_route1 = std::make_shared<Route>( std::deque<Route::Node>{
19
+ {1, "lar_felix_0.Routing"},
20
+ {2, "lar_switch_02.Routing"},
21
+ {1, "lar_swrod_0.Routing"}
22
+ });
23
+ // register flow Flow0_1 with its routes
24
+ FlowDefinitions::registerFlowSourceNode(flowFlow0_1, "lar_felix_0.GeneratorApplication");
25
+ FlowDefinitions::registerFlowRoute(flowFlow0_1, flowFlow0_1_route0);
26
+ FlowDefinitions::registerFlowRoute(flowFlow0_1, flowFlow0_1_route1);
27
+
28
+
29
+ ///// definition of flow Flow_Monitoring0_1
30
+ auto flowFlow_Monitoring0_1PeriodDistribution = readDistributionParameter("flowFlow_Monitoring0_1.periodDistribution");
31
+ auto flowFlow_Monitoring0_1PacketSizeDistribution = readDistributionParameter("flowFlow_Monitoring0_1.packetSizeDistribution");
32
+ auto flowFlow_Monitoring0_1 = std::make_shared<Flow>("Flow_Monitoring0_1", 0 /*startTime*/, 0 /*typeOfService*/, flowFlow_Monitoring0_1PeriodDistribution, flowFlow_Monitoring0_1PacketSizeDistribution);
33
+ // routes for flow Flow_Monitoring0_1
34
+ auto flowFlow_Monitoring0_1_route0 = std::make_shared<Route>( std::deque<Route::Node>{
35
+ {0, "lar_felix_0.Routing"},
36
+ {2, "lar_switch_01.Routing"},
37
+ {0, "lar_swrod_0.Routing"}
38
+ });
39
+ // register flow Flow_Monitoring0_1 with its routes
40
+ FlowDefinitions::registerFlowSourceNode(flowFlow_Monitoring0_1, "lar_felix_0.GeneratorApplication");
41
+ FlowDefinitions::registerFlowRoute(flowFlow_Monitoring0_1, flowFlow_Monitoring0_1_route0);
42
+
43
+
44
+ ///// definition of flow Flow_Control0_1
45
+ auto flowFlow_Control0_1PeriodDistribution = readDistributionParameter("flowFlow_Control0_1.periodDistribution");
46
+ auto flowFlow_Control0_1PacketSizeDistribution = readDistributionParameter("flowFlow_Control0_1.packetSizeDistribution");
47
+ auto flowFlow_Control0_1 = std::make_shared<Flow>("Flow_Control0_1", 0 /*startTime*/, 0 /*typeOfService*/, flowFlow_Control0_1PeriodDistribution, flowFlow_Control0_1PacketSizeDistribution);
48
+ // routes for flow Flow_Control0_1
49
+ auto flowFlow_Control0_1_route0 = std::make_shared<Route>( std::deque<Route::Node>{
50
+ {1, "lar_felix_0.Routing"},
51
+ {2, "lar_switch_02.Routing"},
52
+ {1, "lar_swrod_0.Routing"}
53
+ });
54
+ // register flow Flow_Control0_1 with its routes
55
+ FlowDefinitions::registerFlowSourceNode(flowFlow_Control0_1, "lar_felix_0.GeneratorApplication");
56
+ FlowDefinitions::registerFlowRoute(flowFlow_Control0_1, flowFlow_Control0_1_route0);
57
+
58
+
59
+ ///// definition of flow Flow1_1
60
+ auto flowFlow1_1PeriodDistribution = readDistributionParameter("flowFlow1_1.periodDistribution");
61
+ auto flowFlow1_1PacketSizeDistribution = readDistributionParameter("flowFlow1_1.packetSizeDistribution");
62
+ auto flowFlow1_1 = std::make_shared<Flow>("Flow1_1", 0 /*startTime*/, 0 /*typeOfService*/, flowFlow1_1PeriodDistribution, flowFlow1_1PacketSizeDistribution);
63
+ // routes for flow Flow1_1
64
+ auto flowFlow1_1_route0 = std::make_shared<Route>( std::deque<Route::Node>{
65
+ {0, "lar_felix_1.Routing"},
66
+ {3, "lar_switch_01.Routing"},
67
+ {0, "lar_swrod_1.Routing"}
68
+ });
69
+ auto flowFlow1_1_route1 = std::make_shared<Route>( std::deque<Route::Node>{
70
+ {1, "lar_felix_1.Routing"},
71
+ {3, "lar_switch_02.Routing"},
72
+ {1, "lar_swrod_1.Routing"}
73
+ });
74
+ // register flow Flow1_1 with its routes
75
+ FlowDefinitions::registerFlowSourceNode(flowFlow1_1, "lar_felix_1.GeneratorApplication");
76
+ FlowDefinitions::registerFlowRoute(flowFlow1_1, flowFlow1_1_route0);
77
+ FlowDefinitions::registerFlowRoute(flowFlow1_1, flowFlow1_1_route1);
78
+
79
+
80
+ ///// definition of flow Flow_Monitoring1_1
81
+ auto flowFlow_Monitoring1_1PeriodDistribution = readDistributionParameter("flowFlow_Monitoring1_1.periodDistribution");
82
+ auto flowFlow_Monitoring1_1PacketSizeDistribution = readDistributionParameter("flowFlow_Monitoring1_1.packetSizeDistribution");
83
+ auto flowFlow_Monitoring1_1 = std::make_shared<Flow>("Flow_Monitoring1_1", 0 /*startTime*/, 0 /*typeOfService*/, flowFlow_Monitoring1_1PeriodDistribution, flowFlow_Monitoring1_1PacketSizeDistribution);
84
+ // routes for flow Flow_Monitoring1_1
85
+ auto flowFlow_Monitoring1_1_route0 = std::make_shared<Route>( std::deque<Route::Node>{
86
+ {0, "lar_felix_1.Routing"},
87
+ {3, "lar_switch_01.Routing"},
88
+ {0, "lar_swrod_1.Routing"}
89
+ });
90
+ // register flow Flow_Monitoring1_1 with its routes
91
+ FlowDefinitions::registerFlowSourceNode(flowFlow_Monitoring1_1, "lar_felix_1.GeneratorApplication");
92
+ FlowDefinitions::registerFlowRoute(flowFlow_Monitoring1_1, flowFlow_Monitoring1_1_route0);
93
+
94
+
95
+ ///// definition of flow Flow_Control1_1
96
+ auto flowFlow_Control1_1PeriodDistribution = readDistributionParameter("flowFlow_Control1_1.periodDistribution");
97
+ auto flowFlow_Control1_1PacketSizeDistribution = readDistributionParameter("flowFlow_Control1_1.packetSizeDistribution");
98
+ auto flowFlow_Control1_1 = std::make_shared<Flow>("Flow_Control1_1", 0 /*startTime*/, 0 /*typeOfService*/, flowFlow_Control1_1PeriodDistribution, flowFlow_Control1_1PacketSizeDistribution);
99
+ // routes for flow Flow_Control1_1
100
+ auto flowFlow_Control1_1_route0 = std::make_shared<Route>( std::deque<Route::Node>{
101
+ {1, "lar_felix_1.Routing"},
102
+ {3, "lar_switch_02.Routing"},
103
+ {1, "lar_swrod_1.Routing"}
104
+ });
105
+ // register flow Flow_Control1_1 with its routes
106
+ FlowDefinitions::registerFlowSourceNode(flowFlow_Control1_1, "lar_felix_1.GeneratorApplication");
107
+ FlowDefinitions::registerFlowRoute(flowFlow_Control1_1, flowFlow_Control1_1_route0);
108
+
109
+ }
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ cp topology.pdm /home/alaurito/Desktop/repos/powerdevs/examples/Andy
4
+ cp FlowDefinitions.cpp /home/alaurito/Desktop/repos/powerdevs/atomics/PhaseI
5
+ cp flows_definition.scilabParams /home/alaurito/Desktop/repos/powerdevs/examples/Matias/PhaseI/Scilab
6
+ cp links_definition.scilabParams /home/alaurito/Desktop/repos/powerdevs/examples/Matias/PhaseI/Scilab
7
+ cp routers_definition.scilabParams /home/alaurito/Desktop/repos/powerdevs/examples/Matias/PhaseI/Scilab
8
+ cp hosts_definition.scilabParams /home/alaurito/Desktop/repos/powerdevs/examples/Matias/PhaseI/Scilab
@@ -0,0 +1,30 @@
1
+
2
+ flowFlow0_1.periodDistribution = DISTRIBUTION_EXPONENTIAL;
3
+ flowFlow0_1.periodDistribution_mu = 0.1; // mean for the exponential distribution.
4
+ flowFlow0_1.packetSizeDistribution = DISTRIBUTION_CONSTANT;
5
+ flowFlow0_1.packetSizeDistribution_value = 1000.0; // value for the constant distribution
6
+
7
+ flowFlow_Monitoring0_1.periodDistribution = DISTRIBUTION_EXPONENTIAL;
8
+ flowFlow_Monitoring0_1.periodDistribution_mu = 0.05; // mean for the exponential distribution.
9
+ flowFlow_Monitoring0_1.packetSizeDistribution = DISTRIBUTION_CONSTANT;
10
+ flowFlow_Monitoring0_1.packetSizeDistribution_value = 500; // value for the constant distribution
11
+
12
+ flowFlow_Control0_1.periodDistribution = DISTRIBUTION_EXPONENTIAL;
13
+ flowFlow_Control0_1.periodDistribution_mu = 0.06666666666666667; // mean for the exponential distribution.
14
+ flowFlow_Control0_1.packetSizeDistribution = DISTRIBUTION_CONSTANT;
15
+ flowFlow_Control0_1.packetSizeDistribution_value = 100; // value for the constant distribution
16
+
17
+ flowFlow1_1.periodDistribution = DISTRIBUTION_EXPONENTIAL;
18
+ flowFlow1_1.periodDistribution_mu = 0.1; // mean for the exponential distribution.
19
+ flowFlow1_1.packetSizeDistribution = DISTRIBUTION_CONSTANT;
20
+ flowFlow1_1.packetSizeDistribution_value = 1000.0; // value for the constant distribution
21
+
22
+ flowFlow_Monitoring1_1.periodDistribution = DISTRIBUTION_EXPONENTIAL;
23
+ flowFlow_Monitoring1_1.periodDistribution_mu = 0.05; // mean for the exponential distribution.
24
+ flowFlow_Monitoring1_1.packetSizeDistribution = DISTRIBUTION_CONSTANT;
25
+ flowFlow_Monitoring1_1.packetSizeDistribution_value = 500; // value for the constant distribution
26
+
27
+ flowFlow_Control1_1.periodDistribution = DISTRIBUTION_EXPONENTIAL;
28
+ flowFlow_Control1_1.periodDistribution_mu = 0.06666666666666667; // mean for the exponential distribution.
29
+ flowFlow_Control1_1.packetSizeDistribution = DISTRIBUTION_CONSTANT;
30
+ flowFlow_Control1_1.packetSizeDistribution_value = 100; // value for the constant distribution