Commit Graph

36 Commits

Author SHA1 Message Date
Jacob Erlbeck f6ec0e9fc4 mgcp/rtp: Refactored packet_duration computation
Since the packet duration is given in ms with the 'ptime' RTP media
attribute and also with the 'p' MGCP local connection option, the
computation is changed to use this value (if present). The
computation assumes, that there are N complete frames in a packet and
takes into account, that the ptime value possibly had been rounded
towards the next ms value (which is never the case with a frame length
of exact 20ms).

Sponsored-by: On-Waves ehf
2013-12-10 11:17:44 +01:00
Jacob Erlbeck 58340e5b5b mgcp/rtp: Fix RTP timestamps if enabled
This forces the output timing to fulfill
   dTS = dSegNo * fixedPacketDuration
where dSegNo = seqNo - lastSeqNo.

If timestamp patching is enabled, the output timestamp will be set
to lastTimestamp + dTS. This kind of relative updating is used to
handle seqNo- and timestamp-wraparounds properly.

The updating of timestamp and SSRC has been separated and the patch
field of mgcp_rtp_state has been renamed to patch_ssrc to reflect
it's semantics more closely. The offset fields are now used always
and will change the corresponding header field if they are != 0.

Ticket: OW#1065
Sponsored-by: On-Waves ehf
2013-12-10 11:17:44 +01:00
Jacob Erlbeck e2292f3aa1 mgcp/rtp: Only patch SSRC once after MDCX if enabled
Currently the output SSRC is always forced to be the same if SSRC
patching is enabled.

This patch modifies this to optionally restrict the number of SSRC
changes that will be corrected.

Note that the configuration only allows for the 'once' mode and 'off'.

Sponsored-by: On-Waves ehf
2013-12-10 11:17:42 +01:00
Jacob Erlbeck 3da9e4e441 mgcp/rtp: Use SSRC in proper byte ordering
The ssrc has been used without respect to proper byte ordering in
mgcp_patch_and_count(). This only affected log messages.

This patch introduces a new variable 'ssrc' that takes the value of
the SSRC in proper byte order.

Sponsored-by: On-Waves ehf
2013-12-10 11:13:22 +01:00
Jacob Erlbeck 30ce42250f mgcp/rtp: Compute default packet duration at state initialisiation
This patch adds a packet_duration field to mgcp_rtp_state which
contains the RTP packet's duration in RTP timestamp units or 0, when
the duration is unknown or not fixed.

Sponsored-by: On-Waves ehf
2013-12-10 11:13:22 +01:00
Jacob Erlbeck b35a77751b mgcp/rtp: Only update RTP header field offsets if enabled
Currently seq_offset and timestamp_offset are updated on each SSRC
change even when SSRC patching is not allowed.

This patch fixes this by changing mgcp_patch_and_count() to only
update these fields when SSRC patching is allowed.

Sponsored-by: On-Waves ehf
2013-12-10 11:13:22 +01:00
Jacob Erlbeck 5e9549e6a9 mgcp/rtp: Change the log message shown when the SSRC changes
Show old and new SSRC. Move logging command upward to show the values
immediately after the change has been detected and before any fixing
attempt is made.

Sponsored-by: On-Waves ehf
2013-12-10 11:13:22 +01:00
Jacob Erlbeck db2d431697 mgcp/rtp: Add RTP header patch mode configuration
This adds datastructures and a VTY frontend to configure the
different type of RTP header patching: SSRC and timestamp.

Note that timestamp patching is not yet implemented.

Sponsored-by: On-Waves ehf
2013-12-10 11:11:42 +01:00
Jacob Erlbeck 55ba140da1 mgcp/rtp: Fix output timing error counter
The tsdelta computation and error detection didn't handle the
intialisation phase properly.

This patches fixes this by skipping the output timing validation
when the SSRCs don't match.

Sponsored-by: On-Waves ehf
2013-12-05 16:55:39 +01:00
Jacob Erlbeck 72c309021a mgcp/rtp: Fix timestamp offset when patching RTP packets
The current implementation increments the seqno but does not increment
the RTP timestamp, leading to two identical timestamps following one
after the other.

This patch fixes this by adding the computed tsdelta when the offset
is calulated. In the unlikely case, that a tsdelta hasn't been
computed yet when the SSRC changes, a tsdelta is computed based on
the RTP rate and a RTP packet duration of 20ms (one speech frame per
channel and packet). If the RTP rate is not known, a rate of 8000 is
assumed.

Note that this approach presumes, that the per RTP packet duration
(in samples) is the same for the last two packets of the stream being
replaced (the first one).

Sponsored-by: On-Waves ehf
2013-11-25 18:30:50 +01:00
Jacob Erlbeck d62419b574 mgcp/rtp: Add test case for RTP timestamp patching and stats
This patch adds a test case to check, whether RTP timestamps are
generated properly after SSRC changes and whether the error counters
work properly.

Sponsored-by: On-Waves ehf
2013-11-25 18:13:35 +01:00
Jacob Erlbeck 50079a1843 mgcp/rtp: Add counter for invalid RTP timestamp deltas
This patch modifies the patch_and_count() function to check for RTP
timestamp inconsistencies. It basically checks, whether dTS/dSeqNo
remains constant. If this fails, the corresponding counter is
incremented. There are four counter for this: Incoming and outgoing,
each for streams from the BTS and the net.

Note that this approach presumes, that the per RTP packet duration
(in samples) remains the same throughout the entire stream. Changing
the number of speech frames per channel and packet will be detected
as error.

In addition, the VTY command 'show mgcp' is extended by an optional
'stats' to show the counter values, too.

Ticket: OW#964
Sponsored-by: On-Waves ehf
2013-11-25 18:07:21 +01:00
Pablo Neira Ayuso d81fec021e libmgcp: attach mgcp_ prefix to udp_send
This patch is a cleanup.
2013-08-27 12:21:24 +02:00
Pablo Neira Ayuso 66b52c1df8 libmgcp: add mgcp prefix to functions and constants
Functions and constants that belong to the libmgcp scope are prefixed
with mgcp_ and MGCP_. This patch is a cleanup.
2013-08-14 16:20:37 +02:00
Pablo Neira Ayuso 46bd4244a1 libmgcp: add enum mgcp_type and use it
This patch replaces the field 'is_transcoded' in the mgcp_endpoint
structure by the enum mgcp_type, that can be further extended with
new types.
2013-07-08 16:46:06 +02:00
Holger Hans Peter Freyther 7e7ee5f8c6 mgcp: Fix the vary large jump detection in the code
GCC 3.x on PowerPC correctly highlights that the code is fishy.
Re-reading the RFC 3550 shows that we should subtract it and then
we are in the 16bit range. The probation and re-sync code is still
missing.

GCC:
mgcp/mgcp_network.c:200: warning: comparison is always true due to limited range of data type
2012-12-16 13:11:50 +01:00
Holger Hans Peter Freyther eedb45362d mgcp: Print both receivd and expected address in the error statement
The log statement is split into two because inet_ntoa works on an
internal buffer and would print the last address twice.
2012-11-12 10:55:29 +01:00
Holger Hans Peter Freyther cb306a689e mgcp: Send the jitter statistics at the end of the call 2012-11-12 10:45:09 +01:00
Holger Hans Peter Freyther 30690adbc8 mgcp: Calculate the jitter with the formula/code from the appendix
Use a usec timestamp for the local time. The seconds to usec will
swap over to the lower bits but this appears to be correct. The
CLOCK_MONOTONIC is used to fulfill the RFC 3550 requirement even
if it is a bit slower than the gettimeofday.

Make sure to initialize transit in a way that the first transit
time will be 0. Otherwise the jitter will contain the difference
of the localtime and the remote time.
2012-11-12 10:45:03 +01:00
Holger Hans Peter Freyther 38e02c5125 mgcp: Calculate the packet loss as of Appendix A of RFC 3550
Calculate the expected packages and packet loss as of RFC 3550.
The values should be clamped but our packet loss counter is 32
bits and not 24 and we should clamp at other values but I am
waiting for some issues first before dealing with that.
2012-11-12 10:44:58 +01:00
Holger Hans Peter Freyther 769912c9e9 mgcp: Calculate the wrap around as of Appendix A in RFC 3550
This is missing the probation and the dealing with a remote
restart. For the remote restart we will simply write a log
statement as this is unlikely to happen during a call or if
it does happen the call will be taken down by the BSC anyway.
2012-11-12 10:42:05 +01:00
Holger Hans Peter Freyther 1e85af661c mgcp: Document a difference between RFC 3550 and this code
Explain why this code deals with only one source and that this is
a limit of some equipment (e.g. the nanoBTS).
2012-11-12 10:42:05 +01:00
Holger Hans Peter Freyther ed3a661d0b mgcp: Align the variable naming with Appendix A of RFC 3550
Align the naming inside the mgcp_rtp_state with the naming inside
the 'source' struct of the appendix. Make first_seq_no/base_seq
a uint16_t. This is removing rules for alignments and reduces the
struct from 40 bytes to 36.
2012-11-12 10:42:05 +01:00
Holger Hans Peter Freyther 2e8e659586 mgcp: Remember the initial sequence number of the stream
This information is required for calculating the packet loss at the
end of a phone call.
2012-11-12 10:42:05 +01:00
Holger Hans Peter Freyther 952f752ffa mgcp: Count the received octets as of the MGCP specification
Count the received octets. This is encouraged by the MGCP specification.
Use a 32bit counter that is good enough for more than 12 hours of a EFR
call. This limit is good enough for the current configuration.
2012-11-12 10:42:05 +01:00
Holger Hans Peter Freyther 2a60a11c48 mgcp: Remove the lost_no from the mgcp statistics
The RFC 3435 specifies a different formula for calculating the lost
packages. It involves the number of received packages and the delta
of the sequence number.
2012-11-12 10:42:05 +01:00
Tobias Engel aff20717e4 Set byte order defines when compiled on OSX
Byte order defines have a DARWIN prefix on OSX so the values openbsc
expects are set from their Darwin counterparts when compiled on OSX.
2012-10-27 10:09:21 +02:00
Holger Hans Peter Freyther 8c3d0695e4 mgcp_network.c: Address compiler warning on return
When adding the "omit RTCP" the method started to return with
a proper return statement.

mgcp_network.c: In function ‘send_to’:
mgcp_network.c:233:1: warning: control reaches end of non-void function [-Wreturn-type]
2012-09-11 12:41:23 +02:00
Holger Hans Peter Freyther a8090d54d6 mgcp: Make it possible to drop RTCP packets coming from the BTS/Net
The ip.access nanoBTS appears to send quite broken NTP timestamps in
the RTCP messages might confuse equipment that uses the sender report
of the BTS. Make it easy to experiment by adding an option to drop RTCP.
2012-05-11 13:09:30 +02:00
Holger Hans Peter Freyther 445d00543a mgcp: Fix warning about unused variable
mgcp_network.c:335:22: warning: variable ‘cfg’ set but not used [-Wunused-but-set-variable]
2012-01-17 16:00:08 +01:00
Holger Hans Peter Freyther 9bdf5a9ef7 mgcp: Fix a typo in the function name 2011-06-02 19:04:22 +02:00
Pablo Neira Ayuso 4db9299286 src: use namespace prefix osmo_fd* and osmo_select*
Summary of changes:

s/struct bsc_fd/struct osmo_fd/g
s/bsc_register_fd/osmo_fd_register/g
s/bsc_unregister_fd/osmo_fd_unregister/g
s/bsc_select_main/osmo_select_main/g
2011-05-06 12:11:23 +02:00
Holger Hans Peter Freyther a8a09df6a6 misc: Remove sys/types.h includes from the files
These are not needed any more. We used them for u_int
types but we now use uint which comes from stdint.h
2011-04-18 17:31:39 +02:00
Pablo Neira Ayuso 136f453dd2 src: use new library libosmogsm and new path to headers in libosmocore
libosmogsm is a new library that is distributed in the libosmocore.
Now, openbsc depends on it. This patch gets openbsc with this
change.

This patch also rewrites all include path to the new
osmocom/[gsm|core]

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-03-23 18:17:56 +01:00
Holger Hans Peter Freyther 16b7f5c4ef mgcp: Remove some duplicate header files from the list. 2011-03-08 15:33:52 +01:00
Harald Welte 89579b4317 prefix sub-directories containing libraries with 'lib'
... and make sure tests work again after restructuring
2011-03-04 13:23:09 +01:00