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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/behaviors/serialize_behavior.rb +14 -0
- data/lib/builders_examples/pdm_builders/PhaseI/Flow_concrete_builder.rb +82 -0
- data/lib/builders_examples/pdm_builders/PhaseI/Host_concrete_builder.rb +24 -0
- data/lib/builders_examples/pdm_builders/PhaseI/Link_concrete_builder.rb +150 -0
- data/lib/builders_examples/pdm_builders/PhaseI/Router_concrete_builder.rb +24 -0
- data/lib/builders_examples/pdm_builders/PhaseI/output_concrete_builder.rb +86 -0
- data/lib/builders_examples/pdm_builders/PhaseI/pdm_constants.rb +111 -0
- data/lib/builders_examples/pdm_builders/PhaseIWithPriorityQueues/Flow_concrete_builder.rb +82 -0
- data/lib/builders_examples/pdm_builders/PhaseIWithPriorityQueues/Host_concrete_builder.rb +335 -0
- data/lib/builders_examples/pdm_builders/PhaseIWithPriorityQueues/Link_concrete_builder.rb +25 -0
- data/lib/builders_examples/pdm_builders/PhaseIWithPriorityQueues/Router_concrete_builder.rb +449 -0
- data/lib/builders_examples/pdm_builders/PhaseIWithPriorityQueues/output_concrete_builder.rb +229 -0
- data/lib/builders_examples/ruby_builders/Flow_concrete_builder.rb +5 -0
- data/lib/builders_examples/ruby_builders/Host_concrete_builder.rb +5 -0
- data/lib/builders_examples/ruby_builders/Link_concrete_builder.rb +5 -0
- data/lib/builders_examples/ruby_builders/Router_concrete_builder.rb +5 -0
- data/lib/builders_examples/ruby_builders/output_concrete_builder.rb +78 -0
- data/lib/command_line/command_line_arguments.rb +59 -0
- data/lib/createTopology.rb +10 -0
- data/lib/flows_distributions/constant_distribution.rb +7 -0
- data/lib/flows_distributions/exponential_distribution.rb +7 -0
- data/lib/flows_distributions/normal_distribution.rb +8 -0
- data/lib/flows_distributions/pareto_distribution.rb +9 -0
- data/lib/flows_distributions/split_distribution.rb +8 -0
- data/lib/network_entities/abstracts/flow.rb +27 -0
- data/lib/network_entities/abstracts/network_element.rb +19 -0
- data/lib/network_entities/abstracts/path.rb +16 -0
- data/lib/network_entities/physical/host.rb +10 -0
- data/lib/network_entities/physical/link.rb +36 -0
- data/lib/network_entities/physical/router.rb +12 -0
- data/lib/network_entities/topology.rb +69 -0
- data/lib/network_topologies_examples/PhaseI_onlyLAr_1FelixTo1SWROD.rb +93 -0
- data/lib/network_topologies_examples/octopus_topology.rb +66 -0
- data/lib/network_topologies_examples/phase1_topology_mininet/tdaq +4 -0
- data/lib/network_topologies_examples/phase1_topology_mininet/tdaq.py +99 -0
- data/lib/network_topologies_examples/sofisticated_octopus_topology.rb +121 -0
- data/lib/network_topologies_examples/tdaq_network_topology.rb +76 -0
- data/lib/network_topologies_examples/tdaq_topology_example.rb +119 -0
- data/lib/network_topologies_examples/tree_topology.rb +102 -0
- data/lib/output/FlowDefinitions.cpp +109 -0
- data/lib/output/copy_files.sh +8 -0
- data/lib/output/flows_definition.scilabParams +30 -0
- data/lib/output/hosts_definition.scilabParams +5 -0
- data/lib/output/links_definition.scilabParams +48 -0
- data/lib/output/routers_definition.scilabParams +24 -0
- data/lib/output/ruby_network_topology.rb +76 -0
- data/lib/output/topology.pdm +5321 -0
- data/lib/output_builder.rb +39 -0
- data/lib/providers/apis/onos_topology_provider.rb +146 -0
- data/lib/providers/customs/custom_topology_provider.rb +14 -0
- data/lib/providers/interface_topology_provider.rb +11 -0
- data/lib/topologygenerator/version.rb +3 -0
- data/lib/topologygenerator.rb +34 -0
- data/lib/utils/custom_files_utils.rb +16 -0
- data/topologygenerator.gemspec +45 -0
- metadata +188 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
module OutputConcreteBuilder
|
2
|
+
OUTPUT_RUBY_FILE_NAME = 'ruby_network_topology.rb'
|
3
|
+
|
4
|
+
def initialize_concrete_builder(topology_provider, directory_concrete_builders, output_directory)
|
5
|
+
@topology_provider = topology_provider
|
6
|
+
@directory_concrete_builders = directory_concrete_builders # make's sense?
|
7
|
+
@output_directory = output_directory
|
8
|
+
end
|
9
|
+
|
10
|
+
def build_output_content
|
11
|
+
graph_elements = topology_provider.get_topology
|
12
|
+
|
13
|
+
graph_elements = graph_elements.select { |elem| [Host,Link,Router].include? elem.class }
|
14
|
+
|
15
|
+
ruby_network_topology = "module NetworkTopology \n"
|
16
|
+
|
17
|
+
get_topology_function_def =" def get_topology \n "
|
18
|
+
get_topology_function_def +=" return @topology.topology_elements if @topology.topology_elements.size != 0 \n"
|
19
|
+
get_topology_function_def +=" hosts = [] \n "
|
20
|
+
get_topology_function_def +=" routers = [] \n"
|
21
|
+
get_topology_function_def +=" links = [] \n"
|
22
|
+
get_topology_function_def +="\n"
|
23
|
+
|
24
|
+
get_topology_function_def += add_elements_of_type graph_elements, Host
|
25
|
+
get_topology_function_def += add_elements_of_type graph_elements, Router
|
26
|
+
get_topology_function_def += add_elements_of_type graph_elements, Link
|
27
|
+
|
28
|
+
get_topology_function_def +=" @topology.topology_elements \n "
|
29
|
+
get_topology_function_def +=" end \n"
|
30
|
+
|
31
|
+
get_path_definition_function_def = " def get_path_between(source, destination) \n"
|
32
|
+
get_path_definition_function_def += " raise NotImplementedError, \"NetworkTopology: This method is not implemented (¿does it ever get called?)\" \n"
|
33
|
+
get_path_definition_function_def += " end \n"
|
34
|
+
|
35
|
+
ruby_network_topology += get_topology_function_def
|
36
|
+
ruby_network_topology += "\n"
|
37
|
+
ruby_network_topology += get_path_definition_function_def
|
38
|
+
ruby_network_topology += 'end'
|
39
|
+
|
40
|
+
|
41
|
+
write_file "#{@output_directory}/#{OUTPUT_RUBY_FILE_NAME}",
|
42
|
+
ruby_network_topology
|
43
|
+
end
|
44
|
+
|
45
|
+
def add_elements_of_type(graph_elements, type)
|
46
|
+
elements_to_add = graph_elements.select { |elem| elem.is_a? type }
|
47
|
+
|
48
|
+
elements_def = ''
|
49
|
+
|
50
|
+
elements_to_add.each do |element|
|
51
|
+
elements_def += " #{element.transform_to_output_representation @directory_concrete_builders} \n"
|
52
|
+
end
|
53
|
+
|
54
|
+
elements_def = replace_ids_host_router_for_index graph_elements, elements_def if type == Link
|
55
|
+
|
56
|
+
elements_def += "\n"
|
57
|
+
elements_def
|
58
|
+
end
|
59
|
+
|
60
|
+
def replace_ids_host_router_for_index(graph_elements, links_definition)
|
61
|
+
# Links have a dst and a src. These elements are in one of either hosts or routers array,
|
62
|
+
# however the index is unkown for the Link!, Instead of serializing the src/dst, the link
|
63
|
+
# prints it's element id. We now have to find this id (which is a string), and replace it by the
|
64
|
+
# corresponding element of the array.
|
65
|
+
hosts = graph_elements.select { |elem| elem.is_a? Host }
|
66
|
+
routers = graph_elements.select { |elem| elem.is_a? Router }
|
67
|
+
|
68
|
+
hosts.each_with_index do |host,index|
|
69
|
+
links_definition.gsub! host.id, "hosts[#{index}]"
|
70
|
+
end
|
71
|
+
|
72
|
+
routers.each_with_index do |router,index|
|
73
|
+
links_definition.gsub! router.id, "routers[#{index}]"
|
74
|
+
end
|
75
|
+
|
76
|
+
links_definition
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'commander'
|
2
|
+
require 'uri'
|
3
|
+
require 'byebug'
|
4
|
+
|
5
|
+
class CommandLineArguments
|
6
|
+
include Commander::Methods
|
7
|
+
|
8
|
+
attr_reader :source, :uri_resource, :output_directory, :directory_concrete_builders
|
9
|
+
|
10
|
+
def run
|
11
|
+
program :name, 'Create PowerDevs topology'
|
12
|
+
program :version, '0.0.1'
|
13
|
+
program :description, 'Script for creating PowerDevs topology. The output will be a .pdm file'
|
14
|
+
program :help, 'Author', 'Andrés Laurito && Matias Bonaventura'
|
15
|
+
|
16
|
+
my_command_line_argument = self
|
17
|
+
|
18
|
+
my_command = command :source do |c|
|
19
|
+
c.syntax = 'createTopology source [OPTIONS]'
|
20
|
+
c.summary = 'Specify data source for retrieving the topology'
|
21
|
+
c.description = 'Specify the data source from where the topology should be retrieved
|
22
|
+
An example of use: createTopology source ONOS
|
23
|
+
By default, the option is set in CUSTOM.
|
24
|
+
You can also set the output file with the -f option. For example, createTopology source ONOS -f topology
|
25
|
+
By default, the output will be written in a file called my_topology'
|
26
|
+
c.example 'Set ONOS as source', 'createTopology source -n ONOS'
|
27
|
+
c.example 'Set CUSTOM as source', 'createTopology source -n CUSTOM'
|
28
|
+
c.example 'Set CUSTOM as source and called the output file my_file', 'createTopology source -n MOCK -f my_file'
|
29
|
+
c.option '-n', '--name NAME', String, 'Specify the source name'
|
30
|
+
c.option '-o', '--outDir NAME', String, 'Specify the output directory path'
|
31
|
+
c.option '-u', '--uri NAME', String, 'Specify the uri for the source'
|
32
|
+
c.option '-d', '--dirBuilders NAME', String, 'Specify the directory where the builders are located'
|
33
|
+
c.action do |args, options|
|
34
|
+
options.default :file => 'my_topology'
|
35
|
+
options.default :outDir => 'output'
|
36
|
+
options.default :dirBuilders => 'builders_examples/pdm_builders/PhaseI'
|
37
|
+
new_source = options.name
|
38
|
+
raise ArgumentError, "The source '#{new_source}' is not one of the expected. Please type source --help to more information." unless ['ONOS','CUSTOM'].include? new_source
|
39
|
+
|
40
|
+
if new_source == 'ONOS'
|
41
|
+
new_uri_resource = options.uri
|
42
|
+
new_uri_resource = ask 'http source for ONOS?:(example http://127.0.0.1:8181/onos/v1/)' unless new_uri_resource
|
43
|
+
raise ArgumentError, "You must specify a valid http source when the option ONOS is selected. #{new_uri_resource} is not a valid one" unless new_uri_resource =~ /\A#{URI::regexp(['http', 'https'])}\z/
|
44
|
+
elsif new_source == 'CUSTOM'
|
45
|
+
new_uri_resource = options.uri
|
46
|
+
new_uri_resource = ask 'uri source for CUSTOM?:(example network_topologies_examples/tree_topology.rb)' unless new_uri_resource
|
47
|
+
raise ArgumentError, "You must specify a valid uri source when the option CUSTOM is selected. #{new_uri_resource} is not a valid one" unless File.exists? new_uri_resource
|
48
|
+
end
|
49
|
+
|
50
|
+
@source = new_source
|
51
|
+
@uri_resource = new_uri_resource
|
52
|
+
@output_directory = options.outDir
|
53
|
+
@directory_concrete_builders = options.dirBuilders
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
run!
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative 'command_line/command_line_arguments.rb'
|
4
|
+
require_relative "./topology_generator.rb"
|
5
|
+
|
6
|
+
my_command_line_arguments = CommandLineArguments.new
|
7
|
+
my_command_line_arguments.run
|
8
|
+
|
9
|
+
topo_gen = topologygenerator.new my_command_line_arguments
|
10
|
+
topo_gen.generate
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative '../../behaviors/serialize_behavior.rb'
|
2
|
+
require_relative '../../flows_distributions/constant_distribution.rb'
|
3
|
+
require_relative '../../flows_distributions/exponential_distribution.rb'
|
4
|
+
require_relative '../../flows_distributions/normal_distribution.rb'
|
5
|
+
require_relative '../../flows_distributions/pareto_distribution.rb'
|
6
|
+
require_relative '../../flows_distributions/split_distribution.rb'
|
7
|
+
|
8
|
+
class Flow
|
9
|
+
include SerializeBehavior
|
10
|
+
|
11
|
+
attr_accessor :id, :priority, :paths, :distribution_rate, :distribution_size
|
12
|
+
|
13
|
+
def initialize(id, priority, paths, distribution_rate, distribution_size)
|
14
|
+
raise "Invalid 'priority' argument received. Priority must be a number, #{priority} was received" unless priority.is_a? Integer
|
15
|
+
raise "Invalid 'paths' argument received. 'paths' must be an instance of Arry class, however the path received has class #{paths.class}" unless paths.is_a? Array
|
16
|
+
raise "Invalid 'distribution_rate' received. Distribution rate cannot be nil" unless distribution_rate
|
17
|
+
raise "Invalid 'distribution_size' received. Distribution size cannot be nil" unless distribution_size
|
18
|
+
raise "Invalid 'distribution_rate' #{distribution_rate}. It is expected that the rate is an instance of a distribution" unless [ConstantDistribution, ExponentialDistribution, NormalDistribution, ParetoDistribution, SplitDistribution].include? distribution_rate.class
|
19
|
+
raise "Invalid 'distribution_size' #{distribution_size}. It is expected that the size is an instance of a distribution" unless [ConstantDistribution, ExponentialDistribution, NormalDistribution, ParetoDistribution, SplitDistribution].include? distribution_size.class
|
20
|
+
|
21
|
+
@id = id
|
22
|
+
@priority = priority
|
23
|
+
@paths = paths
|
24
|
+
@distribution_rate = distribution_rate
|
25
|
+
@distribution_size = distribution_size
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative '../../behaviors/serialize_behavior.rb'
|
2
|
+
|
3
|
+
class NetworkElement
|
4
|
+
include SerializeBehavior
|
5
|
+
|
6
|
+
attr_reader :id, :my_number, :out_elements, :in_elements
|
7
|
+
|
8
|
+
def initialize(id)
|
9
|
+
@my_number = self.increase_quantity_in_one
|
10
|
+
@id = id
|
11
|
+
@out_elements = []
|
12
|
+
@in_elements = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def increase_quantity_in_one
|
16
|
+
@@quantity ||= 0
|
17
|
+
@@quantity += 1
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Path
|
2
|
+
attr_reader :links, :source, :destination
|
3
|
+
|
4
|
+
def initialize(source, destination)
|
5
|
+
raise "Invalid 'source' argument received. Path must contain a source" unless source
|
6
|
+
raise "Invalid 'destination' argument received. Path must contain a destination" unless destination
|
7
|
+
|
8
|
+
@source = source
|
9
|
+
@destination = destination
|
10
|
+
@links = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_link(link)
|
14
|
+
@links.push link
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative '../abstracts/network_element.rb'
|
2
|
+
|
3
|
+
class Link < NetworkElement
|
4
|
+
|
5
|
+
attr_reader :src_element, :src_port, :dst_element, :dst_port, :bandwith, :delay
|
6
|
+
|
7
|
+
"port numbers are 0-based (like in the c++ of powerdevs)"
|
8
|
+
def initialize(id, src_element, src_port, dst_element, dst_port, bandwith = 500*1000*1000, delay = 0)
|
9
|
+
|
10
|
+
bandwith ||= 500*1000*1000 # 500 Mb/s
|
11
|
+
delay ||= 0
|
12
|
+
|
13
|
+
raise "Attempted to create an invalid Link. Invalid source #{src_element}" if (!src_element.is_a? Router) && (!src_element.is_a? Host)
|
14
|
+
raise "Attempted to create an invalid Link. Invalid destination '#{dst_element}'" if (!dst_element.is_a? Router) && (!dst_element.is_a? Host)
|
15
|
+
raise "Attempted to create an invalid Link. Invalid source port '#{src_port}' must be an integer" if (!src_port.is_a? Integer)
|
16
|
+
raise "Attempted to create an invalid Link. Invalid destination port '#{dst_port}' must be an integer" if (!dst_port.is_a? Integer)
|
17
|
+
raise "Invalid Source port. Port '#{src_port}' already in use for '#{src_element}'" if src_element.out_elements[src_port]
|
18
|
+
raise "Invalid Destination port. Port '#{dst_port}' already in use for '#{dst_element}'" if dst_element.in_elements[dst_port]
|
19
|
+
raise "#{src} was not found as an element of the topology" if src_element.nil?
|
20
|
+
raise "#{dst} was not found as an element of the topology" if dst_element.nil?
|
21
|
+
raise "Bandwith must be a number, #{bandwith} was recieved" unless bandwith.is_a? Integer
|
22
|
+
|
23
|
+
@src_element = src_element
|
24
|
+
@src_port = src_port
|
25
|
+
@dst_element = dst_element
|
26
|
+
@dst_port = dst_port
|
27
|
+
@bandwith = bandwith # Expressed in bits per second (bit/s)
|
28
|
+
@delay = delay
|
29
|
+
|
30
|
+
# add each other
|
31
|
+
@src_element.out_elements[src_port] = @dst_element
|
32
|
+
@dst_element.in_elements[dst_port] = @src_element
|
33
|
+
|
34
|
+
super id
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative '../abstracts/network_element.rb'
|
2
|
+
|
3
|
+
class Router < NetworkElement
|
4
|
+
|
5
|
+
attr_reader :priority_weights, :buffer
|
6
|
+
|
7
|
+
def initialize(id, priority_weights=[1], buffer=-1)
|
8
|
+
@priority_weights = priority_weights
|
9
|
+
@buffer = buffer
|
10
|
+
super id
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require_relative "abstracts/network_element.rb"
|
2
|
+
require_relative "abstracts/flow.rb"
|
3
|
+
require_relative "physical/host.rb"
|
4
|
+
require_relative "physical/link.rb"
|
5
|
+
require_relative "physical/router.rb"
|
6
|
+
|
7
|
+
"A helper class to build consistent topologies"
|
8
|
+
class Topology
|
9
|
+
attr_reader :topology_elements
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@topology_elements = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_element_by_id(element_id)
|
16
|
+
@topology_elements.find{|x| x.id == element_id }
|
17
|
+
end
|
18
|
+
|
19
|
+
def elements_of_type(type)
|
20
|
+
@topology_elements.select { |elem| elem.is_a? type }
|
21
|
+
end
|
22
|
+
|
23
|
+
def links
|
24
|
+
elements_of_type Link
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_host(id)
|
28
|
+
raise "ID '#{id}' already exists in topology" if get_element_by_id id
|
29
|
+
|
30
|
+
new_host = Host.new id
|
31
|
+
@topology_elements.push new_host
|
32
|
+
new_host
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_router(id, priority_weights=[1], buffer=-1)
|
36
|
+
raise "ID '#{id}' already exists in topology" if get_element_by_id id
|
37
|
+
|
38
|
+
new_router = Router.new id, priority_weights, buffer
|
39
|
+
@topology_elements.push new_router
|
40
|
+
new_router
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_link(id, src, src_port, dst, dst_port, bandwith = nil)
|
44
|
+
raise "ID '#{id}' already exists in topology" if get_element_by_id id
|
45
|
+
|
46
|
+
# if they sent the id of the src or dst => search the object
|
47
|
+
src_node = (src.is_a? NetworkElement) ? src : (get_element_by_id src)
|
48
|
+
dst_node = (dst.is_a? NetworkElement) ? dst : (get_element_by_id dst)
|
49
|
+
|
50
|
+
new_link = Link.new id, src_node, src_port, dst_node, dst_port, bandwith
|
51
|
+
@topology_elements.push new_link
|
52
|
+
new_link
|
53
|
+
end
|
54
|
+
|
55
|
+
def add_full_duplex_link(id, src, src_port, dst, dst_port, bandwith = nil)
|
56
|
+
add_link("#{id}_up", src, src_port, dst, dst_port, bandwith) # up
|
57
|
+
add_link("#{id}_down", dst, dst_port, src, src_port, bandwith) # down
|
58
|
+
end
|
59
|
+
|
60
|
+
def add_flow(id, priority, path, distribution_rate, distribution_size)
|
61
|
+
raise "ID '#{id}' already exists in topology" if get_element_by_id id
|
62
|
+
|
63
|
+
distribution_rate ||= ConstantDistribution.new 0
|
64
|
+
distribution_size ||= ConstantDistribution.new 0
|
65
|
+
new_flow = Flow.new id, priority, path, distribution_rate, distribution_size
|
66
|
+
@topology_elements.push new_flow
|
67
|
+
new_flow
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module NetworkTopology
|
2
|
+
# constants
|
3
|
+
K = 1000 # Kilo=10³
|
4
|
+
M = 1000 * K # Megas=10⁶
|
5
|
+
G = 1000 * M # Megas=10⁶
|
6
|
+
|
7
|
+
# parameters
|
8
|
+
NUMBER_OF_FELIX_SERVERS = 2 # this generates 1:1 connections with sw_rod, so NUMBER_OF_FELIX_SERVERS=numberOfSWRODServers
|
9
|
+
LINK_BW_BITS_S = 40 * G # 40 Gbps
|
10
|
+
FELIX_GENERATION_PERIOD = ExponentialDistribution.new 1/10.0 # distribution period in seconds
|
11
|
+
FELIX_GENERATION_SIZE = ConstantDistribution.new 1.0*K #distribution size in bits
|
12
|
+
FELIX_MONITORING_GENERATION_PERIOD = ExponentialDistribution.new 1/20.0 # distribution period in seconds
|
13
|
+
FELIX_MONITORING_GENERATION_SIZE = ConstantDistribution.new 500 #distribution size in bits
|
14
|
+
FELIX_CONTROL_GENERATION_PERIOD = ExponentialDistribution.new 1/15.0 # distribution period in seconds
|
15
|
+
FELIX_CONTROL_GENERATION_SIZE = ConstantDistribution.new 100 #distribution size in bits
|
16
|
+
FELIX_FLOW_PRIORITY = 0
|
17
|
+
|
18
|
+
|
19
|
+
def get_topology
|
20
|
+
return @topology.topology_elements if @topology.topology_elements.size != 0
|
21
|
+
|
22
|
+
@felix_servers = []
|
23
|
+
@sw_rod_servers = []
|
24
|
+
@routers = []
|
25
|
+
@links = []
|
26
|
+
|
27
|
+
|
28
|
+
# switches & routers
|
29
|
+
@routers.push @topology.add_router "lar_switch_01", [1]
|
30
|
+
@routers.push @topology.add_router "lar_switch_02", [1]
|
31
|
+
@routers.push @topology.add_router "felix_core_01", [1] # core_01 router in the felix network (connection out of USA15)
|
32
|
+
@routers.push @topology.add_router "felix_core_02", [1] # core_01 router in the felix network (connection out of USA15)
|
33
|
+
|
34
|
+
# Felix servers
|
35
|
+
for i in 0..NUMBER_OF_FELIX_SERVERS-1
|
36
|
+
@felix_servers.push @topology.add_host "lar_felix_#{i}"
|
37
|
+
|
38
|
+
# connected to both switches
|
39
|
+
@links.push @topology.add_link "link_felix#{i}_switch1", @felix_servers[i], 0, @routers[0], i+2, LINK_BW_BITS_S # lar_felix_{i} --> lar_switch_01
|
40
|
+
@links.push @topology.add_link "link_felix#{i}_switch2", @felix_servers[i], 1, @routers[1], i+2, LINK_BW_BITS_S # lar_felix_{i} --> lar_switch_02
|
41
|
+
end
|
42
|
+
|
43
|
+
# SWROD servers
|
44
|
+
for i in 0..NUMBER_OF_FELIX_SERVERS-1
|
45
|
+
@sw_rod_servers.push @topology.add_host "lar_swrod_#{i}"
|
46
|
+
|
47
|
+
# connected to both switches
|
48
|
+
@links.push @topology.add_link "link_switch1_swrod#{i}", @routers[0], i+2, @sw_rod_servers[i], 0, LINK_BW_BITS_S # lar_switch_01 --> lar_swrod_{i}
|
49
|
+
@links.push @topology.add_link "link_switch2_swrod#{i}", @routers[1], i+2, @sw_rod_servers[i], 1, LINK_BW_BITS_S # lar_switch_02 --> lar_swrod_{i}
|
50
|
+
end
|
51
|
+
|
52
|
+
# links between the switches and routers
|
53
|
+
@links.push @topology.add_full_duplex_link "core_link#{@links.size}", @routers[0], 0, @routers[2], 0, LINK_BW_BITS_S # lar_switch_1 --> core_1
|
54
|
+
@links.push @topology.add_full_duplex_link "core_link#{@links.size}", @routers[0], 1, @routers[3], 0, LINK_BW_BITS_S # lar_switch_1 --> core_2
|
55
|
+
@links.push @topology.add_full_duplex_link "core_link#{@links.size}", @routers[1], 0, @routers[2], 1, LINK_BW_BITS_S # lar_switch_2 --> core_1
|
56
|
+
@links.push @topology.add_full_duplex_link "core_link#{@links.size}", @routers[1], 1, @routers[3], 1, LINK_BW_BITS_S # lar_switch_2 --> core_2
|
57
|
+
|
58
|
+
# flow 1Felix:1ROD
|
59
|
+
add_flows_oneFelix_to_oneSWROD
|
60
|
+
|
61
|
+
@topology.topology_elements
|
62
|
+
end
|
63
|
+
|
64
|
+
def add_flows_oneFelix_to_oneSWROD
|
65
|
+
# Felix flow
|
66
|
+
@felix_servers.each_with_index do |felix,index|
|
67
|
+
paths = []
|
68
|
+
|
69
|
+
# path using switch 1
|
70
|
+
path1 = Path.new felix, @sw_rod_servers[index]
|
71
|
+
path1.add_link @topology.get_element_by_id "link_felix#{index}_switch1" # felix{i} -> switch_1
|
72
|
+
path1.add_link @topology.get_element_by_id "link_switch1_swrod#{index}" # switch_1 --> lar_swrod{i}
|
73
|
+
|
74
|
+
paths.push path1
|
75
|
+
|
76
|
+
# path using switch 2
|
77
|
+
path2 = Path.new felix, @sw_rod_servers[index]
|
78
|
+
path2.add_link @topology.get_element_by_id "link_felix#{index}_switch2" # felix{i} -> switch_2
|
79
|
+
path2.add_link @topology.get_element_by_id "link_switch2_swrod#{index}" # switch_2 --> lar_swrod{i}
|
80
|
+
|
81
|
+
paths.push path2
|
82
|
+
|
83
|
+
@topology.add_flow "Flow#{index}_1", FELIX_FLOW_PRIORITY, paths, FELIX_GENERATION_PERIOD, FELIX_GENERATION_SIZE
|
84
|
+
@topology.add_flow "Flow_Monitoring#{index}_1", FELIX_FLOW_PRIORITY, [path1], FELIX_MONITORING_GENERATION_PERIOD, FELIX_MONITORING_GENERATION_SIZE
|
85
|
+
@topology.add_flow "Flow_Control#{index}_1", FELIX_FLOW_PRIORITY, [path2], FELIX_CONTROL_GENERATION_PERIOD, FELIX_CONTROL_GENERATION_SIZE
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
def get_path_between(source, destination)
|
91
|
+
raise NotImplementedError, "NetworkTopology: This method is not implemented (¿does it ever get called?)"
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#PhaseITopology
|
2
|
+
=begin
|
3
|
+
http://asciiflow.com
|
4
|
+
|
5
|
+
+-------+
|
6
|
+
| | +--------+
|
7
|
+
|Host2 | | |
|
8
|
+
| | | |
|
9
|
+
+----+--+ |Host1 |
|
10
|
+
+-------+ | | |
|
11
|
+
| | | +--------+
|
12
|
+
| Host3 +------+---+-------+----+
|
13
|
+
| | | |
|
14
|
+
+-------+ ++ Router1 | +---------+
|
15
|
+
|| +------------+ |
|
16
|
+
+----+-------+ | |
|
17
|
+
+---------+ | |Router2 |
|
18
|
+
| | | | |
|
19
|
+
| | | +---------+
|
20
|
+
| Host4 | |
|
21
|
+
+---------+ |
|
22
|
+
+---------+
|
23
|
+
| |
|
24
|
+
|Host5 |
|
25
|
+
| |
|
26
|
+
+---------+
|
27
|
+
|
28
|
+
=end
|
29
|
+
module NetworkTopology
|
30
|
+
def get_topology
|
31
|
+
return @topology.topology_elements if @topology.topology_elements.size != 0
|
32
|
+
|
33
|
+
# Routers
|
34
|
+
router1 = @topology.add_router 'MyRouter1'
|
35
|
+
router2 = @topology.add_router 'MyRouter2'
|
36
|
+
|
37
|
+
# Hosts
|
38
|
+
link_count = 0
|
39
|
+
for i in 1..5
|
40
|
+
host = @topology.add_host "Host#{i}"
|
41
|
+
link_count += 1
|
42
|
+
@topology.add_link "Link#{link_count}", host, 0, router1, i
|
43
|
+
link_count += 1
|
44
|
+
@topology.add_link "Link#{link_count}", router1, i, host, 0
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
#Links
|
49
|
+
@topology.add_link 'Link0', router1, 0, router2, 0
|
50
|
+
|
51
|
+
@topology.topology_elements
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_path_between(source, destination)
|
55
|
+
raise Exception, "Source must be either from class Router or class Host to ask for a path" unless [Host, Router].include? source.class
|
56
|
+
raise Exception, "Destination must be either from class Router or class Host to ask for a path" unless [Host, Router].include? destination.class
|
57
|
+
|
58
|
+
first_link = @topology.topology_elements.select { |elem| (elem.is_a? Link) && (elem.src_element == source) }.first
|
59
|
+
second_link = @topology.topology_elements.select { |elem| (elem.is_a? Link) && (elem.dst_element == destination) }.first
|
60
|
+
|
61
|
+
path = Path.new(source,destination)
|
62
|
+
path.add_link first_link
|
63
|
+
path.add_link second_link
|
64
|
+
path
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,4 @@
|
|
1
|
+
sudo mn --custom /home/onos/Projects/tdaq.py --topo tdaq --controller remote,192.168.56.1 --mac --switch ovsk,protocols=OpenFlow13
|
2
|
+
|
3
|
+
#Para correrla en mi maquina
|
4
|
+
sudo mn --custom /home/alaurito/Desktop/repos/cern/topologyGenerator/lib/network_topologies_examples/phase1_topology_mininet/tdaq.py --topo tdaq --controller remote,127.0.0.1 --mac --switch ovsk,protocols=OpenFlow13
|