aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests/mgcp
AgeCommit message (Collapse)AuthorFilesLines
2015-04-29mgcp/test: Fix mgcp-transcoding assertion (Coverity)Jacob Erlbeck1-1/+1
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-03-22rtp: And really catch up and remove all occurences of openbsc/rtp.hHolger Hans Peter Freyther1-1/+3
2014-11-20mgcp/sdp: Session name must not be empty pick an empty oneHolger Hans Peter Freyther1-0/+7
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-19mgcp: Allow to omit sending the audio name at allHolger Hans Peter Freyther2-0/+52
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-10-09mgcp: Count the incoming data instead of the modified oneHolger Hans Peter Freyther1-36/+36
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-09mgcp: Do not detect the initial package as a wrap aroundHolger Hans Peter Freyther2-0/+41
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-09mgcp: Move Annex A counting out of patch/count methodHolger Hans Peter Freyther2-41/+41
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-09-05mgcp: Re-load the state after the transcoding changeHolger Hans Peter Freyther1-0/+3
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-02mgcp: Use l16 in the testHolger Hans Peter Freyther2-8/+8
G729 might not be available, so execute the test with codecs that are always available.
2014-09-02mgcp: Deal with receiving another payload typeHolger Hans Peter Freyther2-0/+62
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-02mgcp: Store one more codec/payload type if it is presentHolger Hans Peter Freyther2-2/+125
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-02mgcp: Move the "codec" params to a structHolger Hans Peter Freyther2-12/+12
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-07-22mgcp: Change API to remove memory management from the nameHolger Hans Peter Freyther2-7/+2
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-22mgcp: Fix/test the case of a time jump and the resyncHolger Hans Peter Freyther1-0/+47
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-22mgcp: Add a testcase for 160->80 ptime handlingHolger Hans Peter Freyther1-0/+19
2014-07-22mgcp: Initialise next_time in case the initial timestamp is not 0.Holger Hans Peter Freyther1-4/+6
2014-07-22mgcp: Document transcoding semantic and follow itHolger Hans Peter Freyther2-15/+81
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-22mgcp: Fix/test reading/writing the sequence numberHolger Hans Peter Freyther2-7/+59
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-22mgcp: Capture the return value of the of the transcode functionHolger Hans Peter Freyther2-192/+205
2014-07-22mgcp: Do not use errx as finding a test failure is too hardHolger Hans Peter Freyther1-6/+12
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-22mgcp: Re-factor testcase to separate test and setupHolger Hans Peter Freyther1-54/+64
Separate the test from the code necessary for the setup. This is somehow inspired by the PhExample framework of Pharo.
2014-06-15mgcp: Fix SDP formatting of fmtp_extra (Coverity)Jacob Erlbeck1-24/+0
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-15mgcp/test: Add test case using the fmtp_extra infoJacob Erlbeck2-0/+69
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-05mgcp: Set net_end audio params in recvonly modeJacob Erlbeck2-0/+12
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-05mgcp: Move transcoding to libmgcpJacob Erlbeck2-2/+2
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-05mgcp/test: Add test cases for transcoding and repackingJacob Erlbeck3-3/+927
This patch adds test cases for transcoding and repacking. Sponsored-by: On-Waves ehf
2014-05-22mgcp: Add proper length checking for line handlingHolger Hans Peter Freyther1-0/+1
In ae1997248ccb4fba1394267d3051082dfd85448a 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-22mgcp: add voice muxer supportPablo Neira Ayuso1-1/+1
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-02-03mgcp: Round the frame time otherwise we have porting issuesHolger Hans Peter Freyther3-70/+71
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-03mgcp: transit is a signed variable and should be printed like thisHolger Hans Peter Freyther2-89/+89
On AMD64 we had a difference in the test result most likely due the bigger size of integers.
2014-02-03mgcp: Use the length modifier for the size_t in the printfHolger Hans Peter Freyther1-1/+1
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-01-31mgcp/rtp: Base jitter calculation on input timestampsJacob Erlbeck1-78/+78
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-31mgcp/rtp: Compute delta timestamp based on wallclockJacob Erlbeck1-8/+8
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-31mgcp/rtp: Fix transit computation unitsJacob Erlbeck1-116/+116
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-31mgcp/test: Fake wallclock for RTP timing/stats testsJacob Erlbeck2-0/+184
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-31mgcp/test: Only include conn_mode into test outputJacob Erlbeck2-15/+24
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-20mgcp/test: Don't reset conn_mode between messagesJacob Erlbeck2-3/+2
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-20mgcp: Synchronize conn mode bits and output enabled flagsJacob Erlbeck1-7/+26
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-20mgcp: Disable output enabled on initialisationJacob Erlbeck1-2/+2
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-16mgcp: Send RTP keepalive dummy packets to netJacob Erlbeck1-0/+6
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-16mgcp: Set output_enabled flags based on the MGCP modeJacob Erlbeck1-7/+7
This patch enhances parse_conn_mode() to set the output_enabled flags of each end based on the MGCP mode. Ticket: OW#1044 Sponsored-by: On-Waves ehf
2014-01-16mgcp/test: Show the number of dummy packets sentJacob Erlbeck2-1/+34
This patch extends the test_messages test to show the number of dummy packets that has been passed to sendto(). This way, dummy packets are even being counted when sendto() itself failes (e.g. due to the fd being -1). Sponsored-by: On-Waves ehf
2014-01-16mgcp/test: Reset pkt_period_* after each testJacob Erlbeck2-1/+3
Currently these value may leak into the next test. This patch will reset them after each message has been processed. Sponsored-by: On-Waves ehf
2014-01-16mgcp/test: Test the connection mode parserJacob Erlbeck2-3/+50
This modifies the test MGCP messages to include M:recvonly (CRCX), M:sendrecv (MDCX) and M:sendonly (MDCX) outputs the resulting output_enabled flags and the conn_mode after processing the message. Sponsored-by: On-Waves ehf
2013-12-19mgcp/rtp: Only patch timestamp alignment errorsJacob Erlbeck2-23/+23
Currently, all timestamps are force to SeqNo*d + C which is more than required by the nanoBTS which seems to be sensitive to alignment errors only (dTS != k*d, d = ptime * rate = 160). This patch replaces the force_constant_timing feature by a force_aligned_timing feature. The timestamp offset will only be changed (and timestamp errors counted) when the alignment does not match to the raster based on ptime (default 20ms). The VTY interface does not change. Sponsored-by: On-Waves ehf
2013-12-19mgcp/test: Use differential output for counters and timestampJacob Erlbeck2-112/+236
Currently the counter and output timestamp values are written out for each packet. This makes it difficult to see in the diffs what has been changed significantly. This patch changes this by showing differences for those values. The absolute input values are also shown now. In addition, the sequence numbers (the difference for the output value) are written, too. Sponsored-by: On-Waves ehf
2013-12-19mgcp/test: Add test cases for constant RTP sequence numberJacob Erlbeck2-5/+49
This adds two test cases: 1. Packet repetition (dSeq=0, dTS=0) 2. Broken seqNo (dSeq=0, dTS=160) The second had been already present in the test cases, but it was a mere copy&paste mistake which turned out to be rather helpful. This patch therefore turns it into a documented test case. Sponsored-by: On-Waves ehf
2013-12-13mgcp: Optionally send ptime in SDPJacob Erlbeck1-4/+15
Currently the SDP 'ptime' media attribute is never set in generated MGCP responses. This patch optionally includes the 'ptime' attribute if packet_duration_ms is != 0. This behaviour can be enabled/disabled by using the VTY command "sdp audio-payload send-ptime" (enabled by default). Sponsored-by: On-Waves ehf
2013-12-13mgcp: Parse SDP to get rate and packet durationJacob Erlbeck1-5/+5
This patch parses the 'ptime' and 'maxptime' SDP attributes, and the SDP rate information and sets up packet_duration_ms accordingly. If the packet duration is unknown or allows for different values (e.g. because 'ptime' uses a range or 'maxptime' allows for more than one frame) the duration is set to 0. Sponsored-by: On-Waves ehf
2013-12-13mgcp: Put local connection options into a structJacob Erlbeck2-5/+12
Currently the local connection options have been stored as a string. This patch replaces this string by a struct (that still contains a string) along with the parsed fields (only the packetization period at the moment). It also re-adds the calls to set_local_cx_options() to the handle_create_con() and handle_modify_con() functions. Except for the test program this has no side effects, since the LCO values aren't used yet.