Commit Graph

135 Commits

Author SHA1 Message Date
Max 5fd93e02f8 Fix potential NULL dereference
Change-Id: I5baf369dbf3948565614476980a32be59abaf42a
2017-02-07 11:46:41 +01:00
Daniel Willmann 2904f82f99 osmux: Add function to delete all msgs pending for a circuit
Use this function in osmux_batch_del_circuit() since msgs are stored in a list
per circuit. After the circuit is free()d the msgs are lost.
Before this patch any messages enqueued inside a batch when the circiut is
deleted were leaking.

Change-Id: Ib0311652183332d0475bf7347023d518d38487ef
Ticket: OS#1733
Reviewed-on: https://gerrit.osmocom.org/120
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-26 12:05:42 +00:00
Daniel Willmann d5235e5e51 osmux: Pass circuit to _batch_del_circuit() and use it from _xfrm_input_fini()
Change-Id: If224980123d4a369133499ab7b577d02511f4055
Ticket: OS#1733
Reviewed-on: https://gerrit.osmocom.org/119
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-25 20:42:41 +00:00
Pablo Neira Ayuso e479f25a9b osmux: rename batch->dummy field to batch->ndummy
This is basically a counter that tells us how many circuits need the padding,
so better rename this to ndummy.

Suggested by Holger.
2015-08-19 00:21:43 +02:00
Pablo Neira Ayuso e1aefad278 osmux: kill osmux_get_hdr()
Never used, so let's get rid of this function. We can recover it later on in
case we need it.
2015-07-21 11:05:41 +02:00
Pablo Neira Ayuso ea549806c9 osmux: introduce osmux_xfrm_input_open_circuit()
This new function allows you to create a circuit on an existing input handle.

We don't create the circuit anymore from the first packet seen, instead the
client application is in full control of opening and closing the circuit.

This change includes a new feature to pad a circuit until we see the first
packet that contains voice data. This is useful to preallocate bandwidth on
satellite links such as Iridium/OpenPort.
2015-07-21 09:59:49 +02:00
Pablo Neira Ayuso b3fc27423a osmux: introduce osmux_xfrm_input_close_circuit()
Add this new function to explicitly remove an existing circuit. Thus, the
client application (openbsc) is in full control to release circuits.

Before this patch, the circuit object was added when the first RTP messages was
seen, and it was removed when transforming the list of pending RTP messages to
the Osmux message (once the timer expired).

Moreover, check circuit->nmsgs to account bytes that are consumed by the osmux
header, given that !circuit doesn't mean "this is the first packet" anymore.
2015-07-21 09:59:49 +02:00
Pablo Neira Ayuso ab898deea3 osmux: count pending messages to be transformed in the batch
Add a new field to count the number of messages in the batch that are pending
to be transformed to osmux. Use this new field to check when to enable the
osmux timer.

The follow up patch keeps circuit objects in the batch until they are closed,
so we won't be able to rely on this to know when to enable the timer anymore.
2015-07-21 09:59:49 +02:00
Pablo Neira Ayuso d886bd0503 osmux: pass up struct osmux_batch
Instead of struct osmux_in_handle. This object contains the internal batching
state information.
2015-07-21 09:59:49 +02:00
Pablo Neira Ayuso f3016f29dd osmux: rename circuit->list to circuit->rtp_list
A circuit object contains a list of pending RTP messages to be converted to the
osmux format.
2015-07-21 09:59:49 +02:00
Pablo Neira Ayuso 22026a4b9b osmux: rename struct batch_list_node to osmux_circuit
I think this is a better name for this object. Basically, an input handle
represents a batch that is composed of one or more circuit objects.

Each circuit object contains a list of RTP messages that are pending to be
converted to the osmux format in one single batch.
2015-07-21 09:59:48 +02:00
Pablo Neira Ayuso 75df57e15f osmux: add circuit helper functions
Add osmux_batch_add_circuit() and osmux_batch_find_circuit() helper functions.
2015-07-21 09:58:48 +02:00
Pablo Neira Ayuso 752a9c68e5 osmux: add osmux_input_state structure
This new structure serves as container of the internal osmux state during
transformation from RTP AMR to the compressed osmux format.

This reduces the footprint of several functions and it makes them easier to
extend if we need to pass new information between functions.
2015-07-17 22:03:31 +02:00
Pablo Neira Ayuso f67d1126ab osmux: discard non voice osmux message
We only support voice osmux messages by now. Discard unsupported types.
2015-07-17 22:03:31 +02:00
Pablo Neira Ayuso 0316aa6060 osmux: export OSMUX_BATCH_DEFAULT_MAX
This allows you to set the default batch size when initializing the
osmux input handle.
2014-08-29 15:30:29 +02:00
Pablo Neira Ayuso 9de1521ca9 osmux: fix more leaks in osmux_xfrm_input() in the error path
Return 0 to the caller, which believes that we have put the message
in the batch. But if it is malformed, silently release it.
2014-08-28 20:19:13 +02:00
Pablo Neira Ayuso c7f110fe73 osmux: stop batch timer in osmux_xfrm_input_fini()
Make sure we don't release a osmux handle with an armed batch timer.

==9753== Invalid read of size 4
==9753==    at 0x4043CA2: rb_first (rbtree.c:293)
==9753==    by 0x403E172: osmo_timers_check (timer.c:256)
==9753==    by 0x403E69E: osmo_select_main (select.c:124)
==9753==    by 0x804EBD3: main (bsc_nat.c:1613)
==9753==  Address 0x4302670 is 56 bytes inside a block of size 108 free'd
==9753==    at 0x4023B6A: free (vg_replace_malloc.c:366)
==9753==    by 0x40494CF: talloc_free (talloc.c:609)
==9753==    by 0x40AB279: osmux_xfrm_input_fini (osmux.c:620)
==9753==    by 0x80651FC: osmux_disable_endpoint (mgcp_osmux.c:96)
==9753==    by 0x805CAFF: mgcp_release_endp (mgcp_protocol.c:1540)
==9753==    by 0x805DD35: handle_delete_con (mgcp_protocol.c:1274)
==9753==    by 0x805E998: mgcp_handle_message (mgcp_protocol.c:415)
==9753==    by 0x804CFF1: mgcp_do_read (bsc_mgcp_utils.c:972)
==9753==    by 0x403F96D: osmo_wqueue_bfd_cb (write_queue.c:48)
==9753==    by 0x403E724: osmo_select_main (select.c:158)
==9753==    by 0x804EBD3: main (bsc_nat.c:1613)
2014-08-28 20:00:06 +02:00
Pablo Neira Ayuso bf42dd6b23 osmux: fix leaks in osmux_xfrm_input() error path
If it is not possible to put the RTP message into the batch in case that:

1) The message is malformed.
2) The message is duplicated.
3) OOM.
4) The batch is already full.

Osmux releases the messages and gets back to the upper layer with an OK
to give another chance to follow up RTP messages.

This patch also fixes a use-after-free that was possible when the batch
was full. The message was released and osmux_batch_add() was returning 0
osmux_xfrm_input(), which resulted in accessing the released message
when updating the statistics.
2014-08-28 19:33:45 +02:00
Pablo Neira Ayuso 217336c2ec osmux: fix osmux_xfrm_output() due to 62d8a18
Fix accidental inclusion of list_add in debugging message area
in ("62d8a18 osmux: hide spamming debug log messages behind ifdef")
that broke osmux.
2014-08-28 18:39:35 +02:00
Pablo Neira Ayuso 355f95b0a3 osmux: more hide spamming debug log 2014-08-28 17:30:12 +02:00
Pablo Neira Ayuso 62d8a18787 osmux: hide spamming debug log messages behind ifdef
This is ugly, with many ifdefs, but they don't want any debug message
that can be spamming. I don't want to remove these because there is
no dissector for osmux, and this can be useful for troubleshooting.
2014-08-28 17:18:11 +02:00
Pablo Neira Ayuso 843c23098a osmux: add statistics to osmux_in_handle struct
Add statistics to the osmux input handle, which translates the RTP
messages to osmux batch.
2014-08-28 16:14:16 +02:00
Pablo Neira Ayuso 7a990e8e53 osmux: disable timing reconstruction debugging
Should be enabled only in case you consider that Osmux should
is lagging when reconstructing RTP messages. I haven't seen
any issue regarding this so far. Let's disable it by default.
2014-08-28 15:17:41 +02:00
Pablo Neira Ayuso d8947e37b0 osmux: allow to specify the osmux frame size
This patch adds a new field to the struct osmux_in_handle that allows
you to specify the osmux frame size. If not specified, the default
size assumes your nic uses a mtu of 1500 bytes.
2014-08-28 15:01:03 +02:00
Pablo Neira Ayuso 0b44016ef6 osmux: fix leak in osmux_replay_lost_packets()
The original RTP header has been already sanity check. Therefore,
we can assume the clone is sane.
2014-08-28 14:30:53 +02:00
Pablo Neira Ayuso 3789791b6b osmux: revisit osmux_batch_enqueue() in case of batch full
1) Force batch delivery in case it is full.

2) Skip padding with more RTP clone in case of message lost if the
   batch is full.
2014-08-28 14:27:54 +02:00
Pablo Neira Ayuso 0143d6ec18 osmux: add osmux_xfrm_input_fini()
To clean up the osmux input handle.
2014-08-28 12:45:04 +02:00
Pablo Neira Ayuso 512db84622 osmux: cleanup debugging message
Remove message that is printed twice and reword the messages to
make it more clear the traffic flow when compressing and
decompressing the RTP AMR traffic.
2014-04-25 15:02:26 +02:00
Pablo Neira Ayuso a040773d57 osmux: (really) validate AMR FT field
(dc898ab osmux: don't trust AMR FT field) was not correctly
validating the AMR FT field as it was comparing the same
value twice calculated in different ways.

Use osmo_amr_bytes(amrh->ft) to obtain the expected length
and check if it is what we got. Use the output of
osmo_rtp_get_payload() as it also includes the RTP payload
stripping possible extensions.
2013-12-16 13:49:42 +01:00
Pablo Neira Ayuso dc898ab983 osmux: don't trust AMR FT field
Sanity check that that we have enough bytes in the AMR payload for
this frame-type.
2013-12-16 13:05:31 +01:00
Pablo Neira Ayuso 0094d98b04 osmux: limit RTP messages per batch
The ctr field of the osmux header is 3 bits long, make sure we
don't run over that boundary. This should not happen in practise
unless we have to deal with network congestion or broken RTP
stacks, but osmux should not crash in that case.
2013-12-16 12:55:28 +01:00
Pablo Neira Ayuso d8a8c0db20 osmux: fix handling of old RTP messages
Make sure that osmux_replay_lost_packets() doesn't try to fill gaps
if we see RTP messages whose sequence number is in the past.
2013-12-16 12:55:28 +01:00
Pablo Neira Ayuso 88eae20dc2 osmux: pass rtp header to osmux_batch_add()
This patch is a cleanup. Pass the pointer to the header, so we don't
need to obtain it from the message buffer again.
2013-12-15 22:35:28 +01:00
Pablo Neira Ayuso 84fffecba5 osmux: fix handling of too big RTP message in osmux_xfrm_input()
With this patch, osmux_xfrm_input() returns 0 (means "message has been
processed") instead of 1 (means "retry") if the RTP message is too big
to fit into one osmux batch. This fixes a likely infinite loop in the
caller, which will retry forever for a message does not fit into the
batch.

Unlikely to happen in normal scenario, as RTP+AMR messages are way
smaller than the interface MTU.
2013-12-15 22:27:18 +01:00
Pablo Neira Ayuso 55033742a1 osmux: don't print messages with wrong AMR FT
The AMR FT field is used to infer the length of the payload, if
a value higher than 8 (SID) is received, skip it.

This fixes a possible crash in osmux_snprintf() in case we receive
a malformed osmux header.

This is also addresses the crash described in c733ae5b6e.
2013-12-14 22:36:00 +01:00
Pablo Neira Ayuso c733ae5b6e osmux: fix crash in osmux_snprintf when handling multi-batch messages
valgrind reports the following crash backtrace:

!<001c> osmux.c:687 No room for OSMUX payload: only 49 bytes
==12800==
==12800== Process terminating with default action of signal 11 (SIGSEGV)
==12800==  Access not within mapped region at address 0xDFA8E473
==12800==    at 0x4073FD2: osmux_snprintf (osmux.c:628)
==12800==    by 0x80524F1: osmux_deliver (osmux.c:50)
==12800==    by 0x407371C: osmux_xfrm_input_deliver (osmux.c:302)
==12800==    by 0x4073792: osmux_batch_timer_expired (osmux.c:312)
==12800==    by 0x405A4A0: osmo_timers_update (timer.c:243)
==12800==    by 0x405A79A: osmo_select_main (select.c:133)
==12800==    by 0x8049A53: main (mgcp_main.c:307)

The problem is that osmux_snprintf() is not handling multi-batch
messages (ie. messages that contain several osmux batches). More
specifically, the offset to print the osmux batches was reset
when parsing every osmux batch.

The problem also manifested with wrong outputs.

Reported by Mattias Lundstrom.
2013-12-14 22:01:25 +01:00
Pablo Neira Ayuso 87b3eeaed7 osmux: delete message from output list before calling tx_cb
Valgrind complains about a possible use after free:

==12800== Invalid read of size 4
==12800==    at 0x4073DF6: osmux_tx_sched (linuxlist.h:119)
==12800==    by 0x8052B0F: osmux_read_from_bsc_nat_cb (osmux.c:261)
==12800==    by 0x453F967: ???
==12800==  Address 0x453f710 is 48 bytes inside a block of size 145
+free'd
==12800==    at 0x402750C: free (vg_replace_malloc.c:427)
==12800==    by 0x4064ADE: talloc_free (talloc.c:609)
==12800==    by 0x405AAAA: msgb_free (msgb.c:72)
==12800==    by 0x8052492: scheduled_tx_bts_cb (osmux.c:196)
==12800==    by 0x4072CF8: osmux_tx_cb (osmux.c:554)
==12800==    by 0x4073F03: osmux_tx_sched (osmux.c:582)
==12800==    by 0x8052B0F: osmux_read_from_bsc_nat_cb (osmux.c:261)
==12800==    by 0x453F967: ???

The problem is that osmux_tx_sched may immediately call osmux_tx_cb for
the first extracted RTP message from the osmux batch, which releases the
message after that.

Remove the message from our list of messages to be transmitted before
the message is passed to the tx callback.

Reported by Mattias Lundstrom.
2013-12-13 15:23:04 +01:00
Pablo Neira Ayuso ceda50fa70 osmux: add artificial limit for cloned RTP packets
Avoid spamming lots of cloned RTP packets in case of severe
gaps.
2013-09-12 13:19:32 +02:00
Pablo Neira Ayuso 7b37afba33 osmux: sanity check too big RTP/RTCP messages as input
Holger spotted that the caller may loop forever in case it receives
big RTP/RCTP packets, that are likely to be spoofed.
2013-08-27 17:15:27 +02:00
Pablo Neira Ayuso 8c1f31a3dc osmux: disable timing debugging
Disable timing debugging by default.
2013-05-27 01:30:36 +02:00
Pablo Neira Ayuso 390872055d osmux: nul-terminate all strings generated by _snprintf
Make sure all strings are null-terminated.

Spotted by Holger Hans Peter Freyther.
2013-05-24 12:51:02 +02:00
Pablo Neira Ayuso 70214a15d1 osmux: further sanity checkings for AMR FT
According to RFC3267, AMR FT upper 9 should be discarded. This patch
adds extra validation to make sure that input RTP traffic encapsulating
AMR payload and OSMUX amr_ft field are OK with regards to that
restriction.
2013-05-24 12:16:49 +02:00
Pablo Neira Ayuso 1ee6d39921 osmux: add sanity checking in osmux_xfrm_output_pull
Osmux infers the size of the AMR payload from the FT type.
Make sure we get enough data from the network according to
what we expect.
2013-05-24 10:47:59 +02:00
Pablo Neira Ayuso dd34adea7a osmux: remove trailing line break from osmux_snprintf 2013-05-23 20:59:13 +02:00
Pablo Neira Ayuso 3cf3a732ea osmux: fix warning spotted by clang --analyze
osmux.c:622:20: warning: Value stored to 'osmuxh' during its
      initialization is never read
        struct osmux_hdr *osmuxh = (struct osmux_hdr *)msg->data;
                          ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reported by Holger Hans Peter Freyther.
2013-05-22 02:06:33 +02:00
Pablo Neira Ayuso 56c4681d83 osmux: replay last RTP packet seen under packet loss scenario
If osmux notices a gap between two RTP packets, fill it with
the last RTP packet seen. Without this patch, 10% of packet loss
is enough to get garbage, with it we get glitches in the conversation
with 30%, and pretty much broken conversation with 40% of it.
2013-05-21 00:48:13 +02:00
Pablo Neira Ayuso a9ab95c2c4 osmux: use ccid to identify batches instead of the RTP SSRC
This should reduce the amount of batch nodes that are created
by the maximum number of allowed circuit IDs.
2013-05-20 22:37:31 +02:00
Pablo Neira Ayuso a2c7f909ef osmux: add sanity checking to osmux_snprintf
Add sanity checking to avoid crashes on malformed OSMUX packets
2013-05-12 20:44:00 +02:00
Pablo Neira Ayuso 282aee422f osmux: allow to set initial RTP SSRC
Instead of using the osmuxh->circuit_id.
2013-05-12 19:56:21 +02:00
Pablo Neira Ayuso d32caea9ea osmux: add osmux_snprintf
Useful for debugging purposes. Modify also examples to use it.
2013-02-19 17:14:33 +01:00
Pablo Neira Ayuso e0ae0d25c0 osmux: RTP payload type for voice is dynamic
Don't make any assumption on the payload type.
2013-02-19 16:14:32 +01:00
Pablo Neira Ayuso 5cbdd8797a osmux: add talloc context
Good for debugging leaks.
2013-02-19 13:18:48 +01:00
Pablo Neira Ayuso 01537a3678 osmux: initialize batch appropriately in osmux_xfrm_input_init
Use talloc_size not talloc. Should fix:

0xb779401a in rb_erase (node=0x200200, root=0xb779c908) at rbtree.c:230
0xb779401a in rb_erase (node=0x200200, root=0xb779c908) at rbtree.c:230
0xb778ee48 in osmo_timer_del (timer=0x94aacd0) at timer.c:110
0xb778ef65 in osmo_timer_add (timer=0x94aacd0) at timer.c:72
0xb778f03c in osmo_timer_schedule (timer=0x94aacd0, seconds=0, microseconds=64000)
0xb77360ff in osmux_xfrm_input (h=0x94a4280, msg=0x94b8a50, ccid=18) at osmux.c:390

Due to uninitialization batch structures.
2013-02-19 13:17:02 +01:00
Pablo Neira Ayuso 92601d0a20 osmux: use ft instead of the cmr
The cmr is the requested codec for the other peer, the ft actually
contains the current codec mode. cmr may contain 15 which means
"don't care".
2013-02-12 19:29:42 +01:00
Pablo Neira Ayuso c92810eccd osmux: remove arrays from osmux_out_handle
there will be one osmux_out_handle per endpoint.
2013-02-12 17:24:13 +01:00
Pablo Neira Ayuso 7ff7a5cd6d osmux: allow to pass data to osmux_deliver 2013-02-11 22:49:27 +01:00
Pablo Neira Ayuso 0f1f41411f osmux: fix missing data set in osmux_tx_sched 2012-10-21 04:12:29 +02:00
Pablo Neira Ayuso 5654c43f80 osmux: remove generic functions to register and get ccid
Remove these functions:

- osmux_xfrm_input_get_ccid
- osmux_xfrm_input_register_ccid

The ccid will be managed by the BSC and it will be stored in the
mgcp_endpoint structure.

Also adjust all tests and examples using the API.
2012-10-20 20:17:28 +02:00
Pablo Neira Ayuso 7f9ebe2e56 osmux: fix DELTA_RTP_MSG
It should be 16000 and add DELTA_RTP_TIMESTAMP which is 160.
2012-10-15 23:09:36 +02:00
Pablo Neira Ayuso 8c9caa8607 osmux: rewrite batching function
Rework batching routine to reduce its complexity, updates:

* Now it uses a list of lists to store the messages that will be
  batched.

batch list
    |
    `-> node SSRC=a ---> ... ---> node SSRC=b
            |                         |
        msg seq=x1               msg seq=y1
            |                         |
        msg seq=x2               msg seq=y2
            |                         |
        msg seq=x3               msg seq=y3
            |                         |
        msg seq=x4               msg seq y4

This keeps easier the creation of the final batch that is sent from that
data structure.

* We also detect duplicate messages in the batch, ie. messages with the
  same sequence are skipped.

Still pending to resolve reordering, corruption and omissions (reliability
is desired).
2012-10-15 23:09:36 +02:00
Pablo Neira Ayuso e472f44dd3 osmux: RTP timestamp has to be bumped in 160
Between two RTP messages that were extracted from a batch, the
timestamp difference should be 160.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2012-10-15 23:09:36 +02:00
Pablo Neira Ayuso 384bdf630a osmux: release of batch message is controled by caller
Instead of internally released. This is required if we use the
osmo_dgram infrastructure, to avoid a double release.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2012-10-15 18:14:59 +02:00
Pablo Neira Ayuso 6907ac37e1 osmux: use DLMIB instead of internal defined DOSMUX
Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2012-10-15 15:59:14 +02:00
Pablo Neira Ayuso 4fd56b6d2f osmux: fix ordering of RTP messages in the batching list
This patch fixes the ordering in RTP sequence number. Before this patch,
the list was inverted.

This also fixes the calculation of the room that still remains in the
batch.
2012-08-06 21:04:25 +02:00
Pablo Neira Ayuso 7a01104b88 osmux: add OSMUX_MAX_CONCURRENT_CALLS which is 8
Instead of harcoding the number all around the code.
2012-08-06 21:04:25 +02:00
Pablo Neira Ayuso 72a0aae500 osmux: support two concurrent calls in output path 2012-08-06 21:04:25 +02:00
Pablo Neira Ayuso b9cf903bbe osmux: add infrastructure to map RTP SSRC and osmux CCID 2012-08-06 21:04:25 +02:00
Pablo Neira Ayuso da0c9ab922 osmux: fix wrong calculation of csrc_count 2012-08-06 21:04:25 +02:00
Pablo Neira Ayuso 468d81b4ac osmux: batching factor can be explicitly configured by caller
Not hardcoded in osmux.c code anymore.
2012-08-06 21:04:25 +02:00
Pablo Neira Ayuso f366c924e2 osmux: store internal batching information in struct osmux_in_handle
The layout is not provided, as it is internal.

Thus, we don't allocate the internal batching information in BSS
anymore.
2012-08-06 21:04:25 +02:00
Pablo Neira Ayuso 6d72b4a729 osmux: print RTP header if debug logging level is set 2012-08-06 21:04:25 +02:00
Pablo Neira Ayuso f4b11c0717 osmux: extend debugging to make sure we don't lag in scheduled transmissions
osmux only lags ~0.15 ms at maximum to transmit one scheduled RTP message
according to my tests with PCAP traces.

Yes, only ~0.15 milliseconds, this is not wrong :-).

This is good news, our timer infrastructure seems to be quite precise.
2012-08-04 21:16:27 +02:00
Pablo Neira Ayuso d2ea108728 osmux: remove timeval parameter from osmux_tx_sched
We can internal allocate this in the stack, no need to expose it to
the caller.
2012-08-04 21:03:56 +02:00
Pablo Neira Ayuso 81979fa80a osmux: fix when to add the osmux header
This needs to be done for the first message in one RTP SSRC series.
Before this patch, it was always included due to wrong aritmethics.
2012-08-04 20:56:53 +02:00
Pablo Neira Ayuso 082d700a8f osmux: fix list ordering for RTP messages that will be included in batch
This fixes the algorithms to include the messages in order in the
batch based on the TRP SSRC (from lower to higher).

This is very important to reduce the amount of bytes that we
spend on the osmux header.
2012-08-04 20:53:57 +02:00
Pablo Neira Ayuso 2cefb116d0 osmux: check for the maximum amount of messages in batch
This should not happen, but make sure our osmux CTR field does not
wrap around.
2012-08-04 20:52:45 +02:00
Pablo Neira Ayuso fe9fccd412 osmux: cleanup tx path
This patch cleans up the transmission path for osmux, this involves
the functions that extract the messages from the batch and the one
that reconstruct the timing.

They now take a list that contains the reconstructed RTP messages:

 osmux_xfrm_output(osmuxh, &h_output, &list);
 osmux_tx_sched(&list, &tv, tx_cb, NULL);
2012-08-04 19:59:33 +02:00
Pablo Neira Ayuso ffd20f3f1c osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.

osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...

The new header is the following:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT  | CTR |F|Q|    SeqNR      |  Circuit ID   |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.

I have also removed the RTP marker, since it can be reconstructed
from the AMR information.

Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.

Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.

The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 20:36:19 +02:00
Pablo Neira Ayuso 52c7649e23 osmux: fix wrong maximum batch size
Missing UDP header in calculation.
2012-08-02 20:24:31 +02:00
Pablo Neira Ayuso 8a8c47aaba osmux: use logging infrastructure
so far, printf was used instead.
2012-07-19 13:04:39 +02:00
Pablo Neira Ayuso 0db9b568f2 osmux: add DEBUG_TIMING to make sure timing reconstruction is OK
by now, it is set on by default.
2012-07-19 12:53:04 +02:00
Pablo Neira Ayuso 6071c652cf osmux: always use osmux_tx_cb in osmux_tx_sched
This is required by the follow-up patch to debug timing issues.
2012-07-19 12:49:55 +02:00
Pablo Neira Ayuso 8ba490fd96 osmux: add osmux_tx_sched to reconstruct the timing of RTP messages
This function schedules the transmission of a RTP message that was
obtained from one osmux batch. It takes the time (in microseconds)
after which the message should be transmitted.
2012-07-19 11:38:50 +02:00
Pablo Neira Ayuso d3c21b3cad osmux: use osmo_amr_bytes instead of hardcoded 15 bytes for CMR 2
I was using AMR CMR 2 (15 bytes) as the initial tests were done
with the codec variant.

This patch fixes this by using the new generic osmo_amr_bytes
extracted from 3GPP TS 26.101.
2012-07-13 21:17:51 +02:00
Pablo Neira Ayuso 00b6026f64 add osmux support 2012-07-12 13:03:07 +02:00