Commit Graph

98 Commits

Author SHA1 Message Date
Alexander Huemer 7b6673fa06 Consistenly format variables in */Makefile.am files
Change-Id: Ifa21513c007072314097b7bec188579972dc1694
2016-09-15 15:55:02 +02:00
Neels Hofmeyr 29048b2a80 rm dup: use channel type names from libosmocore
In gsm_lchant_name(enum gsm_chan_t), use the gsm_chan_t_names value strings
from libosmocore instead of redefining the same strings. The list from
libosmocore is also more complete, including CCCH and PDTCH.

Add a todo comment to move to libosmocore.

In consequence, libosmogsm linkage needs to be added to osmo-bsc_mgcp,
mgcp_test, mgcp_transcoding_test and smpp_mirror, smpp_test.

Change-Id: If65ee7c0619cbc0acb0a15045bd5a969442c93cc
2016-06-18 11:34:21 +00:00
Pablo Neira Ayuso 11cb27ece6 mgcp_osmux: available circuit IDs from 0 to 255, not from 0 to 128
Holger reports that the bitmap that accounts for available Osmux circuit
IDs is limited to 128, when the maximum number of circuit IDs are
determined by the uint8_t field in the header (ie. 256 circuits).

[hfreyther: Update the testcase now that we have more ids to allocate]
2015-11-02 13:26:26 +01:00
Holger Hans Peter Freyther b45e4d80b6 osmux: Do not divide the number of bytes by eight.
sizeof(uint8_t) == 1 and there is no need to create an array
with 16 bytes and then only use the first two of them. This
means the CID range is from 0 to 127 and we should be able
to extend this to 256 by changing the array size to 32. Update
the testcase now that we can have more than 16 calls with Osmux.
2015-10-12 09:11:25 +02:00
Holger Hans Peter Freyther 641d387409 osmux: Test cid allocation and de-allocation
* Test that one can get an id
* That they are assigned predicatble right now
* That returning them will make the number of used ones go down
* That allocating more will fail
2015-10-12 09:11:25 +02:00
Holger Hans Peter Freyther 4c97435b35 mgcp: Test we don't crash on the NAT dummy MGCP message
We want the port and IPv4 address to be extracted but don't
expect any change in audio codecs.
2015-08-17 15:50:01 +02:00
Holger Hans Peter Freyther d17bc7b3a8 mgcp: Avoid crashing when rtpmap is not complete
The NAT sends an incomplete SDP file for the purpose of informing
the BSC about the remote IP/PORT early. The case of an incomplete
SDP file was not considered. Check if there is a codec and if not
skip it.

TODO: We need to have a better end-point life cycle test.
2015-08-17 15:22:30 +02:00
Holger Hans Peter Freyther aeadf261e5 mgcp: Allow to enforce that the codecs need to match
We have a lot of legacy that I am afraid to break. We have
everything in place to make a good codec selection (e.g. if
we can avoid transcoding, pick the one with best quality or
the lowest speed). Right now I have a specific case where
from all options I want to pick GSM. Guard the codec compat
check behind the disallow transcoding option to make sure
to not break legacy application.
2015-08-14 15:43:06 +02:00
Holger Hans Peter Freyther b69518f383 configure: Do not link all applications against libgsm
Use the same trick as done by the dlopen check to not
have everyone link against the library.
2015-07-02 09:51:31 +02:00
Andreas Rottmann b25c8342cc Fix build wrt. missing CFLAGS constituents
When libosmo-netif and/or libosmo-abis are installed in distinct
prefixes, the build failed with non-found headers.
2015-06-19 20:56:53 +02:00
Jacob Erlbeck ddc0e05604 mgcp/test: Fix mgcp-transcoding assertion (Coverity)
In test_rtp_seq_state an assignment is accidently done within an
assertion.

This commit changes that into a comparison as it was intended.

Fixes: Coverity CID 1295457, 1295458
Sponsored-by: On-Waves ehf
2015-04-29 14:02:40 +02:00
Holger Hans Peter Freyther 7ce72c1be8 rtp: And really catch up and remove all occurences of openbsc/rtp.h 2015-03-22 14:43:19 +01:00
Holger Hans Peter Freyther b1edf7b64f mgcp/sdp: Session name must not be empty pick an empty one
The session name must be present in a SDP file. The RFC proposes
to use a space for it but the other equipment is using the dash
so I have picked that as well.

RFC 4566:
The "s=" field is the textual session name.  There MUST be one and
only one "s=" field per session description.  The "s=" field MUST NOT
be empty and SHOULD contain ISO 10646 characters (but see also the
"a=charset" attribute).  If a session has no meaningful name, the
alue "s= " SHOULD be used (i.e., a single space as the session
name).

Fixes: RT#2196
2014-11-20 23:17:32 +01:00
Holger Hans Peter Freyther 619b014d3a mgcp: Allow to omit sending the audio name at all
Equipment like AudioCode appears to get upset when we use a
builtin type and then assign a name to it. Allow to completely
omit the name.
2014-11-19 16:18:56 +01:00
Holger Hans Peter Freyther 7b76f82b6e mgcp: Count the incoming data instead of the modified one
For jitter, transit and packet loss we should count the data
that arrived and not the data we send towards the remote. This
is changing the jitter timings to what they were before the
re-factoring.

For forced timing we might willingly add jumps in the sequence
number but for jitter and packet loss we are more interested
in the data that traveled through the wire/air.
2014-10-09 17:22:33 +02:00
Holger Hans Peter Freyther 05d481a42c mgcp: Do not detect the initial package as a wrap around
The Annex A code has a probation period but we don't have it. When
starting with seq_no==0 do not assume that the sequence numbers
have wrapped. Do it by moving the entire checking code into the
else.
2014-10-09 17:22:33 +02:00
Holger Hans Peter Freyther a5a59c9a05 mgcp: Move Annex A counting out of patch/count method
mgcp_patch_and_count has grown due supporting linearizing timestamps,
ssrc and other things for equipment like the ip.access nanoBTS. Fight
back and move the Annex A code into a dedicated method.

The result is updated as we now count after all the patching and for
the Annex A code no change in SSRC can be detected.
2014-10-09 17:22:33 +02:00
Holger Hans Peter Freyther 0169971a59 mgcp: Re-load the state after the transcoding change
Jacob ran the tests with ASAN and noticed that the state is
dead. This is on purpose as we have forced a change in the
transcoding. Re-load the state and verify that it has not
changed in the other cases.
2014-09-05 12:25:32 +02:00
Holger Hans Peter Freyther 0454e32861 mgcp: Use l16 in the test
G729 might not be available, so execute the test with codecs that
are always available.
2014-09-02 12:16:22 +02:00
Holger Hans Peter Freyther 4680121fe6 mgcp: Deal with receiving another payload type
In case we get offered G729 and G711 we might have selected
G729 as the audio codec. The first packet we receive might be
G711 though. In that case we will need to change. But only if
we have a matching alternate codec payload_type. E.g. in the
case of comfort noise we will receive the PT=11 and we don't
want to change.
2014-09-02 09:27:45 +02:00
Holger Hans Peter Freyther e46bc2714d mgcp: Store one more codec/payload type if it is present
In case of some RTP proxy from time to time we are offered both
G729 and G711 but only one of them will work. I intend to adjust
the codec at runtime in case we receive the wrong codec.
2014-09-02 09:22:19 +02:00
Holger Hans Peter Freyther cac2438b0c mgcp: Move the "codec" params to a struct
We might be offered multiple codecs by the remote and need to
switch between them once we receive data. Do this by moving it
to a struct so we can separate between proposed and current
codec. In SDP we can have multiple codecs but a global ptime.
The current code doesn't separate that clearly instead we write
it to the main codec.
2014-09-02 08:25:49 +02:00
Holger Hans Peter Freyther cb6ad70994 mgcp: Change API to remove memory management from the name
Jacob pointed out that "free_endp" refers to the memory of
the endpoint being freed. What we want is actually a way to
release an endpoint (and the resource it allocated) or in
the case of the testcase/testapp initialize the data structure
correctly. Introduce two names for that.
2014-07-22 15:00:52 +02:00
Holger Hans Peter Freyther b936278b2e mgcp: Fix/test the case of a time jump and the resync
In case the sender didn't send a couple of frames we will have
a time gap that is bigger than the accepted delta. Add a new
testcase for this and update the next_time.
2014-07-22 14:48:07 +02:00
Holger Hans Peter Freyther 4c18d79475 mgcp: Add a testcase for 160->80 ptime handling 2014-07-22 14:48:07 +02:00
Holger Hans Peter Freyther c8b29083d2 mgcp: Initialise next_time in case the initial timestamp is not 0. 2014-07-22 14:48:07 +02:00
Holger Hans Peter Freyther bd4109babc mgcp: Document transcoding semantic and follow it
Transcoding from GSM to PCMA can lead to the MGCP MGW sending
two PCMA packages with the same sequence number and timestamp.
Once with the encoded audio and once completely empty.

This is because "state->dst_packet_duration" is 0 in most cases
(unless a ptime is forced) and we attempt to encode audio even
if there are not enough samples. The encode_audio return will
return 0 in that case which is not trated as an error by the
mgcp network code.

Handle rc == 0 specially and document the semantic.
2014-07-22 14:42:53 +02:00
Holger Hans Peter Freyther 91eeeae312 mgcp: Fix/test reading/writing the sequence number
The sequence number was read from the wrong place and then
the wrong byte order conversion routine was used so we ended
up wirting 0x00, 0x00 into the patched sequence number. Add
a testcase for that.
2014-07-22 14:31:35 +02:00
Holger Hans Peter Freyther 4fb7e64da2 mgcp: Capture the return value of the of the transcode function 2014-07-22 13:12:12 +02:00
Holger Hans Peter Freyther 6041c8db27 mgcp: Do not use errx as finding a test failure is too hard
It took me a long time to figure out that errx just exits and
the test output didn't indicate that the application was exited
early. Use a printf and good old abort in case of a failure.
2014-07-22 13:12:05 +02:00
Holger Hans Peter Freyther 83cbac2ac0 mgcp: Re-factor testcase to separate test and setup
Separate the test from the code necessary for the setup. This is
somehow inspired by the PhExample framework of Pharo.
2014-07-22 13:11:59 +02:00
Jacob Erlbeck cb04ca2fc3 mgcp: Fix SDP formatting of fmtp_extra (Coverity)
Currently when ftmp_extra is set, a doubled a=rtpmap line is emitted
instead of the fmtp_extra info.

This patch fixes replaces the formerly copied and pasted but not
modified snprintf parameters by the correct ones.

Fixes: Coverity CID 1220873
Sponsored-by: On-Waves ehf
2014-06-15 19:15:32 +02:00
Jacob Erlbeck bebf92d7f0 mgcp/test: Add test case using the fmtp_extra info
Add tests setting the fmtp_extra field to check the response
generation. This triggers a bug found by Coverity.

Addresses: Coverity CID 1220873
Sponsored-by: On-Waves ehf
2014-06-15 19:15:09 +02:00
Jacob Erlbeck 452c183c5e mgcp: Set net_end audio params in recvonly mode
Currently, if there is no SDP data in the MGCP message received from
the net, the fields containing audio encoding information are not set
in net_end. So in recvonly mode transcoding would not be set up
correctly.

This patch changes the implementation of the code handling CRCX and
MDCX to use the codec signalled in the MGCP local connection options
(field 'a:') if there isn't any SDP data. This is only halfway
negotiation, because the codec is used blindly and not matched
against the supported ones.

Sponsored-by: On-Waves ehf
2014-06-05 14:09:52 +02:00
Jacob Erlbeck 909fac6689 mgcp: Move transcoding to libmgcp
This patch moves the files relevant to transcoding from
src/osmo-bsc_mgcp to src/libmgcp and src/include/openbsc. Makefiles
and include directives are being updated accordingly.

Sponsored-by: On-Waves ehf
2014-06-05 14:08:53 +02:00
Jacob Erlbeck 84a45cbf83 mgcp/test: Add test cases for transcoding and repacking
This patch adds test cases for transcoding and repacking.

Sponsored-by: On-Waves ehf
2014-06-05 14:08:53 +02:00
Holger Hans Peter Freyther 1cc5ff8e19 mgcp: Add proper length checking for line handling
In ae1997248c the handwritten tokenizer
was replaced with strtok_r. As part of this change the structural
checking of MGCP parameters was stopped. This means that a code like
"line + 3" might access beyond the first NUL and be possibly behind
the msgb. Manually add size checking again. Manually jumping to the
error label is not possible anymore as it has been removed. The result
is that invalid lines will be skipped. This is matching the general
approach by the IETF RFCs to be permissive in data being received.
2014-05-22 16:46:11 +02:00
Pablo Neira Ayuso cab6e7528c mgcp: add voice muxer support
This patch adds the voice muxer. You can use this to batch RTP
traffic to reduce bandwidth comsuption. Basically, osmux transforms
RTP flows to a compact batch format, that is later on decompacted
to its original form. Port UDP/1984 is used for the muxer traffic
between osmo-bsc_nat and osmo-bsc_mgcp (in the BSC side). This
feature depends on libosmo-netif, which contains the osmux core
support.

Osmux is requested on-demand via the MGCP CRCX/MDCX messages (using
the vendor-specific extension X-Osmux: on) coming from the BSC-NAT,
so you can selectively enable osmux per BSC from one the bsc-nat.cfg
file, so we have a centralized point to enable/disable osmux.

First thing you need to do is to accept requests to use Osmux,
this can be done from VTY interface of osmo-bsc_nat and
osmo-bsc_mgcp by adding the following line:

mgcp
  ...
  osmux on
  osmux batch-factor 4

This just initializes the osmux engine. You still have to specify
what BSC uses osmux from osmo-bsc_nat configuration file:

...
 bsc 1
  osmux on
 bsc 2
  ...
 bsc 3
  osmux on

In this case, bsc 1 and 3 should use osmux if possible, bsc 2 does
not have osmux enabled.

Thus, you can selectively enable osmux depending on the BSC, and
we have a centralized point for configuration from the bsc-nat to
enable osmux on demand, as suggested by Holger.

At this moment, this patch contains heavy debug logging for each
RTP packet that can be removed later to save cycles.

The RTP ssrc/seqnum/timestamp is randomly allocated for each MDCX that
is received to configure an endpoint.
2014-05-22 14:39:16 +02:00
Holger Hans Peter Freyther cdfc2061bb mgcp: Round the frame time otherwise we have porting issues
With the current multiplication we might end up with 19999 as
time on i386. When we round it ends up as 20000 on i386 and
should work the same on AMD64.
2014-02-03 13:32:34 +01:00
Holger Hans Peter Freyther ba41978b97 mgcp: transit is a signed variable and should be printed like this
On AMD64 we had a difference in the test result most likely due
the bigger size of integers.
2014-02-03 09:20:06 +01:00
Holger Hans Peter Freyther 757971ade8 mgcp: Use the length modifier for the size_t in the printf
Should fix on AMD64:
mgcp_test.c: In function ‘sendto’:
mgcp_test.c:318:10: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat]
2014-02-03 09:18:51 +01:00
Jacob Erlbeck b281e4e6f4 mgcp/rtp: Base jitter calculation on input timestamps
So far, the jitter computation has been based on output timestamps.

This patch uses the input timestamps instead and resets jitter
computation on SSRC changes.

Sponsored-by: On-Waves ehf
2014-01-31 11:45:25 +01:00
Jacob Erlbeck eacc9b92a1 mgcp/rtp: Compute delta timestamp based on wallclock
Currently, when the SSRC changes within a stream and SSRC fixing is
enabled, the RTP timestamp between the last packet that has been
received with the old SSRC and the first packet of the new SSRC
is always incremented by one packet duration.
This can lead to audio muting (at least with the nanoBTS) when the
wallclock interval between these packets is too large (> 1s).

This patch changes the implementation to base the RTP timestamp offset
on the wallclock interval that has passed between these two packets.

Ticket: OW#466
Sponsored-by: On-Waves ehf
2014-01-31 11:44:16 +01:00
Jacob Erlbeck 303b54a2a4 mgcp/rtp: Fix transit computation units
Currently micro-secs and RTP rate get mixed when the transit value is
computed in mgcp_patch_and_count().

This patch changes get_current_ts() to accept the desired rate as
argument and to use it for the time conversion instead of always
converting to microseconds. If microseconds are needed,
get_current_ts(1000) can be used.
The arrival_time is now measured in 1/rtp_end->rate seconds so that
it can be directly compared to RTP timestamps as required by RFC3550
(section 6.4.1, see definition of 'interarrival jitter').

Sponsored-by: On-Waves ehf
2014-01-31 11:18:25 +01:00
Jacob Erlbeck e763f3e73e mgcp/test: Fake wallclock for RTP timing/stats tests
Currently the stats (jitter, transit) cannot be checked properly,
since they depend on the wallclock time.

This patch fakes clock_gettime (CLOCK_MONOTONIC) to reflect the
scheduling time of the RTP packets. In addition, the RTP statistical
value are written to stdout.
A RTP test case with a SSRC change along with a reference time delay
has been added.

Sponsored-by: On-Waves ehf
2014-01-31 11:18:25 +01:00
Jacob Erlbeck cf577c3492 mgcp/test: Only include conn_mode into test output
Currently the conn_mode and the output_enabled flags are printed to
stdout.

This patch modifies this to print the output_enabled flags to stderr
instead. The bits in conn_mode are shown as RECV, SEND, and LOOP.
This does not reduce the significance of the test, since there is an
assertion already that verifies the values of the output_enabled
flags with respect to the conn_mode.

Sponsored-by: On-Waves ehf
2014-01-31 11:18:25 +01:00
Jacob Erlbeck ead0529e07 mgcp/test: Don't reset conn_mode between messages
Currently, the conn_mode field is reset after it has been checked.

This patch disables this behaviour and only adds a mark (bit) to
detect modifications.

Sponsored-by: On-Waves ehf
2014-01-20 08:27:03 +01:00
Jacob Erlbeck e35fd13697 mgcp: Synchronize conn mode bits and output enabled flags
This patch changes implementation and the mgcp_connection_mode enum
in a way that net_end.output_enabled (bts_end.output_enabled) flag
always matches the MGCP_CONN_SEND_ONLY (MGCP_CONN_RECV_ONLY) bit of
conn_mode.

Based on this, the conn_mode bits are then used instead of the
output_enabled fields within mgcp_protocol.c.

Sponsored-by: On-Waves ehf
2014-01-20 08:27:03 +01:00
Jacob Erlbeck 8857c90e36 mgcp: Disable output enabled on initialisation
Currently RTP output_enabled is set to 1 on initialisation, which
does not semantically match the initial value of conn_mode
(MGCP_CONN_NONE).

This patch changes this initial value to 0.

Sponsored-by: On-Waves ehf
2014-01-20 08:27:03 +01:00
Jacob Erlbeck 075a9ebdcc mgcp: Send RTP keepalive dummy packets to net
So far, a single dummy packet has been sent immediately after the
reception of a MDCX message. There is no dedicated keep alive
mechanism (it just worked because the audio from the MS has always
been forwarded to the NAT until the 'mgcp: Set output_enabled flags
based on the MGCP mode' patch).

This patch adds explicit, timer based keep alive handling that can be
enable per trunk. A VTY command 'rtp keep-alive' command is added for
configuration which can be used to set the interval in seconds, to
send a single packet after the reception of a CRCX/MDCX when RTP data
from the net is expected ('once'), or to disable the feature
completely ('no rtp keep-alive'). In 'send-recv' connections, only
the initial packet is sent if enabled (even when an interval has been
configured). The default is 'once'.

Note that this removes the mgcp_change_cb() from mgcp_main.c.

Sponsored-by: On-Waves ehf
2014-01-16 13:20:51 +01:00