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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 31aed2824e654df2a0ba4b41686d7e08afd82e9c
|
4
|
+
data.tar.gz: 1d94117ecd066a17cacf7b83b8e89da848584ba7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bc9d9bf9f06357e2b4c13261ccb133eb058af3c2270578638270e85b4867df7723ecd6faafb011500f8bdd6fa3f7bdf92d3bdb193e4857b59d5c315b27366fd7
|
7
|
+
data.tar.gz: 02756b998240d4c41667f982f8f09959d58cd46ade91c2970936016c1833ea70868e9f3c7bdbe3e33fec58e85336468599df31cbf642f8ca121a2e8d24cf278f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at andy.laurito@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
## Installation
|
2
|
+
|
3
|
+
Add this line to your application's Gemfile:
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
gem 'topologygenerator'
|
7
|
+
```
|
8
|
+
|
9
|
+
And then execute:
|
10
|
+
|
11
|
+
$ bundle
|
12
|
+
|
13
|
+
Or install it yourself as:
|
14
|
+
|
15
|
+
$ gem install topologygenerator
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
For using the topologygenerator gem, you will need to write your builder, and specify the uri from where the initial topology information will be get.
|
20
|
+
|
21
|
+
## Development
|
22
|
+
|
23
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
24
|
+
|
25
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/topologygenerator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
30
|
+
|
31
|
+
|
32
|
+
## License
|
33
|
+
|
34
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
35
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "topologygenerator"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module SerializeBehavior
|
2
|
+
def transform_to_output_representation(path_to_templates_directory)
|
3
|
+
load "#{path_to_templates_directory}/#{self.class.name}_concrete_builder.rb"
|
4
|
+
self.class.send(:include, Kernel.const_get("#{self.class.name}ConcreteBuilder"))
|
5
|
+
validate_concrete_builder
|
6
|
+
build_output_representation
|
7
|
+
end
|
8
|
+
|
9
|
+
def validate_concrete_builder
|
10
|
+
[:build_output_representation].each do |method|
|
11
|
+
raise ArgumentError, "It was expected to load a #{self.class.name}ConcreteBuilder module from #{path_to_templates_directory}/builders/pdm that implements the method #{method}, but the one provided does not have this method implemented" unless self.respond_to? method
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module FlowConcreteBuilder
|
2
|
+
def build_output_representation
|
3
|
+
scilab_definition = build_scilab_definition
|
4
|
+
cplusplus_definition = build_cplusplus_definition
|
5
|
+
{'scilab'=>scilab_definition, 'cplusplus'=>cplusplus_definition}
|
6
|
+
end
|
7
|
+
|
8
|
+
def build_scilab_definition
|
9
|
+
scilab_flows_definition = ''
|
10
|
+
scilab_flows_definition += "\n"
|
11
|
+
scilab_flows_definition += build_parameter_flow_distribution 'periodDistribution', distribution_rate
|
12
|
+
scilab_flows_definition += build_parameter_flow_distribution 'packetSizeDistribution', distribution_size
|
13
|
+
scilab_flows_definition
|
14
|
+
end
|
15
|
+
|
16
|
+
def build_parameter_flow_distribution(distribution_name, distribution_variable)
|
17
|
+
scilab_flow_parameter_distribution = ''
|
18
|
+
case distribution_variable
|
19
|
+
when ConstantDistribution
|
20
|
+
scilab_flow_parameter_distribution = "flow#{@id}.#{distribution_name} = DISTRIBUTION_CONSTANT;\n"
|
21
|
+
scilab_flow_parameter_distribution += "flow#{@id}.#{distribution_name}_value = #{distribution_variable.value}; // (in bits) value for the constant distribution\n"
|
22
|
+
when ExponentialDistribution
|
23
|
+
scilab_flow_parameter_distribution = "flow#{@id}.#{distribution_name} = DISTRIBUTION_EXPONENTIAL;\n"
|
24
|
+
scilab_flow_parameter_distribution += "flow#{@id}.#{distribution_name}_mu = #{distribution_variable.mu}; // (in seconds) mean for the exponential distribution.\n"
|
25
|
+
when NormalDistribution
|
26
|
+
scilab_flow_parameter_distribution = "flow#{@id}.#{distribution_name} = DISTRIBUTION_NORMAL;\n"
|
27
|
+
scilab_flow_parameter_distribution += "flow#{@id}.#{distribution_name}_mu = #{distribution_variable.mu}; \n"
|
28
|
+
scilab_flow_parameter_distribution += "flow#{@id}.#{distribution_name}_var = #{distribution_variable.var}; \n"
|
29
|
+
when ParetoDistribution
|
30
|
+
scilab_flow_parameter_distribution = "flow#{@id}.#{distribution_name} = DISTRIBUTION_PARETO;\n"
|
31
|
+
scilab_flow_parameter_distribution += "flow#{@id}.#{distribution_name}_val1 = #{distribution_variable.val_1}; \n"
|
32
|
+
scilab_flow_parameter_distribution += "flow#{@id}.#{distribution_name}_val2 = #{distribution_variable.val_2}; \n"
|
33
|
+
scilab_flow_parameter_distribution += "flow#{@id}.#{distribution_name}_mean = #{distribution_variable.mean}; \n"
|
34
|
+
when SplitDistribution
|
35
|
+
scilab_flow_parameter_distribution = "flow#{@id}.#{distribution_name} = DISTRIBUTION_SPLIT;\n"
|
36
|
+
scilab_flow_parameter_distribution += "flow#{@id}.#{distribution_name}_shape = #{distribution_variable.shape}; \n"
|
37
|
+
scilab_flow_parameter_distribution += "flow#{@id}.#{distribution_name}_scale = #{distribution_variable.scale}; \n"
|
38
|
+
else
|
39
|
+
raise "Distribution provided has a class which was unexpected. Class was: #{distribution_variable.class}"
|
40
|
+
end
|
41
|
+
scilab_flow_parameter_distribution
|
42
|
+
end
|
43
|
+
|
44
|
+
def build_cplusplus_definition
|
45
|
+
start_time_of_flow = 0
|
46
|
+
# flow
|
47
|
+
cplusplus_flows_definition = "\n"
|
48
|
+
cplusplus_flows_definition += "\t ///// definition of flow #{@id} \n"
|
49
|
+
cplusplus_flows_definition += "\t auto flow#{@id}PeriodDistribution = readDistributionParameter(\"flow#{@id}.periodDistribution\"); \n"
|
50
|
+
cplusplus_flows_definition += "\t auto flow#{@id}PacketSizeDistribution = readDistributionParameter(\"flow#{@id}.packetSizeDistribution\"); \n"
|
51
|
+
cplusplus_flows_definition += "\t auto flow#{@id} = std::make_shared<Flow>(\"#{@id}\", #{start_time_of_flow} /*startTime*/, #{priority} /*typeOfService*/, flow#{@id}PeriodDistribution, flow#{@id}PacketSizeDistribution); \n"
|
52
|
+
|
53
|
+
#routes
|
54
|
+
cplusplus_flows_definition += "\t // routes for flow #{@id} \n"
|
55
|
+
paths.each_with_index do |path, index| # add each route/path in the flow
|
56
|
+
cplusplus_flows_definition += "\t auto flow#{@id}_route#{index} = std::make_shared<Route>( std::deque<Route::Node>{ \n"
|
57
|
+
path.links.each do |link|
|
58
|
+
cplusplus_flows_definition += "\t\t\t {#{link.src_port}, \"#{link.src_element.id}.Routing\"}, \n"
|
59
|
+
end
|
60
|
+
last_link = path.links.last
|
61
|
+
cplusplus_flows_definition += "\t\t\t {#{last_link.dst_port}, \"#{last_link.dst_element.id}.Routing\"} \n"
|
62
|
+
cplusplus_flows_definition += "\t });"
|
63
|
+
cplusplus_flows_definition += "\t \n"
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
# registrations
|
68
|
+
cplusplus_flows_definition += "\t // register flow #{@id} with its routes\n"
|
69
|
+
unique_sources = paths.map{ |path| path.links.first.src_element.id }.uniq{|id| id} # only add unique sources
|
70
|
+
unique_sources.each do |source|
|
71
|
+
cplusplus_flows_definition += "\t FlowDefinitions::registerFlowSourceNode(flow#{@id}, \"#{source}.GeneratorApplication\"); \n"
|
72
|
+
end
|
73
|
+
|
74
|
+
paths.each_with_index do |path, index| # register each route/path in the flow for each route
|
75
|
+
cplusplus_flows_definition += "\t FlowDefinitions::registerFlowRoute(flow#{@id}, flow#{@id}_route#{index}); \n"
|
76
|
+
end
|
77
|
+
|
78
|
+
cplusplus_flows_definition += "\t \n"
|
79
|
+
|
80
|
+
cplusplus_flows_definition
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module HostConcreteBuilder
|
2
|
+
def build_output_representation
|
3
|
+
" Atomic
|
4
|
+
{
|
5
|
+
Name = #{id}
|
6
|
+
Ports = #{in_elements.size} ; #{out_elements.size}
|
7
|
+
Path = PhaseI/FelixServer.h
|
8
|
+
Description = Generates jobs. Distribution for the rate and jobSize are retrieved from the Flows assigned to this server
|
9
|
+
Graphic
|
10
|
+
{
|
11
|
+
Position = #{-9975 + 750 * (my_number - 1)} ; -10285
|
12
|
+
Dimension = 700 ; 700
|
13
|
+
Direction = Down
|
14
|
+
Color = 15
|
15
|
+
Icon = %datanetworks%generator.png
|
16
|
+
}
|
17
|
+
Parameters
|
18
|
+
{
|
19
|
+
}
|
20
|
+
}
|
21
|
+
"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
module LinkConcreteBuilder
|
2
|
+
def build_output_representation
|
3
|
+
" Coupled
|
4
|
+
{
|
5
|
+
Type = Coordinator
|
6
|
+
Name = #{@id}
|
7
|
+
Ports = 1; 1
|
8
|
+
Description = Coupled DEVS model
|
9
|
+
Graphic
|
10
|
+
{
|
11
|
+
Position = #{-9975 + 750 * (@my_number - 1)}; -9870
|
12
|
+
Dimension = 645; 705
|
13
|
+
Direction = Down
|
14
|
+
Color = 15
|
15
|
+
Icon = %datanetworks%ethernet.jpg
|
16
|
+
Window = 5000; 5000; 5000; 5000
|
17
|
+
}
|
18
|
+
Parameters
|
19
|
+
{
|
20
|
+
}
|
21
|
+
System
|
22
|
+
{
|
23
|
+
Inport
|
24
|
+
{
|
25
|
+
Name = Inport0
|
26
|
+
CoupledPort = 1
|
27
|
+
Description =
|
28
|
+
Graphic
|
29
|
+
{
|
30
|
+
Position = -4740 ; -3525
|
31
|
+
Dimension = 480
|
32
|
+
Direction = Right
|
33
|
+
}
|
34
|
+
}
|
35
|
+
Outport
|
36
|
+
{
|
37
|
+
Name = Outport0
|
38
|
+
CoupledPort = 1
|
39
|
+
Description =
|
40
|
+
Graphic
|
41
|
+
{
|
42
|
+
Position = -930 ; 2850
|
43
|
+
Dimension = 360
|
44
|
+
Direction = Right
|
45
|
+
}
|
46
|
+
}
|
47
|
+
Atomic
|
48
|
+
{
|
49
|
+
Name = InNICQueue
|
50
|
+
Ports = 2 ; 2
|
51
|
+
Path = PhaseI/NetworkQueue.h
|
52
|
+
Description = In0 Incomming packets to queueIn1 Incoming signal to request dequeueOut0 Outgoing dequeued packetsOut1 Outgoing queue lenght informationQueues incoming packets and enqueues them as required by aexternal entity. FIFO Policy (FirstInFirstOut). Provides information its internal state.
|
53
|
+
Graphic
|
54
|
+
{
|
55
|
+
Position = -3855 ; -1230
|
56
|
+
Dimension = 675 ; 675
|
57
|
+
Direction = Down
|
58
|
+
Color = 15
|
59
|
+
Icon = %datanetworks%queue.png
|
60
|
+
}
|
61
|
+
Parameters
|
62
|
+
{
|
63
|
+
MaxCapacity = Str; FelixNICQueue1.maxBuffer ; Queue Capacity in Bytes. (Use -1 for INF capacity)
|
64
|
+
ForcedPeriod = Str; -1 ; Force minimum period to transition. Use -1 for INF
|
65
|
+
}
|
66
|
+
}
|
67
|
+
Atomic
|
68
|
+
{
|
69
|
+
Name = Link
|
70
|
+
Ports = 1 ; 1
|
71
|
+
Path = PhaseI/Link.h
|
72
|
+
Description = Vector to scalar signal
|
73
|
+
Graphic
|
74
|
+
{
|
75
|
+
Position = -3990 ; 585
|
76
|
+
Dimension = 630 ; 630
|
77
|
+
Direction = Down
|
78
|
+
Color = 15
|
79
|
+
Icon = %vectors%vec2scalar.svg
|
80
|
+
}
|
81
|
+
Parameters
|
82
|
+
{
|
83
|
+
link.capacity = Str; FelixLink.capacity ; Signal Index
|
84
|
+
link.delay = Str; link.delay ;
|
85
|
+
}
|
86
|
+
}
|
87
|
+
Point
|
88
|
+
{
|
89
|
+
ConectedLines = 3 ; 4 ; 5
|
90
|
+
ConectedExtrems = Org ; Org ; Org
|
91
|
+
Position = -3675 ; 1950
|
92
|
+
}
|
93
|
+
Line
|
94
|
+
{
|
95
|
+
Source = Prt ; 1 ; 1 ; 0
|
96
|
+
Sink = Cmp ; 1 ; 1 ; -1
|
97
|
+
PointX = -4125 ; -3675 ; -3675
|
98
|
+
PointY = -3525 ; -3525 ; -1365
|
99
|
+
}
|
100
|
+
Line
|
101
|
+
{
|
102
|
+
Source = Cmp ; 1 ; 1 ; 0
|
103
|
+
Sink = Cmp ; 2 ; 1 ; -1
|
104
|
+
PointX = -3675 ; -3675 ; -3675
|
105
|
+
PointY = -450 ; -450 ; 435
|
106
|
+
}
|
107
|
+
Line
|
108
|
+
{
|
109
|
+
Source = Cmp ; 2 ; 1 ; 0
|
110
|
+
Sink = Pnt ; 1 ; -1 ; 0
|
111
|
+
PointX = -3675 ; -3675 ; -3675
|
112
|
+
PointY = 1350 ; 1350 ; 1950
|
113
|
+
}
|
114
|
+
Line
|
115
|
+
{
|
116
|
+
Source = Cmp ; 1 ; 2 ; -1
|
117
|
+
Sink = Pnt ; 1 ; -1 ; 0
|
118
|
+
PointX = -3375 ; -3375 ; -2325 ; -2325 ; -3675
|
119
|
+
PointY = -1365 ; -1650 ; -1650 ; 1950 ; 1950
|
120
|
+
}
|
121
|
+
Line
|
122
|
+
{
|
123
|
+
Source = Pnt ; 1 ; -1 ; 0
|
124
|
+
Sink = Prt ; 2 ; 1 ; -1
|
125
|
+
PointX = -3675 ; -3675 ; -1065 ; -1065
|
126
|
+
PointY = 1950 ; 2775 ; 2775 ; 2850
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
"
|
131
|
+
end
|
132
|
+
|
133
|
+
def create_pdm_line_between_src_and_dst(src_element_pdm_pos, dst_element_pdm_pos, link_element_pdm_pos)
|
134
|
+
"Line
|
135
|
+
{
|
136
|
+
Source = Cmp ; #{src_element_pdm_pos} ; #{@src_port + 1} ; 0
|
137
|
+
Sink = Cmp ; #{link_element_pdm_pos} ; 1 ; -1
|
138
|
+
PointX = -9675 ; -9675 ; -9675
|
139
|
+
PointY = -10350 ; -10350 ; -9990
|
140
|
+
}
|
141
|
+
Line
|
142
|
+
{
|
143
|
+
Source = Cmp ; #{link_element_pdm_pos} ; 1 ; 0
|
144
|
+
Sink = Cmp ; #{dst_element_pdm_pos} ; #{@dst_port + 1} ; -1
|
145
|
+
PointX = -9675 ; -9675 ; -9675
|
146
|
+
PointY = -10350 ; -10350 ; -9990
|
147
|
+
}
|
148
|
+
"
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RouterConcreteBuilder
|
2
|
+
def build_output_representation
|
3
|
+
"Atomic
|
4
|
+
{
|
5
|
+
Name = #{@id}
|
6
|
+
Ports = #{in_elements.size} ; #{out_elements.size}
|
7
|
+
Path = PhaseI/Router.h
|
8
|
+
Description = In0: Incomming packetsInN: Outgoing packets from a single flowDemultiplexes a single packet flow in N input output streams.Each output stream contains packets belonging to a single flow identifier.
|
9
|
+
Graphic
|
10
|
+
{
|
11
|
+
Position = #{-9975 + 750 * (@my_number-1)} ; -8505
|
12
|
+
Dimension = 600 ; 800
|
13
|
+
Direction = Down
|
14
|
+
Color = 15
|
15
|
+
Icon = %datanetworks%router.jpg
|
16
|
+
}
|
17
|
+
Parameters
|
18
|
+
{
|
19
|
+
}
|
20
|
+
}
|
21
|
+
"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module OutputConcreteBuilder
|
2
|
+
OUTPUT_PDM_FILE_NAME = 'topology.pdm'
|
3
|
+
OUTPUT_CPP_FILE_NAME = 'FlowDefinitions.cpp'
|
4
|
+
OUTPUT_SCILAB_FILE_NAME = 'flows_definition.scilabParams'
|
5
|
+
|
6
|
+
def initialize_concrete_builder(topology_provider, directory_concrete_builders, output_directory)
|
7
|
+
@topology_provider = topology_provider
|
8
|
+
@directory_concrete_builders = directory_concrete_builders # make's sense?
|
9
|
+
@output_directory = output_directory
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_output_content
|
13
|
+
build_pdm_output
|
14
|
+
|
15
|
+
build_flow_output
|
16
|
+
end
|
17
|
+
|
18
|
+
def build_pdm_output
|
19
|
+
graph_elements = topology_provider.get_topology
|
20
|
+
|
21
|
+
graph_elements = graph_elements.select { |elem| [Host,Link,Router].include? elem.class }
|
22
|
+
|
23
|
+
pdm_topology = PDM_INITIAL_STRUCTURE
|
24
|
+
|
25
|
+
graph_elements.each do |element|
|
26
|
+
pdm_topology += element.transform_to_output_representation @directory_concrete_builders
|
27
|
+
end
|
28
|
+
|
29
|
+
pdm_topology += create_lines_between_graph_elements graph_elements
|
30
|
+
|
31
|
+
pdm_topology += PDM_FINAL_STRUCTURE
|
32
|
+
|
33
|
+
write_file "#{@output_directory}/#{OUTPUT_PDM_FILE_NAME}",
|
34
|
+
pdm_topology
|
35
|
+
end
|
36
|
+
|
37
|
+
def create_lines_between_graph_elements(graph_elements)
|
38
|
+
links = graph_elements.select { |node| node.is_a? Link }
|
39
|
+
lines = ''
|
40
|
+
links.each do |link|
|
41
|
+
src_pdm_pos = get_pdm_position link.src_element
|
42
|
+
dst_pdm_pos = get_pdm_position link.dst_element
|
43
|
+
link_pdm_pos = get_pdm_position link
|
44
|
+
lines += link.create_pdm_line_between_src_and_dst src_pdm_pos, dst_pdm_pos, link_pdm_pos
|
45
|
+
end
|
46
|
+
lines
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_pdm_position(network_elem)
|
50
|
+
#Here links have a modeled representation, so we have to count the link as well.
|
51
|
+
#We have routers, hosts and links as either atomic or compunded models
|
52
|
+
NUMBER_OF_PDM_MODELS_IN_STRUCTURE + network_elem.my_number
|
53
|
+
end
|
54
|
+
|
55
|
+
def build_flow_output
|
56
|
+
graph_elements = topology_provider.get_topology
|
57
|
+
|
58
|
+
flows = graph_elements.select { |elem| elem.is_a? Flow }
|
59
|
+
|
60
|
+
scilab_flows_definition = ''
|
61
|
+
cplusplus_flows_defined = ''
|
62
|
+
flows.each do |flow|
|
63
|
+
flow_output = flow.transform_to_output_representation @directory_concrete_builders
|
64
|
+
scilab_flows_definition += flow_output['scilab']
|
65
|
+
cplusplus_flows_defined += flow_output['cplusplus']
|
66
|
+
end
|
67
|
+
|
68
|
+
write_file "#{@output_directory}/#{OUTPUT_SCILAB_FILE_NAME}",
|
69
|
+
scilab_flows_definition
|
70
|
+
|
71
|
+
write_file "#{@output_directory}/#{OUTPUT_CPP_FILE_NAME}",
|
72
|
+
(build_cplusplus_output cplusplus_flows_defined)
|
73
|
+
end
|
74
|
+
|
75
|
+
def build_cplusplus_output(cplusplus_flows_defined)
|
76
|
+
cplusplus_flows_definition = "#include \"FlowDefinitions.h\" \n"
|
77
|
+
cplusplus_flows_definition += "\n"
|
78
|
+
cplusplus_flows_definition += "std::multimap<std::string, std::shared_ptr<Flow>> FlowDefinitions::Flows; \n"
|
79
|
+
cplusplus_flows_definition += "\n"
|
80
|
+
cplusplus_flows_definition += "void FlowDefinitions::defineFlows(){ \n"
|
81
|
+
cplusplus_flows_definition += "\n"
|
82
|
+
cplusplus_flows_definition += cplusplus_flows_defined
|
83
|
+
cplusplus_flows_definition += '}'
|
84
|
+
cplusplus_flows_definition
|
85
|
+
end
|
86
|
+
end
|