Commit Graph

28 Commits

Author SHA1 Message Date
Harald Welte a4abe20d62 NS_Emulation: Implement minimal PCU-side SNS functionality
Using this code, we can run a TTCN3 test using NS_Emulation in
IP-SNS mode.  It only covers the most basic cases but works for simple
scenarios.

Change-Id: Id1fb0fcb7a497a9614e82beb8a2c64b5af88150d
2021-04-01 21:27:33 +02:00
Harald Welte c771bfbe36 NS_Emulation: Use endpoint list for SNS-CONFIG payload
We used to have no distinction between endpoints and NSVCs, meaning
that we could not have more than one NSVC per endpoint, which in turn
meant it was ok to iterate the list of NSVCs for generating the
endpoint lists in the SNS-CONFIG payload.

With Change-Id I05a50b966b8ce93497372ca403d40fd383dd35f7 we remove that
constraint and introduce an actual local IP endpoint list.  Let's use
that one for SNS-CONFIG.

Change-Id: Ifa91510430a017fa29592a3d5fa2a3697d29c9da
2021-03-29 22:58:49 +02:00
Harald Welte ad32071825 NS_Emulation: Use the "endpoint" mode of NS_Provider_IPL4
Thew newly-introduced "endpoint" mode of NS_Provider_IPL4 allows us
to have multiple NS-VC within one endpoint.  NS_CT takes care of
creating the NS_Provider_IPL4 components on-the-fly, and then
associating the per-NSVC components with it.

For the user nothing changes, other than that he can now configure
multiple NSVCs with identical local IP + port, which was not possible
before.

Change-Id: Id7360f17e528706e8145d33a14550789d50cded9
2021-03-29 22:58:46 +02:00
Harald Welte c56800066d NS_Emulation: Work around "alive" race condition in IP-SNS
We need to modify the state of each NS-VC within a NS-VCG/NSE once
we receive the final SNS-CONFIG-ACK PDU.  However, sometimes the
IUT sends its first NS-PDU _before_ we even have communicated the
state-change locally to all our NS-VCs.

In order to avoid the problem, let's mark the NS-VCs as alive before
sending the the SNS-CONFIG.  This means we have one RTT more time
to locally propagate the state change to all NS-VCs.

Change-Id: Idac522a81f01553df52dc012cbab15e1c73c0862
Closes: OS#5023
2021-02-13 16:49:25 +01:00
Harald Welte 516c5c7250 NS_Emulation: factor-out as_ns_common_status() altstep
This is a new altstep which groups all handling of NsStatusInd.
Right now it's only used from one place, but upcoming patches
will re-use it elsewhere.

Change-Id: I4e8e7d19c764cc977beb84a6859c9ce73518b653
2021-02-13 16:49:25 +01:00
Harald Welte 3bd182f3b3 NS_Emulation: Factor-out function to broadcast to all NS_VCs
Change-Id: I8cd16031dbbd244dcff74fc8a1cd69e9f8a06dbf
2021-02-13 16:49:25 +01:00
Harald Welte daf89681c4 NS_Emulation: Avoid g_unblocked_nsvcs_* overflowing
Sometimes we run into situations where the g_unblocked_nsvcs_* is
exceeding the number of NSVCs we have in g_nsvcs.  This can only happen
as we blindly append integers to the ro_integer fields, rather than
checking if they are already contained.

Let's factor out the add_unique and del functions (in Osmocom_Types)
and use them from NS_Emulation.

Change-Id: Ib3273d6ce9b80f700c964d578fdb0f268eac6a14
2021-02-04 17:11:30 +01:00
Harald Welte aaa0dfdd3f Move "ro_integer" to Osmocom_Types
We don't need several re-definitions of a "record of integer" type,
plus associated helper functions.  Let's move that to the shared
Osmocom_Types.ttcn

Change-Id: I6a68ab8180a40b93c540db9cb80941c39c2fb549
2021-02-04 17:11:30 +01:00
Harald Welte 4998a09917 NS_Emulation: Don't respond to NS-STATUS with NS-STATUS
Change-Id: Id9544ed1a7686fe113c4f6671e482bffc84bd2cc
2021-02-04 14:58:22 +01:00
Harald Welte c0c67ff14f NS_Emulation: Handle NS_PROV_LINK_STATUS_DOWN
This happens e.g. if FrameRelay detects a "service affecting condition",
i.e. the link is considered dead.

Change-Id: I7409079f5e2b77cc08ccc93d1b0baa72720cefb8
2021-02-03 19:28:00 +01:00
Harald Welte 3f82089977 NS_Emulation: Add CTRL port to administratively disable a NS-VC
This feature is useful in simulating intermittent or permanent transport network
outage by simply halting processing of all rx+tx in the specified NS-VC
until it is administratively re-enabled.

Change-Id: I742ecf01de15e3edbf0719371f0217a5739b7c8e
RelateD: OS#4521
2021-01-25 12:48:38 +00:00
Harald Welte be7afce974 NS_Emulation: Respect data_weight==0 or signalling_weight==0
* allow configuration of signalling + data weight for each NS-VC
* advertise per-NSVC signalling/data weight in SNS-CONFIG
* keep track of unblocked NS-VCS separately for data / signalling
* transmit BVCI=0 traffic only over signalling NS-VC
* transmit BVCI>0 traffic only over data NS-VC
* accept incoming BVCI=0 traffic only if signalling_weight > 0
* accept incoming BVCI>0 traffic only if data_weight > 0

Related: OS#4953
Change-Id: I9798e639b4bc8658482945970775b012b5840779
2021-01-20 15:56:31 +01:00
Harald Welte 1308dbbd8f NS_Emulation: Move SNS handling from NS-VC to NS-VCG
We need to move the IP-SNS handling up one layer, as only the NS-VCG
knows all the other NS-VCs, and after the SNS-CONFIG-ACK, we must
mark all of our NS-VCs as alive and start the alive procedure.

Related: OS#4953
Change-Id: Ie0f4342a0346952d7c50ac36900148e311d4c782
2021-01-18 19:55:03 +01:00
Harald Welte 0b38da55c7 NS_Emulation: Dynamically compute list of v4/v6 endpoints in SNS-CONFIG
Don't hard-code the assumption that we only have a single IP[v4] endpoint.

Related: OS#4953
Change-Id: I43fe5810b95ebbc9f848856803ac2c71f80d74f3
2021-01-18 19:55:03 +01:00
Alexander Couzens 0c96ff6dba NS_Emulation: remove unused variable res
Change-Id: I5cc25ccb8e0d169b6f85e597fda47fdd2130aa70
2021-01-11 13:42:45 +00:00
Alexander Couzens d533890fa7 NS_Emulation.ttcnpp: complete SGSN emulation with SNS
The emulation of an SGSN with SNS was incomplete. The SNS
procedure was completed. However the NSVCs didn't moved
into an unblocked state.
Also sending a NS_ALIVE at the beginning is wrong.

Change-Id: I54c2d9d5b34d791be354298171d04180a9b263c3
2020-12-21 18:41:31 +01:00
Harald Welte da9d9387f6 NS_Emulation: Tolerate late NS-BLOCK-ACK / NS-UNBLOCK-ACK
Particularly in case both sides initiate a BLOCK or UNBLOCK procedure
at almost the same time, it can happen thet we're already in BLOCKED
state and receive a late BLOCK-ACK or in UNBLOCKED state and receive a
late UNBLOCK-ACK.

Let's just silently discard them instaed of generating NS-STATUS which
may confuse the peer.

Change-Id: I2e5b934e1cf6c6cf982d5ab1dbb32e8920b91071
2020-12-07 15:55:20 +01:00
Harald Welte 80a249aa07 NS_Emulation: Include NS-VCI in NsUnitdataIndication
The primitive normally only contains NSE + BVCI, but in a tester
we actually want to verify which NS-VC a given message has arrived on,
and hence it makes sense to add the NSVCI, too.

Change-Id: I9402bf0be47e5b93c9cfb081eb8f9fa6734c9227
2020-11-21 22:52:51 +01:00
Harald Welte e15299ab20 NS_Emulation: Fail if an unsupported NS provider is chosen
This took me quite some time: Tried to use NS_PROVIDER_FR, but the
code was compiled without support for it.  It just failed silently
without printing any error or ever sending any message on the FR link.

Change-Id: I96475127a2079830b3456a8e288adf4c6c908887
2020-11-17 17:42:23 +01:00
Harald Welte c450552c59 NS_Emulation: Introduce Load Sharing Function
The Load Sharing Function distributes traffic among all unblocked NS-VC
within a NS-VCG.  The sharing is done based on a LSP (Link Selector
Parameter) which is passed with the NS-UNITDATA.req primitive from BSSGP
to NS.  Details are implementation specific, but NS must ensure that all
traffic of one LSP is always sent through the same NS-VC, as long as
that NS-VC is alive/unblocked.

We use the LSP as follows:
* Signaling BVC always only uses lsp 0
* PTP BVC messages unrelated to user straffic use a per-BVC static LSP,
  which is the BVCI
* User traffic can set whatever LSP it wants
* NS keeps an array of NSVCs currently unblocked and uses the LSP modulo
  the array size as an index into it

Change-Id: I8b960ec4d729f50cadca353bb52685311cd45eed
Related: SYS#5084
2020-11-12 20:02:07 +00:00
Harald Welte dc0a090ae1 NS+BSSGP: Only send BVC-RESET when _first_ NSVC of NSVCG becomes unblocked
In case of a NS-VCG with multiple NS-VC, we must BVC-RESET only when the
first NS-VC becomes unblocked, i.e. as soon as we have any connection
to the peer at all.  Whether we have further additional links doesn't
matter, at least not in the sense that all state should be reset.

Change-Id: I69b2e9bd919fc981f189b6671b4234c3642e2449
2020-11-12 20:02:07 +00:00
Harald Welte 90f1974fb0 NS_Emulation: Support multiple NS-VC within one NSE (NS-VCG)
This is something we need to simulate more complex scenarios,
particularly in the context of frame relay.

Change-Id: If1220852785853f8a5d8de183d5053ddd6ccb958
2020-11-12 20:02:07 +00:00
Daniel Willmann 654f85e2b8 Correctly handle ALIVE/TEST procedure with FR/NS-over-IP without SNS
If IP-SNS is not used we should wait for the RESET procedure to finish
before sending NS-ALIVE.
For IP-SNS start NS-ALIVE in both roles (sgsn and bss) and don't handle
NS-RESET.

Also unified the log messages a bit (received -> Rx).

Related: SYS#5002
Change-Id: Ie01fee70297255b3d9c091bc2cec75b0f915c588
2020-10-15 10:48:34 +02:00
Harald Welte 847a77e32f NS_Emulation: pass around string idenifier for components created
We want to see useful identification for components in the log, and
hence must be giving every component a name at create() time.

Change-Id: I0fe650243953e4d85161684865acd0354b2e465f
2020-10-03 18:27:05 +02:00
Harald Welte 3dd8355d7d NS_Emulation: Delay Tx of first NS-RESET until Provider tells us it's up
Change-Id: I300cfeb120540940990a834596b0a83a539df080
2020-10-03 18:27:05 +02:00
Harald Welte 4a6a663654 NS_Emulation: Refactor if/elseif/... clause to altsteps with guard
This makes for much more readable code, and we can even do without
activating any default altsteps.

Change-Id: I4c38dd55b7c27899735f5730851d36c1410d96a8
2020-10-03 18:27:05 +02:00
Harald Welte bd612cd328 NS_Emulation: Introduce status events from provider -> emulation
This allows NS_Emulation to react to changes of the underlying
transport layer (e.g. Frame Relay Link/DLCI up).

Change-Id: If00e9c50dc664ce62b6c0cbde99d741e8173169b
2020-10-03 18:26:59 +02:00
Harald Welte 867243a3ec NS_Emulation: Add [optional] support for FrameRelay transport
This adds a NS_Provider_FR which interfaces between FrameRelay_Emulation
and NS_Emulation.  Include support for it only if enabled at compile
time to avoid pulling in a dependency on the FrameRelay stack for every
user of NS_Emulation.

Change-Id: I42ca811d23e383e362d2527c8ff2c916a62a5b42
2020-10-03 18:24:50 +02:00