79 Commits
v2.3 ... v2.4

Author SHA1 Message Date
Jan Kundrát
d28c67143e docs: remove link to asciinema
This image needs changing, so let's prepare by not linking to asciinema
anymore.

Change-Id: I15567325139fdf02bcca2bf2b1f1460d689cbfa4
2021-09-15 16:21:10 +02:00
Jan Kundrát
6bb9ae8336 tests: Fix after merging two incompatible changes
Oops. We are not using gating, which means that changes are tested
against the "current tip of the branch" and might pass fine there, but
once they are merged, there can well be a conflict between them. This
has just happened.

The EDFA which reported a difference had its VOA set to 0.5. Previously,
this was not taken into assumption.

Fixes: ce51a4d1 Take explicitly set out_voa value into account in power calculation
Fixes: 280443f1 add an invocation test with power saturation
Change-Id: Icebbb16d2ef5886d2c9c04cc9a300a6aa08bf245
2021-09-15 15:31:20 +02:00
Jan Kundrát
0dc7d853ef Merge changes I7f6cc553,I0a6a8442,I34fe2dcf
* changes:
  requests: avoid TypeError
  add an invocation test with power saturation
  Update a roadm test to include more cases for power handling
2021-09-15 13:09:32 +00:00
Jan Kundrát
dec9388416 Merge changes from topic "openroadm-v5"
* changes:
  tests: add OpenROADMv5 example propagation
  OpenROADM: mark example config files as v4 explicitly
  Add an eqpt config file matching latest OpenROADM MSA version
  Add updated openroadm amp specifications to eqpt config
2021-09-15 13:08:40 +00:00
Jan Kundrát
017b35fa33 Merge changes I4e407484,Id35aeffe
* changes:
  examples: json-to-csv: fix invocation
  examples: fix JSON-to-CSV description
2021-09-15 13:06:27 +00:00
Jan Kundrát
cb0a410418 Merge "Take explicitly set out_voa value into account in power calculation" 2021-09-15 13:05:12 +00:00
Jan Kundrát
f250990a49 requests: avoid TypeError
When printing a Request which had its baud_rate set and bit_rate unset,
the code would hit a TypeError.

Fixes: https://review.gerrithub.io/c/Telecominfraproject/oopt-gnpy/+/521471
Change-Id: I7f6cc553c07fd8e7d1ef32866d9f711a32016744
2021-09-15 14:59:59 +02:00
EstherLerouzic
280443f17f add an invocation test with power saturation
Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: I0a6a8442326fdfb9c9922abf05aeee52cfa42090
2021-09-15 14:59:59 +02:00
EstherLerouzic
6f62251cb4 Update a roadm test to include more cases for power handling
add several power reference setting tests to the existing test

the test only checks the  power level out of roadm B.
if previous node is a preamp, power level is the one specified in
target_pch_out_db.
if previous node is a fused , power level at roadm input is below
target_pch_out_db and roadm can not increase this power (no amp).
then expected outpower is in_power, which should be equal to -22 + power_dBm
on this particular node.

nota bene
currently, no minimum losss is coded on roadm, so that the applied loss
is 0 dB, and roadm does not affect power in this case.
This behaviour is not correct and should be changed in the future.
But for now, I am only concentrating on existing behaviour tests.

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: I34fe2dcf2d355b291c27745ab511d3d77057dd94
2021-09-15 13:04:09 +02:00
Jan Kundrát
5ad54879b1 Merge "docs: cross-reference topology section with XLS/JSON" 2021-09-15 10:39:46 +00:00
Jan Kundrát
825d37c05c tests: add OpenROADMv5 example propagation
These numbers "appear to look sane" as per [1]. Let's make sure that the
config files are CI-tested.

[1] https://review.gerrithub.io/c/Telecominfraproject/oopt-gnpy/+/522340/1#message-b40ac2c839f138237139407374452f254c3b0b0d

Change-Id: Iad346a14ed12b984f90a40629c0339fa0823290e
2021-09-15 12:33:18 +02:00
Jan Kundrát
3ac9f90914 OpenROADM: mark example config files as v4 explicitly
The recent commit has added support for OpenROADM v5, the latest
published optical spec sheet. Given that the upstream project has
released v10 YANG files (but still just v3, v4 and v5 XLS sheets with
optical performance numbers), I think it would be rather misleading to
have both versioned and non-versioned config files -- especially when
the unversioned one refers to the oldest release, not the newest one.

Change-Id: I04109341724b51d276660d400c923dc28561aef2
2021-09-15 12:31:05 +02:00
Jan Kundrát
dbfbf115ff examples: json-to-csv: fix invocation
The two filenames are actually mandatory, not optional.

Reported-by: 张路 <luzhang@bupt.edu.cn>
Change-Id: I4e40748430a602a2c06eb35c96e0a8267519b8b3
2021-09-15 12:14:19 +02:00
Jan Kundrát
ad2590962b examples: fix JSON-to-CSV description
Change-Id: Id35aeffe4e71da663f3c91298cb166cee5646c98
2021-09-15 12:13:10 +02:00
Jan Kundrát
a9d530c776 Merge "Check for non-existing N or M values when comparing requests" 2021-09-14 14:39:12 +00:00
Jan Kundrát
f255c31f1f Merge "Add option to cli examples for disabling auto-insertion of EDFAs" 2021-09-14 13:15:14 +00:00
Jan Kundrát
80ec05f84c Merge "Limit target length when splitting fibers to max_length in eqpt config" 2021-09-07 09:29:15 +00:00
Jonas Mårtensson
22541d65e4 Check for non-existing N or M values when comparing requests
The compare_reqs function checks if N and M values of the requests are
None but these attributes may not exist e.g. if a service file does not
define an "effective-freq-slot" for a request.

Signed-off-by: Jonas Mårtensson <jonas.martensson@ri.se>
Change-Id: I786aad97ed658cd703694f164a87525d77b51fe1
2021-08-31 22:52:10 +02:00
Jan Kundrát
26fcf0ff6e CI: docker: releases should update the latest tag
We've been accidentally not updating the `latest` tag on Docker hub
after switching from Travis CI to GitHub actions. Traditionally, we've
assumed the `latest` points to the "latest release", so this patch makes
it simple and will call any pushed "version tag" as the `latest`. This
will become a problem if/when we start maintaining multiple releases,
but I think it's a safe approach for now.

As before, there's also the `master` tag which always points to the,
well, master branch of the repo.

Change-Id: I14c08b12010986d4327bd9d685619a98cfec370f
2021-08-31 16:16:01 +02:00
Jan Kundrát
1c32e437a2 docs: README: link to pretty installation docs
The docs used to point to in-the-tree source code of the documentation
in the RST format. When navigating from the landing page on GitHub, this
led to GitHub's rendering of the RST, which is rather incomplete. Just
point to readthedocs to get a nice doc format.

Change-Id: I985a8fd1688337b4e0e47cdb09b666cf4e96cc1b
2021-08-31 12:59:01 +02:00
EstherLerouzic
718007b3de Do not agregate requests which have non None N,M spectrum values
Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: Ib103e3292887c863e7c1cd785ffbffba629d0d02
2021-08-31 11:31:16 +02:00
EstherLerouzic
4d6c06340f Add a complementary set of tests on the N and M values
- if specified, they must be used except:
    - if N and M are not consistant (eg M smaller than the required
      spectrum for the demand)
    - if N value and M value lead to occupation outside of the band
    - if spectrum is occupied
- if any of them is None, the program uses the first fit strategy for M and
the path_bandwidth value to compute minimum required M

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: I9160ffb116dd9d7d53ad80638826b609a1367446
2021-08-31 11:31:16 +02:00
EstherLerouzic
bad893bf86 Remove this test which should never happen
this sort of verification should be covered by automatic tests
since this is a verification of the correct behaviour of the
spectrum_selection function

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: I76dd3bcad74085e1cd36ecb6503dad0271b61b80
2021-08-31 11:31:16 +02:00
EstherLerouzic
75e7fca8e4 change M value from 0 to None in case of blocking
Change tests based on M==0 value for response creation and use
instead the blocking_reason attribute existence
result element should have non null M value if request is not blocked.

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: I67e4222cf9d014201e91d3aefd3624b001264e03
2021-08-31 11:31:16 +02:00
EstherLerouzic
4e38ba98ab Change N value from 0 to None in case of NO_SPECTRUM
in case spectrum can not be assigned default value for N
was set to 0, which is not correct (N is a meaningfull value for
center frequency index). This changes replaces this default
value with None

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: Ibe642682e48d09f340d53e2092f172de6aa7cc90
2021-08-31 11:31:16 +02:00
EstherLerouzic
fdcdfca589 refactor spectrum assignment
use the new function compute_spectrum_slot_vs_bandwidth

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: If045fe53550dbde57c56fd4e8b99275c0757ea2b
2021-08-31 11:31:16 +02:00
EstherLerouzic
299ca10a47 Add a consistency check on request before any propagation is performed
In case user defines trx_mode, it is possible to check consistency of
nb of required slots and the total requested path_bandwidth and raise
a service error, before staring any propagation computation.

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: I543cab581280faef5d6072eb172da136f2542492
2021-08-31 11:31:16 +02:00
EstherLerouzic
c0b7bf714e Remove "null" entries of effective-freq-slot
before 'effective-freq-slot' was just ignored, and filled with "null" strings.
this is no longer supported

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: I24d30de91b8b29d37f6ba81220d3cad5aabb6781
2021-08-31 11:31:16 +02:00
EstherLerouzic
7f7c568160 Enabling the reading of N and M value from the json request
For this commit only the first element from the {N, M} list is read
and assigned.

This is better than not reading this value at all.

the commit also updates test_files and test data files with correct
values for the effective_freq_slot attribute

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: I1e60fe833ca1092b40de27c8cbfb13083810414e
2021-08-31 11:31:07 +02:00
EstherLerouzic
9bf6ed953a Add a new cause of blocking
if the user has specified a nb of slot and has not specified a mode
it may happen that the nb of slot is finally not large enough to support
the requested traffic: then blocking reason is 'NOT_ENOUGH_RESERVED_SPECTRUM'

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: I8d4c4df5fa97e37aefac8d9ee0d93c901505fa55
2021-08-31 11:23:08 +02:00
EstherLerouzic
e68dc39ddd Avoid overwriting blocking reason
When a path is blocked for 'NO_FEASIBLE_MODE' reason, and bidir is true,
the request attributes are filled with the last explored mode values
(baudrate notably), and the reversed path is propagated with this last
explored mode specs. if this reversed path is also not feasible the blocking
reason was overwritten with a 'MODE_NOT_FESIBLE' reasonn, because
baudrate is filled in the request attribute.

This change ensure that the blocking reason (if it exists) is not overwritten.

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: If80a37d77e2b967a327562c733a44e7f78f1c544
2021-08-31 11:23:08 +02:00
Jan Kundrát
f8007b41d1 Merge changes from topic "refactor disjunction"
* changes:
  adding another set of test for disjunction
  Minor refactor
  Refactor step4 of the compute_path_dsjctn
2021-08-31 09:19:57 +00:00
Jonas Mårtensson
228125029e Add an eqpt config file matching latest OpenROADM MSA version
This adds a separate OpenROADM eqpt config file corresponding to the
latest version of the MSA:

https://0201.nccdn.net/4_2/000/000/071/260/20210629_open-roadm_msa_specification_ver5.0.xlsx

The existing config file corresponding to the old version is kept for
backward compatibility. The new version introduces the following
changes:

* New definition of incremental OSNR for a ROADM based on polynomial
  (see also previous commit).

* ROADM add path OSNR changed from 30 dB to 33 dB

* New transceiver mode: 200 Gbit/s, 31.57 Gbaud, DP-16QAM

* Tx OSNR for transceiver mode 100 Gbit/s, 31.57 Gbaud, DP-QPSK changed
  from 35 dB to 36 dB

Signed-off-by: Jonas Mårtensson <jonas.martensson@ri.se>
Change-Id: Ieb7d33bd448ed9d0cb8320ed190019c9aa94c9ef
2021-08-16 22:10:21 +02:00
Jonas Mårtensson
d185e0c241 Add updated openroadm amp specifications to eqpt config
The latest version 5.0 of the OpenROADM MSA changes the definition
of the incremental OSNR mask of a ROADM to a polynomial:

https://0201.nccdn.net/4_2/000/000/071/260/20210629_open-roadm_msa_specification_ver5.0.xlsx

A new preamp type variety corresponding to the updated specification is
added to the default eqpt config file while also keeping the type
variety corresponding to the old specification for backward
compatibility.

The updated specification includes both typical and worst case values.
These are added as separate type varieties to let the user choose which
values to use. Note that the specification with typical values is
identical to the existing OpenROADM ILA standard type variety but a new
type variety is still added for clarity.

Signed-off-by: Jonas Mårtensson <jonas.martensson@ri.se>
Change-Id: I2de5e9db69f9ae3b218e30a3b246bd9b83cef458
2021-08-16 20:57:42 +02:00
Jonas Mårtensson
357bbec257 Limit target length when splitting fibers to max_length in eqpt config
Auto-design tries to split fibers longer than the max_length parameter
specified in the eqpt config file. When calculating new fiber lengths,
it uses a target_length parameter, which is currently hardcoded to 90
km. If the user specifies a max_length that is shorter than the
target_length and the topology includes any fiber that is longer than
the max_length but shorter than the hardcoded target_length, the
calculation crashes with a ZeroDivisionError. This patch limits the
target_length parameter so that it can't be longer than max_length.

Signed-off-by: Jonas Mårtensson <jonas.martensson@ri.se>
Change-Id: Id0851fcf79ab0b1a05832e22ee7e9cf63691446c
2021-08-10 14:10:25 +02:00
EstherLerouzic
d25e98c567 adding another set of test for disjunction
Previous set of tests did not correctly check the combinations of
disjunction and route constraint. This new set tests specific cases
with several demands in one synchronization vector with and without
route constraint, and the case where both disjunction constraint and
route can not be met (STRICT and LOOSE cases)

+ minor refactor on test_disjunction

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: Id5a5902e6945185922ce5743ac97d15dbc777af2
2021-08-02 18:02:14 +02:00
Jan Kundrát
397411690e Merge "Nicer printing of Edfa elements when parameters are None" 2021-06-29 16:06:02 +00:00
Jonas Mårtensson
4ab6f8cb1b Nicer printing of Edfa elements when parameters are None
When delta_p or target_pch_out_db is None (resulting e.g. from
operating in gain mode) the current logic replaces a whole printed
line with 'None' which does not look very nice in the script outputs.
With this patch, the parameter information is kept in the printout
like this:

  Delta_P (dB):           None
  target pch (dBm):       None

Change-Id: Ie52ce7353a708a174cf9d769918a6136eefbf444
Signed-off-by: Jonas Mårtensson <jonas.martensson@ri.se>
Fixes: 225cafa8 (Floating point formatting of elements' operational parameters)
2021-06-29 11:37:05 +00:00
Jan Kundrát
44aff147db Merge pull request #410 from jktjkt/ci-on-windows
CI: test on Windows
2021-06-29 13:33:48 +02:00
Jan Kundrát
a36b139065 CI: GitHub: push coverage reports to codecov
Since Travis CI builds stopped, nothing was pushing updates to codecov.

Change-Id: Ia9a15a1a956c41586eda9ab85bd1f22fa798e960
2021-06-17 20:32:50 +02:00
Jan Kundrát
141fc66d47 CI: GitHub: fix conditional syntax
This is strange because the docs say that it's required [1], but during
my testing it appeared to work just fine without this wrapping. Anyway,
let's follow the docs.

[1] https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#about-contexts-and-expressions

Change-Id: I6a03f9423d7f10d03687759de71f25aed15bd172
2021-06-17 19:52:43 +02:00
Jan Kundrát
53f29957fd CI: GitHub: don't fail pushing PyPI releases from forks
...and also unify the condition with what syntax that the Docker build
job is using.

Change-Id: Ia6e3fe308093bac144441f4d9a33df93ffdca06f
2021-06-17 19:05:52 +02:00
Jan Kundrát
9f3995ee20 CI: GitHub: don't try to access Docker Hub without proper credentials
Change-Id: I9dccb2d12ad97d54fa0f5bfa0d8db63cc5deb2ec
2021-06-17 18:49:07 +02:00
Jan Kundrát
0cf45bd102 CI: test on Windows
I've been getting reports that the test suite is broken on Windows (the
usual set of problems such as CRLF line endings and backslashes in path
names), so let's make sure we have a way of reproducing this.
Unfortunately, we don't have a Windows image in Zuul, so this will be a
post-merge CI I'm afraid :(.

Change-Id: Ibd539764d6e40693b95a9b231324bd0216e4a207
2021-06-17 18:18:16 +02:00
Jan Kundrát
55932ee3e9 tests: handle Unicode properly for "expected console output"
Let's use the text mode everywhere because Unicode codepoints is what
matters. The only catch on Windows turned out to be the default file IO
encoding; forcing UTF-8 there fixes all issues in the CI (and it makes
sense because that file was written out in a UTF-8 locale, and the
system which runs the test suite might be set to something else.

This was a rather interesting debugging experience; passing logs over
the web and handling "strange" characters as utf-8 did not help.

Change-Id: I1fdbe3a115458558b27a81f9eab8e58c9605bae7
Bug: https://github.com/Telecominfraproject/oopt-gnpy/issues/358
2021-06-17 18:14:36 +02:00
Jan Kundrát
797a0856ec tests: Use a portable /dev/null file name
Bug: https://github.com/Telecominfraproject/oopt-gnpy/issues/358
Change-Id: Icbca94682ce0ded860ba6397e4445651b6a61f32
2021-06-17 16:20:49 +02:00
Jan Kundrát
3fa53adc4d Don't print file name when handling requests
We have a test which compares the raw output of GNPy against a fixed
expected output. That comparison of course chokes when forward slashes
and backslashes are used, which breaks the test suite on Windows. Let's
try to solve this by always using forward slashes if possible. The way
to go is via pathlib's as_posix(), but that one can possibly return an
absolute path -- which cannot work in a test suite, obviously. So one
can workaround that via calling a Path.relative_to(), but that one
chokes on paths which require at least one "path up" component (`..`).
I posted a patch which use brute force here, but Jonas is right, better
just don't print that output in the test suite in the first place.

Change-Id: I762ddb58a2042120c7b20414152a06a3ed72048d
Bug: https://github.com/Telecominfraproject/oopt-gnpy/issues/358
2021-06-17 16:20:38 +02:00
Jan Kundrát
bcb5e6bb60 Merge changes I60b4e3bf,I2bb3b5a0,I344c4a03
* changes:
  tests: requests: rely on pytest's own dict support
  tests: enable pytest's builtin multiline diffing
  utils: document round2float
2021-06-17 14:15:32 +00:00
Jan Kundrát
6380f8f37a Merge "CI: Zuul: Introduce Python 3.9, and switch all to Fedora 34" 2021-06-11 13:44:58 +00:00
Jan Kundrát
93869d6cb5 CI: Zuul: Introduce Python 3.9, and switch all to Fedora 34
Change-Id: I40e66ca0eca21b91809ea0f94291f3bd77bc53d2
Depends-on: https://review.gerrithub.io/c/Telecominfraproject/oopt-zuul-jobs/+/518622
2021-06-11 15:35:46 +02:00
Jonas Mårtensson
ce51a4d160 Take explicitly set out_voa value into account in power calculation
As mentioned in GitHub issue #409, an out_voa value for an EDFA
explicitly set in the topology file is not taken into account by
auto-design when calculating target power and gain. I think it is
more logical if the target power resulting from the optimization
algorithm represents the desired power into the fiber. This is also
more consistent with the behaviour for an automatically set out_voa
value when out_voa_auto is set to true.

Signed-off-by: Jonas Mårtensson <jonas.martensson@ri.se>
Change-Id: I7e58b61d0bf30728c39d36404619dbe370c12f2b
2021-06-11 08:32:00 +02:00
Jan Kundrát
601e228bb6 tests: requests: rely on pytest's own dict support
When `pytest` is run with `-vv`, it shows a diff of multiline strings
and dict just fine. The only drawback is that there's the raw string
with newlines shown as "\n", however, *then* the nice diff pretty
printing kicks in, and the result is:

 E                 Common items:
 E                 {'response-id': '5'}
 E                 Differing items:
 E                 {'path-properties': {'path-metric': [{'accumulative-value': 21.68, 'metric-type': 'SNR-bandwidth'}, {'accumulative-val...EDFA', 'link-tp-id': 'east edfa in Rennes_STA to Stbrieuc', 'node-id': 'east edfa in Rennes_STA to Stbrieuc'}}}, ...]}} != {'path-properties': {'path-metric': [{'accumulative-value': 21.68, 'metric-type': 'SNR-bandwidth'}, {'accumulative-val...EDFA', 'link-tp-id': 'east edfa in Rennes_STA to Stbrieuc', 'node-id': 'east edfa in Rennes_STA to Stbrieuc'}}}, ...]}}
 E                 Full diff:
 E                   {
 E                    'path-properties': {'path-metric': [{'accumulative-value': 21.68,
 E                                                         'metric-type': 'SNR-bandwidth'},
 E                                                        {'accumulative-value': 28.77,
 E                                                         'metric-type': 'SNR-0.1nm'},
 E                                                        {'accumulative-value': 23.7,
 E                                                         'metric-type': 'OSNR-bandwidth'},
 E                                                        {'accumulative-value': 30.79,
 E                                                         'metric-type': 'OSNR-0.1nm'},
 E                                                        {'accumulative-value': 0.0019952623149688794,
 E                                                         'metric-type': 'reference_power'},
 E                                                        {'accumulative-value': 20000000000.0,
 E                                                         'metric-type': 'path_bandwidth'}],
 ...
 ... now, it's a bit annoying that there's too much output, but
 ... that's just for context; the offending lines will be properly
 ... marked, see --\
 ...               |
 ...               v
 ...
 E                                                               {'path-route-object': {'index': 17,
 E                 -                                                                    'num-unnum-hop': {'gnpy-node-type': 'transceiver',
 E                 ?                                                                                       ^ ^^^^^^^  - ^      ^^^^^^^^^ -
 E                 +                                                                    'num-unnum-hop': {'link-tp-id': 'trx '
 E                 ?                                                                                       ^^ ^   ^^^      ^^
 E                 -                                                                                      'link-tp-id': 'trx '
 E                                                                                                                      'Lannion_CAS',
 E                                                                                                        'node-id': 'trx '
 E                                                                                                                   'Lannion_CAS'}}},
 E                                                               {'path-route-object': {'index': 18,
 E                                                                                      'label-hop': {'M': 6,
 E                                                                                                    'N': -274}}},
 E                                                               {'path-route-object': {'index': 19,
 E                                                                                      'transponder': {'transponder-mode': 'mode '
 E                                                                                                                          '2',
 E                                                                                                      'transponder-type': 'vendorA_trx-type1'}}}]},
 E                    'response-id': '5',
 E                   }

 tests/test_parser.py:312: AssertionError

Change-Id: I60b4e3bfa432a720a381bf2c0a9f0288e989dab2
2021-06-09 21:17:21 +02:00
Jan Kundrát
3f58cbd559 tests: enable pytest's builtin multiline diffing
...because it works on strings while doesn't work on byte arrays.

Change-Id: I2bb3b5a0a3d6ad965321c58fb90a02341db66d0f
2021-06-09 21:17:21 +02:00
Jan Kundrát
2e3274ac78 utils: document round2float
Change-Id: I344c4a03e7d3e0614e0fc3307b12af359c61b882
2021-06-09 21:17:21 +02:00
Jan Kundrát
e33144f8cc Merge "refactoring: OpenROADM: store the NF model of a premp/booster" 2021-06-09 18:54:56 +00:00
Jan Kundrát
fd1e3f0f61 Merge "Do not load equipment['SI']['default'].power_range_db in the gain mode" 2021-06-09 18:31:48 +00:00
Jan Kundrát
80c41264cf CI: Docker: remove the dev- prefix
We have never used that one before, so let's not introduce it now.
Noise, noise, noise, sorry.

Change-Id: I336b3e73f7dd61b14615412ea52ec90986468fcf
2021-06-09 20:22:58 +02:00
Jan Kundrát
a051a5723b Merge tag 'v2.3.1'
GNPy 2.3.1

Just some release automation on top of v2.3. If you're already on v2.3,
there's no need to update; this release does not contain any
user-visible changes.

Change-Id: I0473a0bb43be596cf376cf18eb8a546b53aa0214
2021-06-09 20:14:11 +02:00
Jan Kundrát
72f300ab94 CI: Build and upload a PyPI package upon tagging
Change-Id: Idcd84a9f8e03ffc4ea27b37add8e5e59d1da7509
2021-06-09 20:03:57 +02:00
Jan Kundrát
2c3b0d8c82 CI: GitHub: build Docker images
Pushes to master should create a "development" tag. Tags should create
something prettier.

We need the git checkout for proper package versioning, hence that magic
`context` thing, and also that magic `echo`.

Change-Id: I79fcb800cc079e8486c3795f36aa1993676cee49
2021-06-09 19:53:53 +02:00
Jan Kundrát
11dab614a9 CI: GitHub: prevent duplicate runs
Change-Id: I09d55937d553d097b0440bb3c7d0f7dcc709abe3
2021-06-09 19:53:53 +02:00
Jan Kundrát
11d88bf09a CI: random bikeshedding about the name
Change-Id: I7ce2b32cb30f2b1a5e402c1dc999b02d2a1588de
2021-06-09 19:46:23 +02:00
Jan Kundrát
af3cc4736e setup metadata: fix description
Our landing page on PyPI was not displaying the longer version of the
README, just a one-sentence summary. It turns out that `pbr` can indeed
read the README file, but specifying the `description` overrides that
with no warning. Yay.

Change-Id: Ic03412928fe09f5edab4a7b9f4297a485a740cd0
2021-06-09 16:34:24 +02:00
Jan Kundrát
50cb82ee18 packaging: fix the long description
Fixes: e45a54c2 (README: rewrite in Markdown)
Change-Id: Ifefd78ba1008f0a37299dca07b53b5481ebeac27
2021-06-09 16:34:17 +02:00
Jan Kundrát
c80aca6696 CI: GitHub: ensure tags are present
We're using PBR, so let's make sure we don't get a package that's marked
as version 0.0.0.

Bug: https://github.com/actions/checkout/issues/217
Change-Id: Icd8264a798f9a1a404e21a9b64317c57662d53fe
2021-06-09 16:34:11 +02:00
Jan Kundrát
dfca35d4ae CI: always try to build a release wheel
This might be a wee bit controversial, I guess, because the Zuul jobs
look like there's a dedicated playbook for that
(playbooks/python/release.yaml). However, that would be one extra VM
launch, which feels wasteful. Let's waste the CPU cycles elsewhere --
during each "regular test build", produce a wheel as well.

It looks that these "wheels" are *the* format for distributing Python
packages now -- including the source code, of course. Since there's no
real support for tag review in Gerrit, I don't think I need Zuul for
release management, either, so I'll just rely on GitHub actions for
release upload, I guess. And for that, I need to "somehow" create a
wheel anyway, so let's just do this all the time to ensure that it
really works and never stops working.

Change-Id: Ib86852a386673cd4929a8059b19fa527cd4d5955
2021-06-09 16:34:02 +02:00
Jan Kundrát
1fbdaef58a CI: Run on GitHub Actions
We have Zuul, and we're happy with it; however, every now and then
there's a problem with the managed infrastructure, and there's also
people who contribute patches as GitHub PRs.

Change-Id: I405c5806ed9ad2e7f59f9b2394daf068b373e425
2021-06-09 16:33:50 +02:00
Jan Kundrát
bd025f3af4 setup metadata: fix description
Our landing page on PyPI was not displaying the longer version of the
README, just a one-sentence summary. It turns out that `pbr` can indeed
read the README file, but specifying the `description` overrides that
with no warning. Yay.

Change-Id: Ic03412928fe09f5edab4a7b9f4297a485a740cd0
2021-06-09 16:30:38 +02:00
Jan Kundrát
c3e546abe3 packaging: fix the long description
Fixes: e45a54c2 (README: rewrite in Markdown)
Change-Id: Ifefd78ba1008f0a37299dca07b53b5481ebeac27
2021-06-09 02:32:48 +02:00
Jan Kundrát
9427d0b139 CI: GitHub: ensure tags are present
We're using PBR, so let's make sure we don't get a package that's marked
as version 0.0.0.

Bug: https://github.com/actions/checkout/issues/217
Change-Id: Icd8264a798f9a1a404e21a9b64317c57662d53fe
2021-06-09 01:17:34 +02:00
Jan Kundrát
89f5b12f7e CI: always try to build a release wheel
This might be a wee bit controversial, I guess, because the Zuul jobs
look like there's a dedicated playbook for that
(playbooks/python/release.yaml). However, that would be one extra VM
launch, which feels wasteful. Let's waste the CPU cycles elsewhere --
during each "regular test build", produce a wheel as well.

It looks that these "wheels" are *the* format for distributing Python
packages now -- including the source code, of course. Since there's no
real support for tag review in Gerrit, I don't think I need Zuul for
release management, either, so I'll just rely on GitHub actions for
release upload, I guess. And for that, I need to "somehow" create a
wheel anyway, so let's just do this all the time to ensure that it
really works and never stops working.

Change-Id: Ib86852a386673cd4929a8059b19fa527cd4d5955
2021-06-09 00:49:52 +02:00
Jan Kundrát
9d2c10e267 CI: Run on GitHub Actions
We have Zuul, and we're happy with it; however, every now and then
there's a problem with the managed infrastructure, and there's also
people who contribute patches as GitHub PRs.

Change-Id: I405c5806ed9ad2e7f59f9b2394daf068b373e425
2021-06-08 22:34:00 +02:00
Jan Kundrát
305620e5dd Do not load equipment['SI']['default'].power_range_db in the gain mode
It is not used, so don't check it.

Change-Id: I309638ac8e647ed9f507016a116d9c8d0342c32d
2021-06-07 13:51:40 +00:00
Jan Kundrát
c91c5d622f Bump the minimal required Python to 3.8
We discussed this at one of the recent coder calls; the motivation
includes better mypy type hint support, especially in numpy, but also in
the language core, and of course the dataclasses.

Change-Id: I8ffee28c33f167cbcba978c85486e58a1b8c99be
2021-06-07 10:01:49 +00:00
Jan Kundrát
24e7f4a5a1 refactoring: OpenROADM: store the NF model of a premp/booster
All other noise models set the `nf_def` variable, so let's make the YANG
code simpler by remembering the amplifier NF model like that.

Change-Id: I341e4ac296c25bf9f27a98a7e4e92e0fd1546021
2021-06-04 23:10:30 +02:00
Jonas Mårtensson
08c922a5e5 Add option to cli examples for disabling auto-insertion of EDFAs
The auto-design feature inserts EDFAs after ROADMs and fibers when they
are not already present in the input topology file. This functionality
can be locally disabled by manually adding a Fused element in the
topology. This patch adds an option to the cli example scripts,
"--no-insert-edfas", which globally disables insertion of EDFAs as well
as automatic splitting of fibers.

Change-Id: If40aa6ac6d8b47d5e7b6f8eabfe389e8258cbce6
Signed-off-by: Jonas Mårtensson <jonas.martensson@ri.se>
2021-06-01 16:18:13 +02:00
Jan Kundrát
efd7468d42 docs: cross-reference topology section with XLS/JSON
Suggested-by: Melin, Stefan M. <Stefan.Melin@teliacompany.com>
Change-Id: I01defca88e0355af39fd6f97e5a69fc1bb5f8f73
2021-02-16 18:04:21 +01:00
EstherLerouzic
902cfa11a7 Minor refactor
Correct comments

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: I99874f08625bade15223cfbbd3cd933419fb5c66
2021-02-04 10:02:51 +01:00
EstherLerouzic
24c6acc027 Refactor step4 of the compute_path_dsjctn
Previous implementation selected last candidate in case both routing
and disjunction constraints could not be applied. The new implementation
elaborates an alternate list where each feasible paths satisfyng
disjunction constraint but not route constraint is recorded. The algorithm
then preferably selects a feasible path that satisfies all constraints and
if none is found and route constraint is LOOSE, the first set of paths
that satisfy disjunction is selected (instead of the last one).

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: Iba44397d105006a98539494d821cc83dc3e3bbd9
2021-02-04 10:02:51 +01:00
38 changed files with 7639 additions and 377 deletions

111
.github/workflows/main.yml vendored Normal file
View File

@@ -0,0 +1,111 @@
on:
push:
pull_request:
branches:
- master
name: CI
jobs:
build:
name: Tox test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: fedora-python/tox-github-action@v0.4
with:
tox_env: ${{ matrix.tox_env }}
dnf_install: ${{ matrix.dnf_install }}
- uses: codecov/codecov-action@29386c70ef20e286228c72b668a06fd0e8399192
if: ${{ endswith(matrix.tox_env, '-cover') }}
with:
files: ${{ github.workspace }}/cover/coverage.xml
strategy:
matrix:
tox_env:
- py38
- py39-cover
include:
- tox_env: docs
dnf_install: graphviz
pypi:
needs: build
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && github.repository_owner == 'Telecominfraproject' }}
name: PyPI packaging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.9'
- uses: casperdcl/deploy-pypi@bb869aafd89f657ceaafe9561d3b5584766c0f95
with:
password: ${{ secrets.PYPI_API_TOKEN }}
pip: wheel -w dist/ --no-deps .
upload: true
docker:
needs: build
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && github.repository_owner == 'Telecominfraproject' }}
name: Docker image
runs-on: ubuntu-latest
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: jktjkt
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Extract tag name
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
id: extract_pretty_git
run: echo ::set-output name=GIT_DESC::$(git describe --tags)
- name: Build and push a container
uses: docker/build-push-action@v2
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
with:
context: .
push: true
tags: |
telecominfraproject/oopt-gnpy:${{ steps.extract_pretty_git.outputs.GIT_DESC }}
telecominfraproject/oopt-gnpy:master
- name: Extract tag name
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
id: extract_tag_name
run: echo ::set-output name=GIT_DESC::${GITHUB_REF/refs\/tags\//}
- name: Build and push a container
uses: docker/build-push-action@v2
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
with:
context: .
push: true
tags: |
telecominfraproject/oopt-gnpy:${{ steps.extract_tag_name.outputs.GIT_DESC }}
telecominfraproject/oopt-gnpy:latest
windows:
name: Tests on Windows
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python_version }}
- run: |
pip install --editable .
pip install 'pytest>=5.0.0,<6'
pytest -vv
strategy:
matrix:
python_version:
- "3.9"

View File

@@ -3,8 +3,6 @@ os: linux
language: python
services: docker
python:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
before_install:

View File

@@ -2,24 +2,25 @@
- project:
check:
jobs:
- tox-py38-cover
- tox-py38-f34
- tox-py39-cover
- tox-docs-f34
- coverage-diff:
voting: false
dependencies:
- tox-py38-cover-previous
- tox-py38-cover
- tox-py39-cover-previous
- tox-py39-cover
vars:
coverage_job_name_previous: tox-py38-cover-previous
coverage_job_name_current: tox-py38-cover
coverage_job_name_previous: tox-py39-cover-previous
coverage_job_name_current: tox-py39-cover
- tox-linters-diff-n-report:
voting: false
- tox-py36-el8
- tox-docs-f32
- tox-py38-cover-previous
- tox-py39-cover-previous
gate:
jobs:
- tox-py38-f32
- tox-docs-f32
- tox-py38-f34
- tox-py39-f34
- tox-docs-f34
tag:
jobs:
- oopt-release-python:

View File

@@ -3,7 +3,7 @@
[![Install via pip](https://img.shields.io/pypi/v/gnpy)](https://pypi.org/project/gnpy/)
[![Python versions](https://img.shields.io/pypi/pyversions/gnpy)](https://pypi.org/project/gnpy/)
[![Documentation status](https://readthedocs.org/projects/gnpy/badge/?version=master)](http://gnpy.readthedocs.io/en/master/?badge=master)
[![CI](https://travis-ci.com/Telecominfraproject/oopt-gnpy.svg?branch=master)](https://travis-ci.com/Telecominfraproject/oopt-gnpy)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Telecominfraproject/oopt-gnpy/build)](https://github.com/Telecominfraproject/oopt-gnpy/actions/workflows/main.yml)
[![Gerrit](https://img.shields.io/badge/patches-via%20Gerrit-blue)](https://review.gerrithub.io/q/project:Telecominfraproject/oopt-gnpy+is:open)
[![Contributors](https://img.shields.io/github/contributors-anon/Telecominfraproject/oopt-gnpy)](https://github.com/Telecominfraproject/oopt-gnpy/graphs/contributors)
[![Code Quality via LGTM.com](https://img.shields.io/lgtm/grade/python/github/Telecominfraproject/oopt-gnpy)](https://lgtm.com/projects/g/Telecominfraproject/oopt-gnpy/)
@@ -18,12 +18,12 @@ Together, we are building this tool for rapid development of production-grade ro
## Quick Start
Install either via [Docker](docs/install.rst#install-docker), or as a [Python package](docs/install.rst#install-pip).
Install either via [Docker](https://gnpy.readthedocs.io/en/master/install.html#using-prebuilt-docker-images), or as a [Python package](https://gnpy.readthedocs.io/en/master/install.html#using-python-on-your-computer).
Read our [documentation](https://gnpy.readthedocs.io/), learn from the demos, and [get in touch with us](https://github.com/Telecominfraproject/oopt-gnpy/discussions).
This example demonstrates how GNPy can be used to check the expected SNR at the end of the line by varying the channel input power:
[![Running a simple simulation example](https://telecominfraproject.github.io/oopt-gnpy/docs/images/transmission_main_example.svg)](https://asciinema.org/a/252295)
![Running a simple simulation example](https://telecominfraproject.github.io/oopt-gnpy/docs/images/transmission_main_example.svg)
GNPy can do much more, including acting as a Path Computation Engine, tracking bandwidth requests, or advising the SDN controller about a best possible path through a large DWDM network.
Learn more about this [in the documentation](https://gnpy.readthedocs.io/).

View File

@@ -29,6 +29,7 @@ This path is directional, and all "GNPy elements" along the path match the unidi
The network topology contains not just the physical topology of the network, but also references to the :ref:`equipment library<concepts-equipment>` and a set of *operating parameters* for each entity.
These parameters include the **fiber length** of each fiber, the connector **attenutation losses**, or an amplifier's specific **gain setting**.
The topology is specified via :ref:`XLS files<excel>` or via :ref:`JSON<json>`.
.. _complete-vs-incomplete:

View File

@@ -1,3 +1,5 @@
.. _excel:
Excel (XLS, XLSX) input files
=============================

View File

@@ -38,7 +38,7 @@ Using Python on your computer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**Note**: `gnpy` supports Python 3 only. Python 2 is not supported.
`gnpy` requires Python ≥3.6
`gnpy` requires Python ≥3.8
**Note**: the `gnpy` maintainers strongly recommend the use of Anaconda for
managing dependencies.
@@ -84,7 +84,7 @@ exact version of Python you are using.
$ which python # check which Python executable is used
/path/to/anaconda/bin/python
$ python -V # check your Python version
Python 3.6.5 :: Anaconda, Inc.
Python 3.8.0 :: Anaconda, Inc.
.. _install-pip:

View File

@@ -20,7 +20,6 @@ This example demonstrates how GNPy can be used to check the expected SNR at the
:width: 100%
:align: left
:alt: Running a simple simulation example
:target: https://asciinema.org/a/252295
By default, this script operates on a single span network defined in
`gnpy/example-data/edfa_example_network.json <gnpy/example-data/edfa_example_network.json>`_
@@ -92,4 +91,4 @@ As a result transponder type is not part of the network info. it is related to t
The current version includes a spectrum assigment features that enables to compute a candidate spectrum assignment for each service based on a first fit policy. Spectrum is assigned based on service specified spacing value, path_bandwidth value and selected mode for the transceiver. This spectrum assignment includes a basic capacity planning capability so that the spectrum resource is limited by the frequency min and max values defined for the links. If the requested services reach the link spectrum capacity, additional services feasibility are computed but marked as blocked due to spectrum reason.
OpenROADM networks can be simulated via ``gnpy/example-data/eqpt_config_openroadm.json`` -- see ``gnpy/example-data/Sweden_OpenROADM_example_network.json`` as an example.
OpenROADM networks can be simulated via ``gnpy/example-data/eqpt_config_openroadm_*.json`` -- see ``gnpy/example-data/Sweden_OpenROADM*_example_network.json`` as an example.

View File

@@ -1,3 +1,5 @@
.. _json:
JSON Input Files
================

View File

@@ -614,8 +614,8 @@ class Edfa(_Node):
f' pad att_in (dB): {self.att_in:.2f}',
f' Power In (dBm): {self.pin_db:.2f}',
f' Power Out (dBm): {self.pout_db:.2f}',
f' Delta_P (dB): ' + f'{self.delta_p:.2f}' if self.delta_p is not None else 'None',
f' target pch (dBm): ' + f'{self.target_pch_out_db:.2f}' if self.target_pch_out_db is not None else 'None',
f' Delta_P (dB): ' + (f'{self.delta_p:.2f}' if self.delta_p is not None else 'None'),
f' target pch (dBm): ' + (f'{self.target_pch_out_db:.2f}' if self.target_pch_out_db is not None else 'None'),
f' effective pch (dBm): {self.effective_pch_out_db:.2f}',
f' output VOA (dB): {self.out_voa:.2f}'])

View File

@@ -269,7 +269,7 @@ def set_egress_amplifier(network, this_node, equipment, pref_ch_db, pref_total_d
node_loss = span_loss(network, prev_node)
voa = node.out_voa if node.out_voa else 0
if node.delta_p is None:
dp = target_power(network, next_node, equipment)
dp = target_power(network, next_node, equipment) + voa
else:
dp = node.delta_p
if node.effective_gain is None or power_mode:
@@ -511,12 +511,12 @@ def add_fiber_padding(network, fibers, padding):
first_fiber.params.att_in = first_fiber.params.att_in + padding - this_span_loss
def build_network(network, equipment, pref_ch_db, pref_total_db):
def build_network(network, equipment, pref_ch_db, pref_total_db, no_insert_edfas=False):
default_span_data = equipment['Span']['default']
max_length = int(convert_length(default_span_data.max_length, default_span_data.length_units))
min_length = max(int(default_span_data.padding / 0.2 * 1e3), 50_000)
bounds = range(min_length, max_length)
target_length = max(min_length, 90_000)
target_length = max(min_length, min(max_length, 90_000))
# set roadm loss for gain_mode before to build network
fibers = [f for f in network.nodes() if isinstance(f, elements.Fiber)]
@@ -524,17 +524,20 @@ def build_network(network, equipment, pref_ch_db, pref_total_db):
add_fiber_padding(network, fibers, default_span_data.padding)
# don't group split fiber and add amp in the same loop
# =>for code clarity (at the expense of speed):
for fiber in fibers:
split_fiber(network, fiber, bounds, target_length, equipment)
roadms = [r for r in network.nodes() if isinstance(r, elements.Roadm)]
for roadm in roadms:
add_roadm_preamp(network, roadm)
add_roadm_booster(network, roadm)
fibers = [f for f in network.nodes() if isinstance(f, elements.Fiber)]
for fiber in fibers:
add_inline_amplifier(network, fiber)
if not no_insert_edfas:
for fiber in fibers:
split_fiber(network, fiber, bounds, target_length, equipment)
for roadm in roadms:
add_roadm_preamp(network, roadm)
add_roadm_booster(network, roadm)
fibers = [f for f in network.nodes() if isinstance(f, elements.Fiber)]
for fiber in fibers:
add_inline_amplifier(network, fiber)
for roadm in roadms:
set_egress_amplifier(network, roadm, equipment, pref_ch_db, pref_total_db)

View File

@@ -107,6 +107,35 @@ def db2lin(value):
def round2float(number, step):
"""Round a floating point number so that its "resolution" is not bigger than 'step'
The finest step is fixed at 0.01; smaller values are silently changed to 0.01.
>>> round2float(123.456, 1000)
0.0
>>> round2float(123.456, 100)
100.0
>>> round2float(123.456, 10)
120.0
>>> round2float(123.456, 1)
123.0
>>> round2float(123.456, 0.1)
123.5
>>> round2float(123.456, 0.01)
123.46
>>> round2float(123.456, 0.001)
123.46
>>> round2float(123.249, 0.5)
123.0
>>> round2float(123.250, 0.5)
123.0
>>> round2float(123.251, 0.5)
123.5
>>> round2float(123.300, 0.2)
123.2
>>> round2float(123.301, 0.2)
123.4
"""
step = round(step, 1)
if step >= 0.01:
number = round(number / step, 0)

File diff suppressed because it is too large Load Diff

View File

@@ -55,6 +55,24 @@
"allowed_for_design": false
},
{
"type_variety": "openroadm_mw_mw_preamp_typical_ver5",
"type_def": "openroadm",
"gain_flatmax": 27,
"gain_min": 0,
"p_max": 22,
"nf_coef": [-5.952e-4,-6.250e-2,-1.071,28.99],
"allowed_for_design": false
},
{
"type_variety": "openroadm_mw_mw_preamp_worstcase_ver5",
"type_def": "openroadm",
"gain_flatmax": 27,
"gain_min": 0,
"p_max": 22,
"nf_coef": [-5.952e-4,-6.250e-2,-1.071,27.99],
"allowed_for_design": false
},
{
"type_variety": "openroadm_mw_mw_booster",
"type_def": "openroadm_booster",
"gain_flatmax": 32,

View File

@@ -0,0 +1,210 @@
{ "Edfa":[
{
"type_variety": "openroadm_ila_low_noise",
"type_def": "openroadm",
"gain_flatmax": 27,
"gain_min": 0,
"p_max": 22,
"nf_coef": [-8.104e-4,-6.221e-2,-5.889e-1,37.62],
"allowed_for_design": true
},
{
"type_variety": "openroadm_ila_standard",
"type_def": "openroadm",
"gain_flatmax": 27,
"gain_min": 0,
"p_max": 22,
"nf_coef": [-5.952e-4,-6.250e-2,-1.071,28.99],
"allowed_for_design": true
},
{
"type_variety": "openroadm_mw_mw_preamp_typical_ver5",
"type_def": "openroadm",
"gain_flatmax": 27,
"gain_min": 0,
"p_max": 22,
"nf_coef": [-5.952e-4,-6.250e-2,-1.071,28.99],
"allowed_for_design": false
},
{
"type_variety": "openroadm_mw_mw_preamp_worstcase_ver5",
"type_def": "openroadm",
"gain_flatmax": 27,
"gain_min": 0,
"p_max": 22,
"nf_coef": [-5.952e-4,-6.250e-2,-1.071,27.99],
"allowed_for_design": false
},
{
"type_variety": "openroadm_mw_mw_booster",
"type_def": "openroadm_booster",
"gain_flatmax": 32,
"gain_min": 0,
"p_max": 22,
"allowed_for_design": false
}
],
"Fiber":[
{
"type_variety": "SSMF",
"dispersion": 1.67e-05,
"gamma": 0.00127,
"pmd_coef": 1.265e-15
},
{
"type_variety": "NZDF",
"dispersion": 0.5e-05,
"gamma": 0.00146,
"pmd_coef": 1.265e-15
},
{
"type_variety": "LOF",
"dispersion": 2.2e-05,
"gamma": 0.000843,
"pmd_coef": 1.265e-15
}
],
"RamanFiber":[
{
"type_variety": "SSMF",
"dispersion": 1.67e-05,
"gamma": 0.00127,
"pmd_coef": 1.265e-15,
"raman_efficiency": {
"cr":[
0, 9.4E-06, 2.92E-05, 4.88E-05, 6.82E-05, 8.31E-05, 9.4E-05, 0.0001014, 0.0001069, 0.0001119,
0.0001217, 0.0001268, 0.0001365, 0.000149, 0.000165, 0.000181, 0.0001977, 0.0002192, 0.0002469,
0.0002749, 0.0002999, 0.0003206, 0.0003405, 0.0003592, 0.000374, 0.0003826, 0.0003841, 0.0003826,
0.0003802, 0.0003756, 0.0003549, 0.0003795, 0.000344, 0.0002933, 0.0002024, 0.0001158, 8.46E-05,
7.14E-05, 6.86E-05, 8.5E-05, 8.93E-05, 9.01E-05, 8.15E-05, 6.67E-05, 4.37E-05, 3.28E-05, 2.96E-05,
2.65E-05, 2.57E-05, 2.81E-05, 3.08E-05, 3.67E-05, 5.85E-05, 6.63E-05, 6.36E-05, 5.5E-05, 4.06E-05,
2.77E-05, 2.42E-05, 1.87E-05, 1.6E-05, 1.4E-05, 1.13E-05, 1.05E-05, 9.8E-06, 9.8E-06, 1.13E-05,
1.64E-05, 1.95E-05, 2.38E-05, 2.26E-05, 2.03E-05, 1.48E-05, 1.09E-05, 9.8E-06, 1.05E-05, 1.17E-05,
1.25E-05, 1.21E-05, 1.09E-05, 9.8E-06, 8.2E-06, 6.6E-06, 4.7E-06, 2.7E-06, 1.9E-06, 1.2E-06, 4E-07,
2E-07, 1E-07
],
"frequency_offset":[
0, 0.5e12, 1e12, 1.5e12, 2e12, 2.5e12, 3e12, 3.5e12, 4e12, 4.5e12, 5e12, 5.5e12, 6e12, 6.5e12, 7e12,
7.5e12, 8e12, 8.5e12, 9e12, 9.5e12, 10e12, 10.5e12, 11e12, 11.5e12, 12e12, 12.5e12, 12.75e12,
13e12, 13.25e12, 13.5e12, 14e12, 14.5e12, 14.75e12, 15e12, 15.5e12, 16e12, 16.5e12, 17e12,
17.5e12, 18e12, 18.25e12, 18.5e12, 18.75e12, 19e12, 19.5e12, 20e12, 20.5e12, 21e12, 21.5e12,
22e12, 22.5e12, 23e12, 23.5e12, 24e12, 24.5e12, 25e12, 25.5e12, 26e12, 26.5e12, 27e12, 27.5e12, 28e12,
28.5e12, 29e12, 29.5e12, 30e12, 30.5e12, 31e12, 31.5e12, 32e12, 32.5e12, 33e12, 33.5e12, 34e12, 34.5e12,
35e12, 35.5e12, 36e12, 36.5e12, 37e12, 37.5e12, 38e12, 38.5e12, 39e12, 39.5e12, 40e12, 40.5e12, 41e12,
41.5e12, 42e12
]
}
}
],
"Span":[
{
"power_mode":true,
"delta_power_range_db": [0,0,0],
"max_fiber_lineic_loss_for_raman": 0.25,
"target_extended_gain": 0,
"max_length": 135,
"length_units": "km",
"max_loss": 28,
"padding": 11,
"EOL": 0,
"con_in": 0,
"con_out": 0
}
],
"Roadm":[
{
"target_pch_out_db": -20,
"add_drop_osnr": 33,
"pmd": 0,
"restrictions": {
"preamp_variety_list":["openroadm_mw_mw_preamp_worstcase_ver5"],
"booster_variety_list":["openroadm_mw_mw_booster"]
}
}
],
"SI":[
{
"f_min": 191.3e12,
"baud_rate": 31.57e9,
"f_max":196.1e12,
"spacing": 50e9,
"power_dbm": 2,
"power_range_db": [0,0,1],
"roll_off": 0.15,
"tx_osnr": 35,
"sys_margins": 2
}
],
"Transceiver":[
{
"type_variety": "OpenROADM MSA ver. 5.0",
"frequency":{
"min": 191.35e12,
"max": 196.1e12
},
"mode":[
{
"format": "100 Gbit/s, 27.95 Gbaud, DP-QPSK",
"baud_rate": 27.95e9,
"OSNR": 17,
"bit_rate": 100e9,
"roll_off": null,
"tx_osnr": 33,
"min_spacing": 50e9,
"cost":1
},
{
"format": "100 Gbit/s, 31.57 Gbaud, DP-QPSK",
"baud_rate": 31.57e9,
"OSNR": 12,
"bit_rate": 100e9,
"roll_off": 0.15,
"tx_osnr": 36,
"min_spacing": 50e9,
"cost":1
},
{
"format": "200 Gbit/s, 31.57 Gbaud, DP-16QAM",
"baud_rate": 31.57e9,
"OSNR": 20.5,
"bit_rate": 100e9,
"roll_off": 0.15,
"tx_osnr": 36,
"min_spacing": 50e9,
"cost":1
},
{
"format": "200 Gbit/s, DP-QPSK",
"baud_rate": 63.1e9,
"OSNR": 17,
"bit_rate": 200e9,
"roll_off": 0.15,
"tx_osnr": 36,
"min_spacing": 87.5e9,
"cost":1
},
{
"format": "300 Gbit/s, DP-8QAM",
"baud_rate": 63.1e9,
"OSNR": 21,
"bit_rate": 300e9,
"roll_off": 0.15,
"tx_osnr": 36,
"min_spacing": 87.5e9,
"cost":1
},
{
"format": "400 Gbit/s, DP-16QAM",
"baud_rate": 63.1e9,
"OSNR": 24,
"bit_rate": 400e9,
"roll_off": 0.15,
"tx_osnr": 36,
"min_spacing": 87.5e9,
"cost":1
}
]
}
]
}

View File

@@ -14,8 +14,8 @@
"trx_mode": null,
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 50000000000.0,
@@ -39,8 +39,8 @@
"trx_mode": "mode 1",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 50000000000.0,
@@ -104,8 +104,8 @@
"trx_mode": "mode 1",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 50000000000.0,
@@ -129,8 +129,8 @@
"trx_mode": null,
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 75000000000.0,
@@ -154,8 +154,8 @@
"trx_mode": "mode 2",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 75000000000.0,
@@ -179,8 +179,8 @@
"trx_mode": "mode 1",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 50000000000.0,
@@ -204,8 +204,8 @@
"trx_mode": "mode 1",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 50000000000.0,
@@ -229,8 +229,8 @@
"trx_mode": "mode 1",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 75000000000.0,

View File

@@ -18,9 +18,9 @@ from gnpy.tools.json_io import load_equipment
from gnpy.topology.request import jsontocsv
parser = ArgumentParser(description='A function that writes json path results in an excel sheet.')
parser.add_argument('filename', nargs='?', type=Path)
parser.add_argument('output_filename', nargs='?', type=Path)
parser = ArgumentParser(description='Converting JSON path results into a CSV')
parser.add_argument('filename', type=Path)
parser.add_argument('output_filename', type=Path)
parser.add_argument('eqpt_filename', nargs='?', type=Path, default=Path(__file__).parent / 'eqpt_config.json')
if __name__ == '__main__':

View File

@@ -103,6 +103,9 @@ def _add_common_options(parser: argparse.ArgumentParser, network_default: Path):
help='Save the final network as a JSON file')
parser.add_argument('--save-network-before-autodesign', type=Path, metavar=_help_fname_json,
help='Dump the network into a JSON file prior to autodesign')
parser.add_argument('--no-insert-edfas', action='store_true',
help='Disable insertion of EDFAs after ROADMs and fibers '
'as well as splitting of fibers by auto-design.')
def transmission_main_example(args=None):
@@ -187,6 +190,7 @@ def transmission_main_example(args=None):
params['loose_list'] = ['strict']
params['format'] = ''
params['path_bandwidth'] = 0
params['effective_freq_slot'] = None
trx_params = trx_mode_params(equipment)
if args.power:
trx_params['power'] = db2lin(float(args.power)) * 1e-3
@@ -200,7 +204,7 @@ def transmission_main_example(args=None):
pref_ch_db = lin2db(req.power * 1e3) # reference channel power / span (SL=20dB)
pref_total_db = pref_ch_db + lin2db(req.nb_channel) # reference total power / span (SL=20dB)
try:
build_network(network, equipment, pref_ch_db, pref_total_db)
build_network(network, equipment, pref_ch_db, pref_total_db, args.no_insert_edfas)
except exceptions.NetworkTopologyError as e:
print(f'{ansi_escapes.red}Invalid network definition:{ansi_escapes.reset} {e}')
sys.exit(1)
@@ -214,17 +218,16 @@ def transmission_main_example(args=None):
f'and {destination.uid}')
print(f'\nNow propagating between {source.uid} and {destination.uid}:')
try:
p_start, p_stop, p_step = equipment['SI']['default'].power_range_db
p_num = abs(int(round((p_stop - p_start) / p_step))) + 1 if p_step != 0 else 1
power_range = list(linspace(p_start, p_stop, p_num))
except TypeError:
print('invalid power range definition in eqpt_config, should be power_range_db: [lower, upper, step]')
power_range = [0]
if not power_mode:
power_range = [0]
if power_mode:
# power cannot be changed in gain mode
power_range = [0]
try:
p_start, p_stop, p_step = equipment['SI']['default'].power_range_db
p_num = abs(int(round((p_stop - p_start) / p_step))) + 1 if p_step != 0 else 1
power_range = list(linspace(p_start, p_stop, p_num))
except TypeError:
print('invalid power range definition in eqpt_config, should be power_range_db: [lower, upper, step]')
for dp_db in power_range:
req.power = db2lin(pref_ch_db + dp_db) * 1e-3
if power_mode:
@@ -307,7 +310,6 @@ def path_requests_run(args=None):
_setup_logging(args)
_logger.info(f'Computing path requests {args.service_filename} into JSON format')
print(f'{ansi_escapes.blue}Computing path requests {os.path.relpath(args.service_filename)} into JSON format{ansi_escapes.reset}')
(equipment, network) = load_common_data(args.equipment, args.topology, args.sim_params, args.save_network_before_autodesign)
@@ -319,7 +321,7 @@ def path_requests_run(args=None):
p_total_db = p_db + lin2db(automatic_nch(equipment['SI']['default'].f_min,
equipment['SI']['default'].f_max, equipment['SI']['default'].spacing))
try:
build_network(network, equipment, p_db, p_total_db)
build_network(network, equipment, p_db, p_total_db, args.no_insert_edfas)
except exceptions.NetworkTopologyError as e:
print(f'{ansi_escapes.red}Invalid network definition:{ansi_escapes.reset} {e}')
sys.exit(1)

View File

@@ -18,7 +18,7 @@ from gnpy.core.equipment import trx_mode_params
from gnpy.core.exceptions import ConfigurationError, EquipmentConfigError, NetworkTopologyError, ServiceError
from gnpy.core.science_utils import estimate_nf_model
from gnpy.core.utils import automatic_nch, automatic_fmax, merge_amplifier_restrictions
from gnpy.topology.request import PathRequest, Disjunction
from gnpy.topology.request import PathRequest, Disjunction, compute_spectrum_slot_vs_bandwidth
from gnpy.tools.convert import xls_to_json_data
from gnpy.tools.service_sheet import read_service_sheet
@@ -33,6 +33,14 @@ Model_hybrid = namedtuple('Model_hybrid', 'nf_ram gain_ram edfa_variety')
Model_dual_stage = namedtuple('Model_dual_stage', 'preamp_variety booster_variety')
class Model_openroadm_preamp:
pass
class Model_openroadm_booster:
pass
class _JsonThing:
def update_attr(self, default_values, kwargs, name):
clean_kwargs = {k: v for k, v in kwargs.items() if v != ''}
@@ -201,8 +209,10 @@ class Amp(_JsonThing):
except KeyError: # nf_coef is expected for openroadm amp
raise EquipmentConfigError(f'missing nf_coef input for amplifier: {type_variety} in equipment config')
nf_def = Model_openroadm_ila(nf_coef)
elif type_def in ('openroadm_preamp', 'openroadm_booster'):
pass # no extra parameters needed
elif type_def == 'openroadm_preamp':
nf_def = Model_openroadm_preamp()
elif type_def == 'openroadm_booster':
nf_def = Model_openroadm_booster()
elif type_def == 'dual_stage':
try: # nf_ram and gain_ram are expected for a hybrid amp
preamp_variety = kwargs.pop('preamp_variety')
@@ -475,12 +485,12 @@ def requests_from_json(json_data, equipment):
params['nb_channel'] = automatic_nch(f_min, f_max_from_si, params['spacing'])
except KeyError:
params['nb_channel'] = automatic_nch(f_min, f_max_from_si, params['spacing'])
_check_one_request(params, f_max_from_si)
params['effective_freq_slot'] = req['path-constraints']['te-bandwidth'].get('effective-freq-slot', [None])[0]
try:
params['path_bandwidth'] = req['path-constraints']['te-bandwidth']['path_bandwidth']
except KeyError:
pass
_check_one_request(params, f_max_from_si)
requests_list.append(PathRequest(**params))
return requests_list
@@ -506,6 +516,22 @@ def _check_one_request(params, f_max_from_si):
max recommanded nb of channels is {max_recommanded_nb_channels}.'''
_logger.critical(msg)
raise ServiceError(msg)
# Transponder mode already selected; will it fit to the requested bandwidth?
if params['trx_mode'] is not None and params['effective_freq_slot'] is not None \
and params['effective_freq_slot']['M'] is not None:
_, requested_m = compute_spectrum_slot_vs_bandwidth(params['path_bandwidth'],
params['spacing'],
params['bit_rate'])
# params['effective_freq_slot']['M'] value should be bigger than the computed requested_m (simple estimate)
# TODO: elaborate a more accurate estimate with nb_wl * tx_osnr + possibly guardbands in case of
# superchannel closed packing.
if requested_m > params['effective_freq_slot']['M']:
msg = f'requested M {params["effective_freq_slot"]["M"]} number of slots for request' +\
f'{params["request_id"]} should be greater than {requested_m} to support request' +\
f'{params["path_bandwidth"] * 1e-9} Gbit/s with {params["trx_type"]} {params["trx_mode"]}'
_logger.critical(msg)
raise ServiceError(msg)
def disjunctions_from_json(json_data):

View File

@@ -127,7 +127,7 @@ class Request_element(Element):
'technology': 'flexi-grid',
'trx_type': self.trx_type,
'trx_mode': self.mode,
'effective-freq-slot': [{'N': 'null', 'M': 'null'}],
'effective-freq-slot': [{'N': None, 'M': None}],
'spacing': self.spacing,
'max-nb-of-channel': self.nb_channel,
'output-power': self.power

View File

@@ -35,7 +35,7 @@ LOGGER = getLogger(__name__)
RequestParams = namedtuple('RequestParams', 'request_id source destination bidir trx_type' +
' trx_mode nodes_list loose_list spacing power nb_channel f_min' +
' f_max format baud_rate OSNR bit_rate roll_off tx_osnr' +
' min_spacing cost path_bandwidth')
' min_spacing cost path_bandwidth effective_freq_slot')
DisjunctionParams = namedtuple('DisjunctionParams', 'disjunction_id relaxable link' +
'_diverse node_diverse disjunctions_req')
@@ -68,6 +68,9 @@ class PathRequest:
self.min_spacing = params.min_spacing
self.cost = params.cost
self.path_bandwidth = params.path_bandwidth
if params.effective_freq_slot is not None:
self.N = params.effective_freq_slot['N']
self.M = params.effective_freq_slot['M']
def __str__(self):
return '\n\t'.join([f'{type(self).__name__} {self.request_id}',
@@ -75,7 +78,7 @@ class PathRequest:
f'destination: {self.destination}'])
def __repr__(self):
if self.baud_rate is not None:
if self.baud_rate is not None and self.bit_rate is not None:
temp = self.baud_rate * 1e-9
temp2 = self.bit_rate * 1e-9
else:
@@ -129,7 +132,7 @@ BLOCKING_NOPATH = ['NO_PATH', 'NO_PATH_WITH_CONSTRAINT',
'NO_FEASIBLE_BAUDRATE_WITH_SPACING',
'NO_COMPUTED_SNR']
BLOCKING_NOMODE = ['NO_FEASIBLE_MODE', 'MODE_NOT_FEASIBLE']
BLOCKING_NOSPECTRUM = 'NO_SPECTRUM'
BLOCKING_NOSPECTRUM = ['NO_SPECTRUM', 'NOT_ENOUGH_RESERVED_SPECTRUM']
class ResultElement:
@@ -162,7 +165,11 @@ class ResultElement:
}
pro_list.append(temp)
index += 1
if self.path_request.M > 0:
if not hasattr(self.path_request, 'blocking_reason'):
# M and N values should not be None at this point
if self.path_request.M is None or self.path_request.N is None:
raise ServiceError('request {self.path_id} should have positive non null n and m values.')
temp = {
'path-route-object': {
'index': index,
@@ -174,12 +181,14 @@ class ResultElement:
}
pro_list.append(temp)
index += 1
elif self.path_request.M == 0 and hasattr(self.path_request, 'blocking_reason'):
# if the path is blocked due to spectrum, no label object is created, but
# the json response includes a detailed path for user infromation.
pass
else:
raise ServiceError('request {self.path_id} should have positive path bandwidth value.')
# if the path is blocked, no label object is created, but
# the json response includes a detailed path for user information.
# M and N values should be None at this point
if self.path_request.M is not None or self.path_request.N is not None:
raise ServiceError('request {self.path_id} should not have label M and N values at this point.')
if isinstance(element, Transceiver):
temp = {
'path-route-object': {
@@ -389,7 +398,6 @@ def propagate_and_optimize_mode(path, req, equipment):
else:
req.blocking_reason = 'NO_COMPUTED_SNR'
return path, None
# only get to this point if no baudrate/mode satisfies OSNR requirement
# returns the last propagated path and mode
@@ -696,8 +704,8 @@ def compute_path_dsjctn(network, equipment, pathreqlist, disjunctions_list):
# in each loop, dpath is updated with a path for rq that satisfies
# disjunction with each path in dpath
# for example, assume set of requests in the vector (disjunction_list) is {rq1,rq2, rq3}
# rq1 p1: abfhg
# p2: aefhg
# rq1 p1: aefhg
# p2: abfhg
# p3: abcg
# rq2 p8: bf
# rq3 p4: abcgh
@@ -714,6 +722,7 @@ def compute_path_dsjctn(network, equipment, pathreqlist, disjunctions_list):
# after second loop:
# dpath = [ p3 p8 p6 ]
# since p1 and p4 are not disjoint
# p1 and p6 are not disjoint
# p1 and p7 are not disjoint
# p3 and p4 are not disjoint
# p3 and p7 are not disjoint
@@ -737,7 +746,6 @@ def compute_path_dsjctn(network, equipment, pathreqlist, disjunctions_list):
temp.append(temp2)
# print(f' coucou {elem1}: \t{temp}')
dpath = temp
# print(dpath)
candidates[dis.disjunction_id] = dpath
# for i in disjunctions_list:
@@ -778,9 +786,9 @@ def compute_path_dsjctn(network, equipment, pathreqlist, disjunctions_list):
if pth in cndt:
candidates[this_id].remove(cndt)
# for i in disjunctions_list:
# print(i.disjunction_id)
# print(f'\n{candidates[i.disjunction_id]}')
# for i in disjunctions_list:
# print(i.disjunction_id)
# print(f'\n{candidates[i.disjunction_id]}')
# step 4 apply route constraints: remove candidate path that do not satisfy
# the constraint only in the case of disjounction: the simple path is processed in
@@ -788,33 +796,34 @@ def compute_path_dsjctn(network, equipment, pathreqlist, disjunctions_list):
# TODO: keep a version without the loose constraint
for this_d in disjunctions_list:
temp = []
alternatetemp = []
for j, sol in enumerate(candidates[this_d.disjunction_id]):
testispartok = True
testispartnokloose = True
for pth in sol:
# print(f'test {allpaths[id(pth)].req.request_id}')
# print(f'length of route {len(allpaths[id(pth)].req.nodes_list)}')
if allpaths[id(pth)].req.nodes_list:
# if pth does not containt the ordered list node, remove sol from the candidate
# except if this was the last solution: then check if the constraint is loose
# or not
# if any pth from sol does not contain the ordered list node,
# remove sol from the candidate, except if constraint was loose:
# then keep sol as an alternate solution
if not ispart(allpaths[id(pth)].req.nodes_list, pth):
# print(f'nb of solutions {len(temp)}')
if j < len(candidates[this_d.disjunction_id]) - 1:
msg = f'removing {sol}'
LOGGER.info(msg)
testispartok = False
# break
else:
if 'LOOSE' in allpaths[id(pth)].req.loose_list:
LOGGER.info(f'Could not apply route constraint' +
f'{allpaths[id(pth)].req.nodes_list} on request' +
f' {allpaths[id(pth)].req.request_id}')
else:
LOGGER.info(f'removing last solution from candidate paths\n{sol}')
testispartok = False
testispartok = False
if 'STRICT' in allpaths[id(pth)].req.loose_list:
LOGGER.info(f'removing solution from candidate paths\n{pth}')
testispartnokloose = False
break
if testispartok:
temp.append(sol)
candidates[this_d.disjunction_id] = temp
elif testispartnokloose:
LOGGER.info(f'Adding solution as alternate solution not satisfying constraint\n{pth}')
alternatetemp.append(sol)
if temp:
candidates[this_d.disjunction_id] = temp
elif alternatetemp:
candidates[this_d.disjunction_id] = alternatetemp
else:
candidates[this_d.disjunction_id] = []
# step 5 select the first combination that works
pathreslist_disjoint = {}
@@ -964,7 +973,9 @@ def compare_reqs(req1, req2, disjlist):
req1.format == req2.format and \
req1.OSNR == req2.OSNR and \
req1.roll_off == req2.roll_off and \
same_disj:
same_disj and \
getattr(req1, 'N', None) is None and getattr(req2, 'N', None) is None and \
getattr(req1, 'M', None) is None and getattr(req2, 'M', None) is None:
return True
else:
return False
@@ -1152,7 +1163,8 @@ def compute_path_with_disjunction(network, equipment, pathreqlist, pathlist):
print(msg)
LOGGER.warning(msg)
# TODO selection of mode should also be on reversed direction !!
pathreq.blocking_reason = 'MODE_NOT_FEASIBLE'
if not hasattr(pathreq, 'blocking_reason'):
pathreq.blocking_reason = 'MODE_NOT_FEASIBLE'
else:
propagated_reversed_path = []
else:
@@ -1168,3 +1180,15 @@ def compute_path_with_disjunction(network, equipment, pathreqlist, pathlist):
# print to have a nice output
print('')
return path_res_list, reversed_path_res_list, propagated_reversed_path_res_list
def compute_spectrum_slot_vs_bandwidth(bandwidth, spacing, bit_rate, slot_width=0.0125e12):
""" Compute the number of required wavelengths and the M value (number of consumed slots)
Each wavelength consumes one `spacing`, and the result is rounded up to consume a natural number of slots.
>>> compute_spectrum_slot_vs_bandwidth(400e9, 50e9, 200e9)
(2, 8)
"""
number_of_wavelengths = ceil(bandwidth / bit_rate)
total_number_of_slots = ceil(spacing / slot_width) * number_of_wavelengths
return number_of_wavelengths, total_number_of_slots

View File

@@ -18,6 +18,7 @@ from logging import getLogger
from math import ceil
from gnpy.core.elements import Roadm, Transceiver
from gnpy.core.exceptions import ServiceError, SpectrumError
from gnpy.topology.request import compute_spectrum_slot_vs_bandwidth
LOGGER = getLogger(__name__)
@@ -390,42 +391,40 @@ def pth_assign_spectrum(pths, rqs, oms_list, rpths):
""" basic first fit assignment
if reversed path are provided, means that occupation is bidir
"""
for i, pth in enumerate(pths):
for pth, rq, rpth in zip(pths, rqs, rpths):
# computes the number of channels required
try:
if rqs[i].blocking_reason:
rqs[i].blocked = True
rqs[i].N = 0
rqs[i].M = 0
except AttributeError:
nb_wl = ceil(rqs[i].path_bandwidth / rqs[i].bit_rate)
# computes the total nb of slots according to requested spacing
# TODO : express superchannels
# assumes that all channels must be grouped
# TODO : enables non contiguous reservation in case of blocking
requested_m = ceil(rqs[i].spacing / 0.0125e12) * nb_wl
# concatenate all path and reversed path elements to derive slots availability
(center_n, startn, stopn), path_oms = spectrum_selection(pth + rpths[i], oms_list, requested_m,
requested_n=None)
# checks that requested_m is fitting startm and stopm
if hasattr(rq, 'blocking_reason'):
rq.N = None
rq.M = None
else:
nb_wl, requested_m = compute_spectrum_slot_vs_bandwidth(rq.path_bandwidth,
rq.spacing, rq.bit_rate)
if getattr(rq, 'M', None) is not None:
# Consistency check between the requested M and path_bandwidth
# M value should be bigger than the computed requested_m (simple estimate)
# TODO: elaborate a more accurate estimate with nb_wl * tx_osnr + possibly guardbands in case of
# superchannel closed packing.
if requested_m > rq.M:
rq.N = None
rq.M = None
rq.blocking_reason = 'NOT_ENOUGH_RESERVED_SPECTRUM'
# need to stop here for this request and not go though spectrum selection process with requested_m
continue
# use the req.M even if requested_m is smaller
requested_m = rq.M
requested_n = getattr(rq, 'N', None)
(center_n, startn, stopn), path_oms = spectrum_selection(pth + rpth, oms_list, requested_m,
requested_n)
# if requested n and m concern already occupied spectrum the previous function returns a None candidate
# if not None, center_n and start, stop frequencies are applicable to all oms of pth
# checks that spectrum is not None else indicate blocking reason
if center_n is not None:
# checks that requested_m is fitting startm and stopm
if 2 * requested_m > (stopn - startn + 1):
msg = f'candidate: {(center_n, startn, stopn)} is not consistant ' +\
f'with {requested_m}'
LOGGER.critical(msg)
raise ValueError(msg)
for oms_elem in path_oms:
oms_list[oms_elem].assign_spectrum(center_n, requested_m)
oms_list[oms_elem].add_service(rqs[i].request_id, nb_wl)
rqs[i].blocked = False
rqs[i].N = center_n
rqs[i].M = requested_m
oms_list[oms_elem].add_service(rq.request_id, nb_wl)
rq.N = center_n
rq.M = requested_m
else:
rqs[i].blocked = True
rqs[i].N = 0
rqs[i].M = 0
rqs[i].blocking_reason = 'NO_SPECTRUM'
rq.N = None
rq.M = None
rq.blocking_reason = 'NO_SPECTRUM'

View File

@@ -1,8 +1,7 @@
[metadata]
name = gnpy
description = Route planning and optimization tool for mesh optical networks
description-file = README.rst
description-content-type = text/x-rst; charset=UTF-8
description-file = README.md
description-content-type = text/markdown; variant=GFM
author = Telecom Infra Project
author-email = jan.kundrat@telecominfraproject.com
license = BSD-3-Clause
@@ -10,7 +9,7 @@ home-page = https://github.com/Telecominfraproject/oopt-gnpy
project_urls =
Bug Tracker = https://github.com/Telecominfraproject/oopt-gnpy/issues
Documentation = https://gnpy.readthedocs.io/
python-requires = >=3.6
python-requires = >=3.8
classifier =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
@@ -20,8 +19,6 @@ classifier =
Natural Language :: English
Programming Language :: Python
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: Implementation :: CPython

View File

@@ -14,8 +14,8 @@
"trx_mode": "mode 1",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 50000000000.0,
@@ -39,8 +39,8 @@
"trx_mode": "mode 1",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 50000000000.0,
@@ -64,8 +64,8 @@
"trx_mode": "mode 1",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 50000000000.0,

View File

@@ -14,8 +14,8 @@
"trx_mode": "mode 1",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 50000000000.0,
@@ -39,8 +39,8 @@
"trx_mode": "mode 1",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 50000000000.0,
@@ -104,8 +104,8 @@
"trx_mode": "mode 1",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 50000000000.0,
@@ -129,8 +129,8 @@
"trx_mode": "mode 2",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 75000000000.0,
@@ -154,8 +154,8 @@
"trx_mode": "mode 2",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 75000000000.0,
@@ -179,8 +179,8 @@
"trx_mode": "mode 2",
"effective-freq-slot": [
{
"N": "null",
"M": "null"
"N": null,
"M": null
}
],
"spacing": 75000000000.0,

View File

@@ -12,12 +12,6 @@
"technology": "flexi-grid",
"trx_type": "Voyager_16QAM",
"trx_mode": "16QAM",
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 50000000000.0,
"max-nb-of-channel": 80,
"output-power": 0.001,
@@ -37,12 +31,6 @@
"technology": "flexi-grid",
"trx_type": "vendorA_trx-type1",
"trx_mode": "PS_SP64_1",
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 50000000000.0,
"max-nb-of-channel": 80,
"output-power": 0.001,
@@ -62,12 +50,6 @@
"technology": "flexi-grid",
"trx_type": "vendorA_trx-type1",
"trx_mode": "PS_SP64_1",
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 50000000000.0,
"max-nb-of-channel": 80,
"output-power": 0.001,
@@ -87,12 +69,6 @@
"technology": "flexi-grid",
"trx_type": "vendorA_trx-type1",
"trx_mode": "PS_SP64_1",
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 50000000000.0,
"max-nb-of-channel": 80,
"output-power": 0.001,
@@ -133,12 +109,6 @@
"technology": "flexi-grid",
"trx_type": "Voyager",
"trx_mode": "mode 2 - fake",
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 75000000000.0,
"max-nb-of-channel": 63,
"output-power": 0.001,
@@ -158,12 +128,6 @@
"technology": "flexi-grid",
"trx_type": "Voyager",
"trx_mode": "mode 2",
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 75000000000.0,
"max-nb-of-channel": 63,
"output-power": 0.001,
@@ -183,12 +147,6 @@
"technology": "flexi-grid",
"trx_type": "vendorA_trx-type1",
"trx_mode": "PS_SP64_1",
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 50000000000.0,
"max-nb-of-channel": 80,
"output-power": 0.001,
@@ -221,12 +179,6 @@
"technology": "flexi-grid",
"trx_type": "Voyager",
"trx_mode": "mode 3",
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 62500000000.0,
"max-nb-of-channel": 76,
"output-power": 0.001,
@@ -259,12 +211,6 @@
"technology": "flexi-grid",
"trx_type": "vendorA_trx-type1",
"trx_mode": "PS_SP64_1",
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 50000000000.0,
"max-nb-of-channel": 80,
"output-power": 0.001,
@@ -284,12 +230,6 @@
"technology": "flexi-grid",
"trx_type": "vendorA_trx-type1",
"trx_mode": "PS_SP64_1",
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 50000000000.0,
"max-nb-of-channel": 80,
"output-power": 0.001,
@@ -330,12 +270,6 @@
"technology": "flexi-grid",
"trx_type": "Voyager_16QAM",
"trx_mode": "16QAM",
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 50000000000.0,
"max-nb-of-channel": 80,
"output-power": null,
@@ -355,12 +289,6 @@
"technology": "flexi-grid",
"trx_type": "Voyager",
"trx_mode": "mode 1",
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 50000000000.0,
"max-nb-of-channel": null,
"output-power": 0.001,
@@ -380,12 +308,6 @@
"technology": "flexi-grid",
"trx_type": "vendorA_trx-type1",
"trx_mode": "PS_SP64_1",
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 50000000000.0,
"max-nb-of-channel": null,
"output-power": null,
@@ -405,12 +327,6 @@
"technology": "flexi-grid",
"trx_type": "vendorA_trx-type1",
"trx_mode": null,
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 50000000000.0,
"max-nb-of-channel": 80,
"output-power": 0.001,
@@ -451,12 +367,6 @@
"technology": "flexi-grid",
"trx_type": "Voyager",
"trx_mode": null,
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 50000000000.0,
"max-nb-of-channel": null,
"output-power": 0.001,
@@ -476,12 +386,6 @@
"technology": "flexi-grid",
"trx_type": "Voyager",
"trx_mode": null,
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 75000000000.0,
"max-nb-of-channel": 63,
"output-power": null,
@@ -501,12 +405,6 @@
"technology": "flexi-grid",
"trx_type": "Voyager",
"trx_mode": null,
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 50000000000.0,
"max-nb-of-channel": null,
"output-power": null,
@@ -526,12 +424,6 @@
"technology": "flexi-grid",
"trx_type": "Voyager",
"trx_mode": null,
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 75000000000.0,
"max-nb-of-channel": null,
"output-power": null,
@@ -551,12 +443,6 @@
"technology": "flexi-grid",
"trx_type": "Voyager",
"trx_mode": null,
"effective-freq-slot": [
{
"n": "null",
"m": "null"
}
],
"spacing": 30000000000.0,
"max-nb-of-channel": null,
"output-power": null,

View File

@@ -0,0 +1,239 @@
There are 96 channels propagating
Power mode is set to True
=> it can be modified in eqpt_config.json - Span
There are 6 fiber spans over 500 km between trx_Stockholm and trx_Gothenburg
Now propagating between trx_Stockholm and trx_Gothenburg:
Propagating with input power = 2.00 dBm:
Transceiver trx_Stockholm
GSNR (0.1nm, dB): 35.00
GSNR (signal bw, dB): 30.98
OSNR ASE (0.1nm, dB): 35.00
OSNR ASE (signal bw, dB): 30.98
CD (ps/nm): 0.00
PMD (ps): 0.00
Roadm roadm_Stockholm
effective loss (dB): 22.00
pch out (dBm): -20.00
Edfa Edfa_booster_roadm_Stockholm_to_fiber (Stockholm → Norrköping)_(1/2)
type_variety: openroadm_mw_mw_booster
effective gain(dB): 22.00
(before att_in and before output VOA)
noise figure (dB): -inf
(including att_in)
pad att_in (dB): 0.00
Power In (dBm): -0.18
Power Out (dBm): 21.82
Delta_P (dB): 0.00
target pch (dBm): 2.00
effective pch (dBm): 2.00
output VOA (dB): 0.00
Fiber fiber (Stockholm → Norrköping)_(1/2)
type_variety: SSMF
length (km): 81.63
pad att_in (dB): 0.00
total loss (dB): 16.33
(includes conn loss (dB) in: 0.00 out: 0.00)
(conn loss out includes EOL margin defined in eqpt_config.json)
pch out (dBm): -14.33
Edfa Edfa_fiber (Stockholm → Norrköping)_(1/2)
type_variety: openroadm_ila_low_noise
effective gain(dB): 16.33
(before att_in and before output VOA)
noise figure (dB): 8.01
(including att_in)
pad att_in (dB): 0.00
Power In (dBm): 5.51
Power Out (dBm): 21.84
Delta_P (dB): 0.00
target pch (dBm): 2.00
effective pch (dBm): 2.00
output VOA (dB): 0.00
Fiber fiber (Stockholm → Norrköping)_(2/2)
type_variety: SSMF
length (km): 81.63
pad att_in (dB): 0.00
total loss (dB): 16.33
(includes conn loss (dB) in: 0.00 out: 0.00)
(conn loss out includes EOL margin defined in eqpt_config.json)
pch out (dBm): -14.33
Edfa Edfa_preamp_roadm_Norrköping_from_fiber (Stockholm → Norrköping)_(2/2)
type_variety: openroadm_mw_mw_preamp_worstcase_ver5
effective gain(dB): 16.33
(before att_in and before output VOA)
noise figure (dB): 11.44
(including att_in)
pad att_in (dB): 0.00
Power In (dBm): 5.53
Power Out (dBm): 21.86
Delta_P (dB): 0.00
target pch (dBm): 2.00
effective pch (dBm): 2.00
output VOA (dB): 0.00
Roadm roadm_Norrköping
effective loss (dB): 22.00
pch out (dBm): -20.00
Edfa Edfa_booster_roadm_Norrköping_to_fiber (Norrköping → Linköping)
type_variety: openroadm_mw_mw_booster
effective gain(dB): 22.00
(before att_in and before output VOA)
noise figure (dB): -inf
(including att_in)
pad att_in (dB): 0.00
Power In (dBm): -0.18
Power Out (dBm): 21.82
Delta_P (dB): 0.00
target pch (dBm): 2.00
effective pch (dBm): 2.00
output VOA (dB): 0.00
Fiber fiber (Norrköping → Linköping)
type_variety: SSMF
length (km): 45.99
pad att_in (dB): 1.80
total loss (dB): 11.00
(includes conn loss (dB) in: 0.00 out: 0.00)
(conn loss out includes EOL margin defined in eqpt_config.json)
pch out (dBm): -9.00
Edfa Edfa_preamp_roadm_Linköping_from_fiber (Norrköping → Linköping)
type_variety: openroadm_mw_mw_preamp_worstcase_ver5
effective gain(dB): 11.00
(before att_in and before output VOA)
noise figure (dB): 16.00
(including att_in)
pad att_in (dB): 0.00
Power In (dBm): 10.83
Power Out (dBm): 21.83
Delta_P (dB): 0.00
target pch (dBm): 2.00
effective pch (dBm): 2.00
output VOA (dB): 0.00
Roadm roadm_Linköping
effective loss (dB): 22.00
pch out (dBm): -20.00
Edfa Edfa_booster_roadm_Linköping_to_fiber (Linköping → Jönköping)
type_variety: openroadm_mw_mw_booster
effective gain(dB): 22.00
(before att_in and before output VOA)
noise figure (dB): -inf
(including att_in)
pad att_in (dB): 0.00
Power In (dBm): -0.18
Power Out (dBm): 21.82
Delta_P (dB): 0.00
target pch (dBm): 2.00
effective pch (dBm): 2.00
output VOA (dB): 0.00
Fiber fiber (Linköping → Jönköping)
type_variety: SSMF
length (km): 134.02
pad att_in (dB): 0.00
total loss (dB): 26.80
(includes conn loss (dB) in: 0.00 out: 0.00)
(conn loss out includes EOL margin defined in eqpt_config.json)
pch out (dBm): -24.80
Edfa Edfa_preamp_roadm_Jönköping_from_fiber (Linköping → Jönköping)
type_variety: openroadm_mw_mw_preamp_worstcase_ver5
effective gain(dB): 26.80
(before att_in and before output VOA)
noise figure (dB): 8.01
(including att_in)
pad att_in (dB): 0.00
Power In (dBm): -4.97
Power Out (dBm): 21.86
Delta_P (dB): 0.00
target pch (dBm): 2.00
effective pch (dBm): 2.00
output VOA (dB): 0.00
Roadm roadm_Jönköping
effective loss (dB): 22.00
pch out (dBm): -20.00
Edfa Edfa_booster_roadm_Jönköping_to_fiber (Jönköping → Borås)
type_variety: openroadm_mw_mw_booster
effective gain(dB): 22.00
(before att_in and before output VOA)
noise figure (dB): -inf
(including att_in)
pad att_in (dB): 0.00
Power In (dBm): -0.18
Power Out (dBm): 21.82
Delta_P (dB): 0.00
target pch (dBm): 2.00
effective pch (dBm): 2.00
output VOA (dB): 0.00
Fiber fiber (Jönköping → Borås)
type_variety: SSMF
length (km): 89.12
pad att_in (dB): 0.00
total loss (dB): 17.82
(includes conn loss (dB) in: 0.00 out: 0.00)
(conn loss out includes EOL margin defined in eqpt_config.json)
pch out (dBm): -15.82
Edfa Edfa_preamp_roadm_Borås_from_fiber (Jönköping → Borås)
type_variety: openroadm_mw_mw_preamp_worstcase_ver5
effective gain(dB): 17.82
(before att_in and before output VOA)
noise figure (dB): 10.54
(including att_in)
pad att_in (dB): 0.00
Power In (dBm): 4.01
Power Out (dBm): 21.84
Delta_P (dB): 0.00
target pch (dBm): 2.00
effective pch (dBm): 2.00
output VOA (dB): 0.00
Roadm roadm_Borås
effective loss (dB): 22.00
pch out (dBm): -20.00
Edfa Edfa_booster_roadm_Borås_to_fiber (Borås → Gothenburg)
type_variety: openroadm_mw_mw_booster
effective gain(dB): 22.00
(before att_in and before output VOA)
noise figure (dB): -inf
(including att_in)
pad att_in (dB): 0.00
Power In (dBm): -0.18
Power Out (dBm): 21.82
Delta_P (dB): 0.00
target pch (dBm): 2.00
effective pch (dBm): 2.00
output VOA (dB): 0.00
Fiber fiber (Borås → Gothenburg)
type_variety: SSMF
length (km): 67.64
pad att_in (dB): 0.00
total loss (dB): 13.53
(includes conn loss (dB) in: 0.00 out: 0.00)
(conn loss out includes EOL margin defined in eqpt_config.json)
pch out (dBm): -11.53
Edfa Edfa_preamp_roadm_Gothenburg_from_fiber (Borås → Gothenburg)
type_variety: openroadm_mw_mw_preamp_worstcase_ver5
effective gain(dB): 13.53
(before att_in and before output VOA)
noise figure (dB): 13.54
(including att_in)
pad att_in (dB): 0.00
Power In (dBm): 8.30
Power Out (dBm): 21.84
Delta_P (dB): 0.00
target pch (dBm): 2.00
effective pch (dBm): 2.00
output VOA (dB): 0.00
Roadm roadm_Gothenburg
effective loss (dB): 22.00
pch out (dBm): -20.00
Transceiver trx_Gothenburg
GSNR (0.1nm, dB): 19.27
GSNR (signal bw, dB): 15.24
OSNR ASE (0.1nm, dB): 21.84
OSNR ASE (signal bw, dB): 17.82
CD (ps/nm): 8350.42
PMD (ps): 0.89
Transmission result for input power = 2.00 dBm:
Final GSNR (0.1 nm): 19.27 dB
(No source node specified: picked trx_Stockholm)
(No destination node specified: picked trx_Gothenburg)

View File

@@ -1,4 +1,3 @@
Computing path requests gnpy/example-data/meshTopologyExampleV2.xls into JSON format
List of disjunctions
[Disjunction 3
relaxable: false

View File

@@ -0,0 +1,326 @@
There are 96 channels propagating
Power mode is set to True
=> it can be modified in eqpt_config.json - Span
WARNING: target gain and power in node west edfa in Lorient_KMA to Loudeac
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: WARNING: effective gain in Node east edfa in Lannion_CAS to Stbrieuc is above user specified amplifier std_low_gain
max flat gain: 16dB ; required gain: 23.0dB. Please check amplifier type.
WARNING: target gain and power in node west edfa in Rennes_STA to Stbrieuc
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: WARNING: effective gain in Node east edfa in Lannion_CAS to Morlaix is above user specified amplifier std_low_gain
max flat gain: 16dB ; required gain: 23.5dB. Please check amplifier type.
WARNING: target gain and power in node west edfa in Brest_KLA to Morlaix
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in Lorient_KMA to Loudeac
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: WARNING: effective gain in Node west edfa in Lannion_CAS to Corlay is above user specified amplifier test
max flat gain: 25dB ; required gain: 29.82dB. Please check amplifier type.
WARNING: target gain and power in node east edfa in Lorient_KMA to Vannes_KBE
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in Vannes_KBE to Lorient_KMA
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in Lorient_KMA to Quimper
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in Quimper to Lorient_KMA
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in Brest_KLA to Quimper
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in Vannes_KBE to Lorient_KMA
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in Lorient_KMA to Vannes_KBE
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in Vannes_KBE to Ploermel
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in Ploermel to Vannes_KBE
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in Rennes_STA to Ploermel
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in Rennes_STA to Stbrieuc
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in Stbrieuc to Rennes_STA
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in Lannion_CAS to Stbrieuc
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in Rennes_STA to Ploermel
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in Vannes_KBE to Ploermel
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in Brest_KLA to Morlaix
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: WARNING: effective gain in Node east edfa in Brest_KLA to Quimper is above user specified amplifier std_low_gain
max flat gain: 16dB ; required gain: 23.0dB. Please check amplifier type.
WARNING: target gain and power in node east edfa in Quimper to Lorient_KMA
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in Lorient_KMA to Quimper
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in a to b
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in b to a
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in a to c
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in c to a
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in b to a
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in a to b
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in b to f
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in f to b
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in c to a
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in a to c
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in d to c
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in c to f
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in f to c
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in d to c
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in c to d
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in d to e
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in e to d
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in e to d
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in d to e
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in e to g
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in g to e
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in f to c
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in c to f
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in f to b
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in b to f
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in f to h
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in h to f
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in g to e
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in e to g
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in g to h
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in h to g
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in h to f
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in f to h
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node east edfa in h to g
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
WARNING: target gain and power in node west edfa in g to h
is beyond all available amplifiers capabilities and/or extended_gain_range:
a power reduction of -1.82 is applied
There are 3 fiber spans over 130 km between trx Lannion_CAS and trx Lorient_KMA
Now propagating between trx Lannion_CAS and trx Lorient_KMA:
Propagating with input power = 3.00 dBm:
Transceiver trx Lannion_CAS
GSNR (0.1nm, dB): 100.00
GSNR (signal bw, dB): 95.92
OSNR ASE (0.1nm, dB): 100.00
OSNR ASE (signal bw, dB): 95.92
CD (ps/nm): 0.00
PMD (ps): 0.00
Roadm roadm Lannion_CAS
effective loss (dB): 23.00
pch out (dBm): -20.00
Edfa east edfa in Lannion_CAS to Corlay
type_variety: test
effective gain(dB): 21.18
(before att_in and before output VOA)
noise figure (dB): 6.13
(including att_in)
pad att_in (dB): 0.00
Power In (dBm): -0.18
Power Out (dBm): 21.01
Delta_P (dB): 0.00
target pch (dBm): 3.00
effective pch (dBm): 1.18
output VOA (dB): 0.00
Fiber fiber (Lannion_CAS → Corlay)-F061
type_variety: SSMF
length (km): 20.00
pad att_in (dB): 0.00
total loss (dB): 4.00
(includes conn loss (dB) in: 0.00 out: 0.00)
(conn loss out includes EOL margin defined in eqpt_config.json)
pch out (dBm): -2.82
Fused west fused spans in Corlay
loss (dB): 1.00
Fiber fiber (Corlay → Loudeac)-F010
type_variety: SSMF
length (km): 50.00
pad att_in (dB): 0.00
total loss (dB): 10.00
(includes conn loss (dB) in: 0.00 out: 0.00)
(conn loss out includes EOL margin defined in eqpt_config.json)
pch out (dBm): -13.82
Fused west fused spans in Loudeac
loss (dB): 1.00
Fiber fiber (Loudeac → Lorient_KMA)-F054
type_variety: SSMF
length (km): 60.00
pad att_in (dB): 0.00
total loss (dB): 12.00
(includes conn loss (dB) in: 0.00 out: 0.00)
(conn loss out includes EOL margin defined in eqpt_config.json)
pch out (dBm): -26.82
Edfa west edfa in Lorient_KMA to Loudeac
type_variety: test
effective gain(dB): 28.00
(before att_in and before output VOA)
noise figure (dB): 5.76
(including att_in)
pad att_in (dB): 0.00
Power In (dBm): -6.99
Power Out (dBm): 21.04
Delta_P (dB): -1.82
target pch (dBm): 1.18
effective pch (dBm): 1.18
output VOA (dB): 0.00
Roadm roadm Lorient_KMA
effective loss (dB): 21.18
pch out (dBm): -20.00
Transceiver trx Lorient_KMA
GSNR (0.1nm, dB): 23.94
GSNR (signal bw, dB): 19.85
OSNR ASE (0.1nm, dB): 24.29
OSNR ASE (signal bw, dB): 20.20
CD (ps/nm): 2171.00
PMD (ps): 0.46
Transmission result for input power = 3.00 dBm:
Final GSNR (0.1 nm): 23.94 dB
(Invalid source node 'lannion' replaced with trx Lannion_CAS)
(Invalid destination node 'lorient' replaced with trx Lorient_KMA)

View File

@@ -4,18 +4,18 @@
# License: BSD 3-Clause Licence
# Copyright (c) 2018, Telecom Infra Project
"""
'''
@author: esther.lerouzic
checks that computed paths are disjoint as specified in the json service file
that computed paths do not loop
that include node constraints are correctly taken into account
"""
'''
from pathlib import Path
import pytest
from gnpy.core.equipment import trx_mode_params
from gnpy.core.network import build_network
from gnpy.core.exceptions import ServiceError
from gnpy.core.exceptions import ServiceError, DisjunctionError
from gnpy.core.utils import automatic_nch, lin2db
from gnpy.core.elements import Roadm
from gnpy.topology.request import (compute_path_dsjctn, isdisjoint, find_reversed_path, PathRequest,
@@ -31,8 +31,8 @@ EQPT_LIBRARY_NAME = Path(__file__).parent.parent / 'tests/data/eqpt_config.json'
@pytest.fixture()
def serv(test_setup):
""" common setup for service list
"""
''' common setup for service list
'''
network, equipment = test_setup
data = load_requests(SERVICE_FILE_NAME, equipment, bidir=False, network=network, network_filename=NETWORK_FILE_NAME)
rqs = requests_from_json(data, equipment)
@@ -43,12 +43,12 @@ def serv(test_setup):
@pytest.fixture()
def test_setup():
""" common setup for tests: builds network, equipment and oms only once
"""
''' common setup for tests: builds network, equipment and oms only once
'''
equipment = load_equipment(EQPT_LIBRARY_NAME)
network = load_network(NETWORK_FILE_NAME, equipment)
# Build the network once using the default power defined in SI in eqpt config
# power density : db2linp(ower_dbm": 0)/power_dbm": 0 * nb channels as defined by
# power density : db2linp(ower_dbm': 0)/power_dbm': 0 * nb channels as defined by
# spacing, f_min and f_max
p_db = equipment['SI']['default'].power_dbm
@@ -61,9 +61,9 @@ def test_setup():
def test_disjunction(serv):
""" service_file contains sevaral combination of disjunction constraint. The test checks
''' service_file contains sevaral combination of disjunction constraint. The test checks
that computed paths with disjunction constraint are effectively disjoint
"""
'''
network, equipment, rqs, dsjn = serv
pths = compute_path_dsjctn(network, equipment, rqs, dsjn)
print(dsjn)
@@ -86,8 +86,8 @@ def test_disjunction(serv):
def test_does_not_loop_back(serv):
""" check that computed paths do not loop back ie each element appears only once
"""
''' check that computed paths do not loop back ie each element appears only once
'''
network, equipment, rqs, dsjn = serv
pths = compute_path_dsjctn(network, equipment, rqs, dsjn)
test = True
@@ -107,33 +107,35 @@ def test_does_not_loop_back(serv):
#
def create_rq(equipment, srce, dest, bdir, nd_list, ls_list):
""" create the usual request list according to parameters
"""
def create_rq(equipment, srce, dest, bdir, node_list, loose_list, rqid='test_request'):
''' create the usual request list according to parameters
'''
requests_list = []
params = {}
params['request_id'] = 'test_request'
params['source'] = srce
params['bidir'] = bdir
params['destination'] = dest
params['trx_type'] = 'Voyager'
params['trx_mode'] = 'mode 1'
params = {
'request_id': rqid,
'source': srce,
'bidir': bdir,
'destination': dest,
'trx_type': 'Voyager',
'trx_mode': 'mode 1',
'spacing': 50000000000.0,
'nodes_list': node_list,
'loose_list': loose_list,
'path_bandwidth': 100.0e9,
'power': 1.0,
'effective_freq_slot': None,
}
params['format'] = params['trx_mode']
params['spacing'] = 50000000000.0
params['nodes_list'] = nd_list
params['loose_list'] = ls_list
trx_params = trx_mode_params(equipment, params['trx_type'], params['trx_mode'], True)
params.update(trx_params)
params['power'] = 1.0
f_min = params['f_min']
f_max_from_si = params['f_max']
params['nb_channel'] = automatic_nch(f_min, f_max_from_si, params['spacing'])
params['path_bandwidth'] = 100000000000.0
requests_list.append(PathRequest(**params))
return requests_list
@pytest.mark.parametrize('srce, dest, result, pth, nd_list, ls_list', [
@pytest.mark.parametrize('srce, dest, result, pth, node_list, loose_list', [
['a', 'trx h', 'fail', 'no_path', [], []],
['trx a', 'h', 'fail', 'no_path', [], []],
['trx a', 'trx h', 'pass', 'found_path', [], []],
@@ -148,8 +150,8 @@ def create_rq(equipment, srce, dest, bdir, nd_list, ls_list):
['trx a', 'trx h', 'pass', 'found_path', ['trx a', 'roadm g'], ['STRICT', 'STRICT']],
['trx a', 'trx h', 'pass', 'found_path', ['trx h'], ['STRICT']],
['trx a', 'trx h', 'pass', 'found_path', ['roadm a'], ['STRICT']]])
def test_include_constraints(test_setup, srce, dest, result, pth, nd_list, ls_list):
""" check that all combinations of constraints are correctly handled:
def test_include_constraints(test_setup, srce, dest, result, pth, node_list, loose_list):
''' check that all combinations of constraints are correctly handled:
- STRICT/LOOSE
- correct names/incorrect names -> pass/fail
- possible include/impossible include
@@ -161,20 +163,82 @@ def test_include_constraints(test_setup, srce, dest, result, pth, nd_list, ls_li
| cannot be applied | no_path | found_path
----------------------------------------------------------------------------------
0 | | computation stops
"""
'''
network, equipment = test_setup
dsjn = []
bdir = False
rqs = create_rq(equipment, srce, dest, bdir, nd_list, ls_list)
rqs = create_rq(equipment, srce, dest, bdir, node_list, loose_list)
print(rqs)
if result == 'fail':
with pytest.raises(ServiceError):
rqs = correct_json_route_list(network, rqs)
else:
rqs = correct_json_route_list(network, rqs)
pths = compute_path_dsjctn(network, equipment, rqs, dsjn)
paths = compute_path_dsjctn(network, equipment, rqs, dsjn)
# if loose, one path can be returned
if pths[0]:
if paths[0]:
assert pth == 'found_path'
else:
assert pth == 'no_path'
@pytest.mark.parametrize('dis1, dis2, node_list1, loose_list1, result, expected_paths', [
[['1', '2', '3'], ['2', '3'], [], [], 'pass',
[['roadm a', 'roadm c', 'roadm d', 'roadm e', 'roadm g'],
['roadm c', 'roadm f'],
['roadm a', 'roadm b', 'roadm f', 'roadm h']]],
[['1', '2', '3'], ['2', '3'], ['b'], ['STRICT'], 'fail', []],
[['1', '2'], ['2', '3'], [], [], 'pass',
[['roadm a', 'roadm c', 'roadm d', 'roadm e', 'roadm g'],
['roadm c', 'roadm f'],
['roadm a', 'roadm b', 'roadm f', 'roadm h']]],
[['1', '2'], ['2', '3'], ['roadm e'], ['LOOSE'], 'pass',
[['roadm a', 'roadm c', 'roadm d', 'roadm e', 'roadm g'],
['roadm c', 'roadm f'],
['roadm a', 'roadm b', 'roadm f', 'roadm h']]],
[['1', '2'], ['2', '3'], ['roadm c | roadm f'], ['LOOSE'], 'pass',
[['roadm a', 'roadm c', 'roadm d', 'roadm e', 'roadm g'],
['roadm c', 'roadm f'],
['roadm a', 'roadm b', 'roadm f', 'roadm h']]]])
def test_create_disjunction(test_setup, dis1, dis2, node_list1, loose_list1, result, expected_paths):
""" verifies that the expected result is obtained for a set of particular constraints:
in particular, verifies that:
- multiple disjunction constraints are correcly handled
- in case a loose constraint can not be met, the first alternate candidate is selected
instead of the last one (last case).
"""
network, equipment = test_setup
json_data = {
'synchronization': [{
'synchronization-id': 'x',
'svec': {
'relaxable': 'false',
'disjointness': 'node link',
'request-id-number': dis1
}
}, {
'synchronization-id': 'y',
'svec': {
'relaxable': 'false',
'disjointness': 'node link',
'request-id-number': dis2
}
}]}
dsjn = disjunctions_from_json(json_data)
bdir = False
rqs = create_rq(equipment, 'trx a', 'trx g', bdir, node_list1, loose_list1, '1') +\
create_rq(equipment, 'trx c', 'trx f', bdir, [], [], '2') +\
create_rq(equipment, 'trx a', 'trx h', bdir, [], [], '3')
if result == 'fail':
with pytest.raises(DisjunctionError):
paths = compute_path_dsjctn(network, equipment, rqs, dsjn)
else:
paths = compute_path_dsjctn(network, equipment, rqs, dsjn)
path_names = []
for path in paths:
roadm_names = [e.uid for e in path if isinstance(e, Roadm)]
path_names.append(roadm_names)
assert path_names == expected_paths
# if loose, one path can be returned

View File

@@ -11,20 +11,24 @@ SRC_ROOT = Path(__file__).parent.parent
@pytest.mark.parametrize("output, handler, args", (
('transmission_main_example', transmission_main_example, []),
('transmission_saturated', transmission_main_example,
['tests/data/testTopology_expected.json', 'lannion', 'lorient', '-e', 'tests/data/eqpt_config.json', '--pow', '3']),
('path_requests_run', path_requests_run, []),
('transmission_main_example__raman', transmission_main_example,
['gnpy/example-data/raman_edfa_example_network.json', '--sim', 'gnpy/example-data/sim_params.json', '--show-channels', ]),
('openroadm-Stockholm-Gothenburg', transmission_main_example,
['-e', 'gnpy/example-data/eqpt_config_openroadm.json', 'gnpy/example-data/Sweden_OpenROADM_example_network.json', ]),
('openroadm-v4-Stockholm-Gothenburg', transmission_main_example,
['-e', 'gnpy/example-data/eqpt_config_openroadm_ver4.json', 'gnpy/example-data/Sweden_OpenROADMv4_example_network.json', ]),
('openroadm-v5-Stockholm-Gothenburg', transmission_main_example,
['-e', 'gnpy/example-data/eqpt_config_openroadm_ver5.json', 'gnpy/example-data/Sweden_OpenROADMv5_example_network.json', ]),
))
def test_example_invocation(capfdbinary, output, handler, args):
def test_example_invocation(capfd, output, handler, args):
'''Make sure that our examples produce useful output'''
os.chdir(SRC_ROOT)
expected = open(SRC_ROOT / 'tests' / 'invocation' / output, mode='rb').read()
expected = open(SRC_ROOT / 'tests' / 'invocation' / output, mode='r', encoding='utf-8').read()
handler(args)
captured = capfdbinary.readouterr()
captured = capfd.readouterr()
assert captured.out == expected
assert captured.err == b''
assert captured.err == ''
@pytest.mark.parametrize('program', ('gnpy-transmission-example', 'gnpy-path-request'))
@@ -39,7 +43,7 @@ def test_run_wrapper(program):
def test_conversion_xls():
proc = subprocess.run(
('gnpy-convert-xls', SRC_ROOT / 'tests' / 'data' / 'testTopology.xls', '--output', '/dev/null'),
('gnpy-convert-xls', SRC_ROOT / 'tests' / 'data' / 'testTopology.xls', '--output', os.path.devnull),
stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True, universal_newlines=True)
assert proc.stderr == ''
assert '/dev/null' in proc.stdout
assert os.path.devnull in proc.stdout

View File

@@ -243,35 +243,6 @@ def test_csv_response_generation(tmpdir, json_input):
print(type(list(resp[column])[-1]))
def compare_response(exp_resp, act_resp):
""" False if the keys are different in the nested dicts as well
"""
print(exp_resp)
print(act_resp)
test = True
for key in act_resp.keys():
if key not in exp_resp.keys():
print(f'{key} is not expected')
return False
if isinstance(act_resp[key], dict):
test = compare_response(exp_resp[key], act_resp[key])
if test:
for key in exp_resp.keys():
if key not in act_resp.keys():
print(f'{key} is expected')
return False
if isinstance(exp_resp[key], dict):
test = compare_response(exp_resp[key], act_resp[key])
# at this point exp_resp and act_resp have the same keys. Check if their values are the same
for key in act_resp.keys():
if not isinstance(act_resp[key], dict):
if exp_resp[key] != act_resp[key]:
print(f'expected value :{exp_resp[key]}\n actual value: {act_resp[key]}')
return False
return test
# test json answers creation
@pytest.mark.parametrize('xls_input, expected_response_file', {
DATA_DIR / 'testTopology.xls': DATA_DIR / 'testTopology_response.json',
@@ -304,11 +275,12 @@ def test_json_response_generation(xls_input, expected_response_file):
result = []
for i, pth in enumerate(propagatedpths):
# test ServiceError handling : when M is zero at this point, the
# test ServiceError handling : when M is None at this point, the
# json result should not be created if there is no blocking reason
if i == 1:
my_rq = deepcopy(rqs[i])
my_rq.M = 0
my_rq.M = None
my_rq.N = None
with pytest.raises(ServiceError):
ResultElement(my_rq, pth, reversed_propagatedpths[i]).json
@@ -327,7 +299,7 @@ def test_json_response_generation(xls_input, expected_response_file):
if i == 2:
# compare response must be False because z-a metric is missing
# (request with bidir option to cover bidir case)
assert not compare_response(expected['response'][i], response)
assert expected['response'][i] != response
print(f'response {response["response-id"]} should not match')
expected['response'][2]['path-properties']['z-a-path-metric'] = [
{'metric-type': 'SNR-bandwidth', 'accumulative-value': 22.809999999999999},
@@ -338,8 +310,7 @@ def test_json_response_generation(xls_input, expected_response_file):
{'metric-type': 'path_bandwidth', 'accumulative-value': 60000000000.0}]
# test should be OK now
else:
assert compare_response(expected['response'][i], response)
print(f'response {response["response-id"]} is not correct')
assert expected['response'][i] == response
# test the correspondance names dict in case of excel input
# test that using the created json network still works with excel input
@@ -424,6 +395,7 @@ def test_excel_ila_constraints(source, destination, route_list, hoptype, expecte
'nb_channel': 0,
'power': 0,
'path_bandwidth': 0,
'effective_freq_slot': None
}
request = PathRequest(**params)

View File

@@ -207,8 +207,9 @@ def test_restrictions(restrictions, equipment):
raise AssertionError()
@pytest.mark.parametrize('power_dbm', [0, +1, -2])
@pytest.mark.parametrize('prev_node_type, effective_pch_out_db', [('edfa', -20.0), ('fused', -22.0)])
def test_roadm_target_power(prev_node_type, effective_pch_out_db):
def test_roadm_target_power(prev_node_type, effective_pch_out_db, power_dbm):
''' Check that egress power of roadm is equal to target power if input power is greater
than target power else, that it is equal to input power. Use a simple two hops A-B-C topology
for the test where the prev_node in ROADM B is either an amplifier or a fused, so that the target
@@ -225,28 +226,28 @@ def test_roadm_target_power(prev_node_type, effective_pch_out_db):
prev_node['params'] = {'loss': 0}
json_network['elements'].append(prev_node)
network = network_from_json(json_network, equipment)
# Build the network once using the default power defined in SI in eqpt config
p_db = equipment['SI']['default'].power_dbm
p_total_db = p_db + lin2db(automatic_nch(equipment['SI']['default'].f_min,
equipment['SI']['default'].f_max,
equipment['SI']['default'].spacing))
p_total_db = power_dbm + lin2db(automatic_nch(equipment['SI']['default'].f_min,
equipment['SI']['default'].f_max,
equipment['SI']['default'].spacing))
build_network(network, equipment, p_db, p_total_db)
build_network(network, equipment, power_dbm, p_total_db)
params = {}
params['request_id'] = 0
params['trx_type'] = ''
params['trx_mode'] = ''
params['source'] = 'trx node A'
params['destination'] = 'trx node C'
params['bidir'] = False
params['nodes_list'] = ['trx node C']
params['loose_list'] = ['strict']
params['format'] = ''
params['path_bandwidth'] = 100e9
params = {'request_id': 0,
'trx_type': '',
'trx_mode': '',
'source': 'trx node A',
'destination': 'trx node C',
'bidir': False,
'nodes_list': ['trx node C'],
'loose_list': ['strict'],
'format': '',
'path_bandwidth': 100e9,
'effective_freq_slot': None,
}
trx_params = trx_mode_params(equipment)
params.update(trx_params)
req = PathRequest(**params)
req.power = db2lin(power_dbm - 30)
path = compute_constrained_path(network, req)
si = create_input_spectral_information(
req.f_min, req.f_max, req.roll_off, req.baud_rate,
@@ -254,10 +255,23 @@ def test_roadm_target_power(prev_node_type, effective_pch_out_db):
for i, el in enumerate(path):
if isinstance(el, Roadm):
carriers_power_in_roadm = min([c.power.signal + c.power.nli + c.power.ase for c in si.carriers])
si = el(si, degree=path[i+1].uid)
si = el(si, degree=path[i + 1].uid)
if el.uid == 'roadm node B':
print('input', carriers_power_in_roadm)
assert el.effective_pch_out_db == effective_pch_out_db
# if previous was an EDFA, power level at ROADM input is enough for the ROADM to apply its
# target power (as specified in equipment ie -20 dBm)
# if it is a Fused, the input power to the ROADM is smaller than the target power, and the
# ROADM cannot apply this target. In this case, it is assumed that the ROADM has 0 dB loss
# so the output power will be the same as the input power, which for this particular case
# corresponds to -22dBm + power_dbm
# next step (for ROADM modelling) will be to apply a minimum loss for ROADMs !
if prev_node_type == 'edfa':
assert el.effective_pch_out_db == effective_pch_out_db
if prev_node_type == 'fused':
# then output power == input_power == effective_pch_out_db + power_dbm
assert effective_pch_out_db + power_dbm == \
pytest.approx(lin2db(carriers_power_in_roadm * 1e3), rel=1e-3)
assert el.effective_pch_out_db == effective_pch_out_db + power_dbm
for carrier in si.carriers:
print(carrier.power.signal + carrier.power.nli + carrier.power.ase)
power = carrier.power.signal + carrier.power.nli + carrier.power.ase
@@ -272,4 +286,3 @@ def test_roadm_target_power(prev_node_type, effective_pch_out_db):
assert power == pytest.approx(carriers_power_in_roadm, rel=1e-3)
else:
si = el(si)

View File

@@ -17,11 +17,12 @@ import pytest
from gnpy.core.network import build_network
from gnpy.core.utils import lin2db, automatic_nch
from gnpy.core.elements import Roadm, Transceiver
from gnpy.core.exceptions import SpectrumError
from gnpy.topology.request import compute_path_dsjctn, find_reversed_path, deduplicate_disjunctions
from gnpy.core.exceptions import ServiceError, SpectrumError
from gnpy.topology.request import compute_path_dsjctn, find_reversed_path, deduplicate_disjunctions, PathRequest
from gnpy.topology.spectrum_assignment import (build_oms_list, align_grids, nvalue_to_frequency,
bitmap_sum, Bitmap, spectrum_selection, pth_assign_spectrum)
from gnpy.tools.json_io import load_equipment, load_network, requests_from_json, disjunctions_from_json
from gnpy.tools.json_io import (load_equipment, load_network, requests_from_json, disjunctions_from_json,
_check_one_request)
TEST_DIR = Path(__file__).parent
DATA_DIR = TEST_DIR / 'data'
@@ -267,6 +268,108 @@ def test_spectrum_assignment_on_path(equipment, setup, requests):
assert center_n is not None and startn is not None and stopn is not None
@pytest.fixture()
def request_set():
""" creates default request dict
"""
return {
'request_id': '0',
'source': 'trx a',
'bidir': False,
'destination': 'trx g',
'trx_type': 'Voyager',
'trx_mode': 'mode 1',
'format': 'mode1',
'spacing': 50e9,
'nodes_list': [],
'loose_list': [],
'f_min': 191.1e12,
'f_max': 196.3e12,
'baud_rate': 32e9,
'OSNR': 14,
'bit_rate': 100e9,
'cost': 1,
'roll_off': 0.15,
'tx_osnr': 38,
'min_spacing': 37.5e9,
'nb_channel': None,
'power': 0,
'path_bandwidth': 800e9}
def test_freq_slot_exist(setup, equipment, request_set):
""" test that assignment works even if effective_freq_slot is not populated
"""
network, oms_list = setup
params = request_set
params['effective_freq_slot'] = None
rqs = [PathRequest(**params)]
paths = compute_path_dsjctn(network, equipment, rqs, [])
pth_assign_spectrum(paths, rqs, oms_list, [find_reversed_path(paths[0])])
assert rqs[0].N == -256
assert rqs[0].M == 32
def test_inconsistant_freq_slot(setup, equipment, request_set):
""" test that an inconsistant M correctly raises an error
"""
network, oms_list = setup
params = request_set
# minimum required nb of slots is 32 (800Gbit/100Gbit/s channels each occupying 50GHz ie 4 slots)
params['effective_freq_slot'] = {'N': 0, 'M': 4}
with pytest.raises(ServiceError):
_check_one_request(params, 196.05e12)
params['trx_mode'] = None
rqs = [PathRequest(**params)]
paths = compute_path_dsjctn(network, equipment, rqs, [])
pth_assign_spectrum(paths, rqs, oms_list, [find_reversed_path(paths[0])])
assert rqs[0].blocking_reason == 'NOT_ENOUGH_RESERVED_SPECTRUM'
@pytest.mark.parametrize('n, m, final_n, final_m, blocking_reason', [
# regular requests that should be correctly assigned:
(-100, 32, -100, 32, None),
(150, 50, 150, 50, None),
# if n is None, there should be an assignment (enough spectrum cases)
# and the center frequency should be set on the lower part of the spectrum based on m value if it exists
# or based on 32
(None, 32, -256, 32, None),
(None, 40, -248, 40, None),
(-100, None, -100, 32, None),
(None, None, -256, 32, None),
# -280 and 60 center indexes should result in unfeasible spectrum, either out of band or
# overlapping with occupied spectrum. The requested spectrum is not available
(-280, None, None, None, 'NO_SPECTRUM'),
(-60, 40, None, None, 'NO_SPECTRUM'),
# 20 is smaller than min 32 required nb of slots so should also be blocked
(-60, 20, None, None, 'NOT_ENOUGH_RESERVED_SPECTRUM')
])
def test_n_m_requests(setup, equipment, n, m, final_n, final_m, blocking_reason, request_set):
""" test that various N and M values for a request end up with the correct path assgnment
"""
network, oms_list = setup
# add an occupation on one of the span of the expected path OMS list on both directions
# as defined by its offsets within the OMS list: [17, 20, 13, 22] and reversed path [19, 16, 21, 26]
expected_path = [17, 20, 13, 22]
expected_oms = [13, 16, 17, 19, 20, 21, 22, 26]
some_oms = oms_list[expected_oms[3]]
some_oms.assign_spectrum(-30, 32) # means that spectrum is occupied from indexes -62 to 1 on reversed path
params = request_set
params['effective_freq_slot'] = {'N': n, 'M': m}
rqs = [PathRequest(**params)]
paths = compute_path_dsjctn(network, equipment, rqs, [])
# check that the computed path is the expected one (independant of blocking issues due to spectrum)
path_oms = list(set([e.oms_id for e in paths[0] if not isinstance(e, (Transceiver, Roadm))]))
assert path_oms == expected_path
# function to be tested:
pth_assign_spectrum(paths, rqs, oms_list, [find_reversed_path(paths[0])])
# check that spectrum is correctly assigned
assert rqs[0].N == final_n
assert rqs[0].M == final_m
assert getattr(rqs[0], 'blocking_reason', None) == blocking_reason
def test_reversed_direction(equipment, setup, requests, services):
""" checks that if spectrum is selected on one direction it is also selected on reversed
direction

View File

@@ -19,6 +19,7 @@ commands =
pytest {env:CI_COVERAGE_OPTS:} -vv {posargs}
cover: coverage html -d cover
cover: coverage xml -o cover/coverage.xml
python setup.py bdist_wheel
[testenv:docs]
deps =