RFC 3952
Real-time Transport Protocol (RTP) Payload Format for internet Low Bit Rate Codec (iLBC) Speech
RFC 3952: RTP Payload Format for iLBC Speech ๐
okay bestie, this one is the RTP payload format for iLBC speech ๐๏ธโจ iLBC is a low bit rate speech codec that was developed by Global IP Sound (GIPS), and this doc explains how to pack its compressed audio into RTP packets. It's giving very specific and very useful ๐
- RFC number: 3952
- Title: Real-time Transport Protocol (RTP) Payload Format for internet Low Bit Rate Codec (iLBC) Speech
- Authors: A. Duric (Telio) and S. Andersen (Aalborg University)
- Working group: Network Working Group
- Category: Experimental ๐งช
- Date: December 2004
- Obsoletes / Updates: neither is listed in the header, so this doc doesn't obsolete or update anything ๐ธ
Status of this Memo ๐
ngl this section is the "what kind of doc is this" part ๐ This memo defines an Experimental Protocol for the Internet community, so it is not an Internet standard of any kind. The authors are asking for discussion and suggestions for improvement, and distribution of this memo is unlimited ๐ฆ
Copyright Notice ๐
Copyright (C) The Internet Society (2004).
Abstract ๐
okay so the abstract is the quick tour โจ The doc describes the RTP payload format for the internet Low Bit Rate Codec (iLBC) Speech, which was developed by Global IP Sound (GIPS). It also includes the details you need to use iLBC with MIME and the Session Description Protocol (SDP), so it's giving everything in one place ๐ง
Table of Contents ๐๏ธ
1. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Background. . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3. RTP Payload Format. . . . . . . . . . . . . . . . . . . . . . . 3
3.1. Bitstream definition . . . . . . . . . . . . . . . . . . . 3
3.2. Multiple iLBC frames in a RTP packet . . . . . . . . . . . 6
4. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 7
4.1. Storage Mode . . . . . . . . . . . . . . . . . . . . . . . 7
4.2. MIME registration of iLBC. . . . . . . . . . . . . . . . . 8
5. Mapping to SDP Parameters . . . . . . . . . . . . . . . . . . . 9
6. Security Considerations . . . . . . . . . . . . . . . . . . . . 11
7. References. . . . . . . . . . . . . . . . . . . . . . . . . . . 11
7.1. Normative References . . . . . . . . . . . . . . . . . . . 11
7.2. Informative References . . . . . . . . . . . . . . . . . . 12
8. Acknowledgements. . . . . . . . . . . . . . . . . . . . . . . . 12
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 12
Full Copyright Statement . . . . . . . . . . . . . . . . . . . . . 13
1. Introduction โจ
okay so this doc explains how compressed iLBC speech, the stuff the iLBC codec [1] spits out, can be formatted as an RTP payload type ๐ง It gives you methods for packetizing the codec data frames into RTP packets. The sender gets to choose how many codec data frames go in each packet, depending on the application scenario or on the transport network condition, bandwidth restriction, delay requirements and packet-loss tolerance. main character energy in the choosing ๐
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14, RFC 2119 [2]. ๐
2. Background ๐
Global IP Sound (GIPS) built a speech compression algorithm for IP based communications [1] ๐ค The iLBC codec gives you graceful speech quality degradation when frames get lost, and frames get lost when IP packets are lost or delayed. It's literally designed for that ๐
This codec is suitable for real time communications such as telephony and videoconferencing, streaming audio, archival and messaging ๐
Here's the core math bestie ๐งฎ The iLBC codec [1] is an algorithm that compresses each basic frame (20 ms or 30 ms) of 8000 Hz, 16-bit sampled input speech into output frames. A 30 ms basic frame becomes 400 bits, and a 20 ms basic frame becomes 304 bits.
The codec supports two basic frame lengths: 30 ms at 13.33 kbit/s and 20 ms at 15.2 kbit/s, and it uses a block independent linear-predictive coding (LPC) algorithm ๐ When the codec runs at 20 ms block lengths, it produces 304 bits per block, which MUST be packetized in 38 bytes. For 30 ms block lengths, it produces 400 bits per block, which MUST be packetized in 50 bytes. ๐ซถ
The vibe is that this algorithm gives you a speech coding system with a controlled response to packet losses. That's similar to pulse code modulation (PCM) with a packet loss concealment (PLC), like the ITU-T G711 standard [7], which runs at a fixed bit rate of 64 kbit/s ๐ At the same time, it gives you fixed bit rate coding with a quality-versus-bit rate tradeoff that's close to what you get from code-excited linear prediction (CELP). โจ
3. RTP Payload Format ๐
okay this is the part where the packets actually get built ๐ฆ The iLBC codec uses 20 or 30 ms frames and a sampling rate clock of 8 kHz, so the RTP timestamp MUST be in units of 1/8000 of a second. โฑ๏ธ The RTP payload for iLBC has the format shown below. No addition header specific to this payload format is required, so it's super lean ๐ฆ
This format is meant for situations where the sender and the receiver send one or more codec data frames per packet. The RTP packet looks like this:
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| RTP Header [3] |
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
| |
+ one or more frames of iLBC [1] |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 1, Packet format diagram ๐
The RTP header of the packetized encoded iLBC speech has the expected values described in [3] ๐ The usage of the M bit SHOULD be as specified in the applicable RTP profile. For example, RFC 3551 [4] says that if the sender does not suppress silence (i.e., sends a frame on every frame interval), the M bit will always be zero. ๐ When more than one codec data frame is present in a single RTP packet, the timestamp is, as always, the oldest data frame represented in the RTP packet โฐ
The assignment of an RTP payload type for this new packet format is outside the scope of this document, so it won't be specified here ๐ง It's expected that the RTP profile for a particular class of applications will assign a payload type for this encoding. If that isn't done, then a payload type in the dynamic range shall be chosen by the sender. ๐
Part 1 of 3 wraps up here, so stay tuned for the next drop ๐ฆ๐
3.1. Bitstream definition โจ
Okay so one frame of 20 ms speech is 304 bits total, which fits in 38 bytes and gives you a bit rate of 15.20 kbit/s ๐. For 30 ms frames it's 400 bits, which fits in 50 bytes at 13.33 kbit/s. The bits get sorted into three classes based on how sensitive they are to bit errors or loss ๐ญ. The most sensitive bits (class 1) go first in each frame, the less sensitive ones (class 2) come after them, and the least sensitive ones (class 3) sit at the very end ๐ซถ.
Here's the breakdown for each frame length. Class 1 takes 6/8 bytes (48/64 bits), class 2 takes 8/12 bytes (64/96 bits), and class 3 takes 24/30 bytes (191/239 bits) ๐ . This split is what makes uneven level protection (ULP) possible, which is so smart ๐ง โจ. When a quantization index gets spread across more than one class, the more significant bits always land in the lowest class ๐. Here's the full bit allocation:
------------------------------------------------------------------+
Parameter | Bits Class <1,2,3> |
| 20 ms frame | 30 ms frame |
----------------------------------+---------------+---------------+
Split 1 | 6 <6,0,0> | 6 <6,0,0> |
LSF 1 Split 2 | 7 <7,0,0> | 7 <7,0,0> |
LSF Split 3 | 7 <7,0,0> | 7 <7,0,0> |
------------------+---------------+---------------+
Split 1 | NA (Not Appl.)| 6 <6,0,0> |
LSF 2 Split 2 | NA | 7 <7,0,0> |
Split 3 | NA | 7 <7,0,0> |
------------------+---------------+---------------+
Sum | 20 <20,0,0> | 40 <40,0,0> |
----------------------------------+---------------+---------------+
Block Class. | 2 <2,0,0> | 3 <3,0,0> |
----------------------------------+---------------+---------------+
Position 22 sample segment | 1 <1,0,0> | 1 <1,0,0> |
----------------------------------+---------------+---------------+
Scale Factor State Coder | 6 <6,0,0> | 6 <6,0,0> |
----------------------------------+---------------+---------------+
Sample 0 | 3 <0,1,2> | 3 <0,1,2> |
Quantized Sample 1 | 3 <0,1,2> | 3 <0,1,2> |
Residual : | : : | : : |
State : | : : | : : |
Samples : | : : | : : |
Sample 56 | 3 <0,1,2> | 3 <0,1,2> |
Sample 57 | NA | 3 <0,1,2> |
------------------+---------------+---------------+
Sum | 171 <0,57,114>| 174 <0,58,116>|
----------------------------------+---------------+---------------+
Stage 1 | 7 <6,0,1> | 7 <4,2,1> |
CB for 22/23 Stage 2 | 7 <0,0,7> | 7 <0,0,7> |
sample block Stage 3 | 7 <0,0,7> | 7 <0,0,7> |
------------------+---------------+---------------+
Sum | 21 <6,0,15> | 21 <4,2,15> |
----------------------------------+---------------+---------------+
Stage 1 | 5 <2,0,3> | 5 <1,1,3> |
Gain for 22/23 Stage 2 | 4 <1,1,2> | 4 <1,1,2> |
sample block Stage 3 | 3 <0,0,3> | 3 <0,0,3> |
------------------+---------------+---------------+
Sum | 12 <3,1,8> | 12 <2,2,8> |
----------------------------------+---------------+---------------+
Stage 1 | 8 <7,0,1> | 8 <6,1,1> |
sub-block 1 Stage 2 | 7 <0,0,7> | 7 <0,0,7> |
Stage 3 | 7 <0,0,7> | 7 <0,0,7> |
------------------+---------------+---------------+
Stage 1 | 8 <0,0,8> | 8 <0,7,1> |
sub-block 2 Stage 2 | 8 <0,0,8> | 8 <0,0,8> |
Indices Stage 3 | 8 <0,0,8> | 8 <0,0,8> |
for CB ------------------+---------------+---------------+
sub-blocks Stage 1 | NA | 8 <0,7,1> |
sub-block 3 Stage 2 | NA | 8 <0,0,8> |
Stage 3 | NA | 8 <0,0,8> |
------------------+---------------+---------------+
Stage 1 | NA | 8 <0,7,1> |
sub-block 4 Stage 2 | NA | 8 <0,0,8> |
Stage 3 | NA | 8 <0,0,8> |
------------------+---------------+---------------+
Sum | 46 <7,0,39> | 94 <6,22,66> |
----------------------------------+---------------+---------------+
Stage 1 | 5 <1,2,2> | 5 <1,2,2> |
sub-block 1 Stage 2 | 4 <1,1,2> | 4 <1,2,1> |
Stage 3 | 3 <0,0,3> | 3 <0,0,3> |
------------------+---------------+---------------+
Stage 1 | 5 <1,1,3> | 5 <0,2,3> |
sub-block 2 Stage 2 | 4 <0,2,2> | 4 <0,2,2> |
Stage 3 | 3 <0,0,3> | 3 <0,0,3> |
Gains for ------------------+---------------+---------------+
sub-blocks Stage 1 | NA | 5 <0,1,4> |
sub-block 3 Stage 2 | NA | 4 <0,1,3> |
Stage 3 | NA | 3 <0,0,3> |
------------------+---------------+---------------+
Stage 1 | NA | 5 <0,1,4> |
sub-block 4 Stage 2 | NA | 4 <0,1,3> |
Stage 3 | NA | 3 <0,0,3> |
------------------+---------------+---------------+
Sum | 24 <3,6,15> | 48 <2,12,34> |
-------------------------------------------------------------------
Empty frame indicator | 1 <0,0,1> | 1 <0,0,1> |
-------------------------------------------------------------------
SUM 304 <48,64,192> 400 <64,96,240>
Table 3.1 The bitstream definition for iLBC. ๐
Now for the packing rule, which is a big deal ๐. When everything gets packetized into the payload, all the class 1 bits MUST be sorted in order (top to bottom) exactly as they appear in the table. The class 2 bits MUST also be sorted top to bottom, and the class 3 bits MUST be sorted in that same sequential order too ๐.
3.2. Multiple iLBC frames in a RTP packet ๐ฆ
Good news: you can put more than one iLBC frame into a single RTP packet ๐. Senders do have a few extra rules to follow though, so pay attention bestie ๐:
- Senders SHOULD NOT include more iLBC frames in a single RTP packet than will fit in the MTU of the RTP transport protocol.
- Frames MUST NOT be split between RTP packets.
- Frames of the different modes (20 ms and 30 ms) MUST NOT be included within the same packet.
It is RECOMMENDED that the number of frames in an RTP packet fits the application ๐ซถ. For telephony and other real-time apps where delay matters, the delay goes down as the number of frames per packet goes down (fewer frames per packet, lower delay โฑ๏ธ). For bandwidth-constrained links or delay-insensitive streaming and messaging apps, one or more frames per packet is totally fine ๐ธ.
The number of frames in an RTP packet isn't sent as part of the RTP payload, so nothing tells you directly how many there are ๐คทโโ๏ธ. Instead, you count the total octets in the RTP packet and divide by the expected octets per frame (32/50 per frame). Math, but make it iconic ๐งฎ๐ .
4. IANA Considerations ๐
One new MIME sub-type, described in this section, has been registered ๐.
4.1. Storage Mode ๐พ
The storage mode is for storing speech frames, like as a file or an email attachment ๐.
+------------------+
| Header |
+------------------+
| Speech frame 1 |
+------------------+
: :
+------------------+
| Speech frame n |
+------------------+
Figure 2, Storage format diagram
The file starts with a header, and that header only has a magic number so you know it's an iLBC file ๐. The magic number MUST match these ASCII strings:
- for 30 ms frame size mode:
"#!iLBC30\n", or"0x23 0x21 0x69 0x4C 0x42 0x43 0x33 0x30 0x0A"in hexadecimal form ๐ท, - for 20 ms frame size mode:
"#!iLBC20\n", or"0x23 0x21 0x69 0x4C 0x42 0x43 0x32 0x30 0x0A"in hexadecimal form ๐บ.
After the header, the speech frames just follow in consecutive order ๐ง.
Speech frames lost in transmission MUST be stored as "empty frames", as defined in [1]. ๐ซ
4.2. MIME Registration of iLBC โจ
Okay bestie, this is the registration form for the MIME type, so I'm keeping the template exactly as written. Every field and value matters here. ๐
MIME media type name: audio
MIME subtype: iLBC
Optional parameters:
All of the parameters does apply for RTP transfer only.
maxptime:The maximum amount of media which can be encapsulated in
each packet, expressed as time in milliseconds. The time
SHALL be calculated as the sum of the time the media present
in the packet represents. The time SHOULD be a multiple of
the frame size. This attribute is probably only meaningful
for audio data, but may be used with other media types if it
makes sense. It is a media attribute, and is not dependent
on charset. Note that this attribute was introduced after
RFC 2327, and non updated implementations will ignore this
attribute.
mode: The iLBC operating frame mode (20 or 30 ms) that will be
encapsulated in each packet. Values can be 0, 20 and 30
(where 0 is reserved, 20 stands for preferred 20 ms frame
size and 30 stands for preferred 30 ms frame size).
ptime: Defined as usual for RTP audio (see [5]).
Encoding considerations:
This type is defined for transfer via both RTP (RFC 3550)
and stored-file methods as described in Section 4.1, of RFC
3952. Audio data is binary data, and must be encoded for
non-binary transport; the Base64 encoding is suitable for
email.
Security considerations:
See Section 6 of RFC 3952.
Public specification:
Please refer to RFC 3951 [1].
Additional information:
The following applies to stored-file transfer methods:
Magic number:
ASCII character string for:
o 30 ms frame size mode "#!iLBC30\n" (or 0x23 0x21
0x69 0x4C 0x42 0x43 0x33 0x30 0x0A in hexadecimal)
o 20 ms frame size mode "#!iLBC20\n" (or 0x23 0x21
0x69 0x4C 0x42 0x43 0x32 0x30 0x0A in hexadecimal)
File extensions: lbc, LBC
Macintosh file type code: none
Object identifier or OID: none
Person & email address to contact for further information:
alan.duric@telio.no
Intended usage: COMMON.
It is expected that many VoIP applications will use this
type.
Author/Change controller:
alan.duric@telio.no
IETF Audio/Video transport working group
The short version: maxptime SHALL be calculated from the media in the packet, and it SHOULD be a multiple of the frame size. The mode values are 0, 20, and 30, where 0 is reserved. ๐
Also, this type is basically a VoIP favourite. The form says many VoIP apps are expected to use it, so it's giving COMMON energy ๐
5. Mapping To SDP Parameters ๐ฆ
Okay so the MIME media type info has a specific mapping onto fields in the Session Description Protocol (SDP) [5]. SDP is what people use to describe RTP sessions, so this is the part where iLBC meets SDP. Here's how it all lines up:
- The MIME type ("audio") goes in SDP "m=" as the media name.
- The MIME subtype (payload format name) goes in SDP "a=rtpmap" as the encoding name.
- The parameters "ptime" and "maxptime" go in the SDP "a=ptime" and "a=maxptime" attributes, respectively.
- The parameter "mode" goes in the SDP "a=fmtp" attribute by copying it directly from the MIME media type string as "mode=value".
When you're conveying this stuff through SDP, the encoding name SHALL be "iLBC" (the same as the MIME subtype). Non-negotiable, bestie ๐ซถ
Here's what a basic SDP media description looks like:
m=audio 49120 RTP/AVP 97
a=rtpmap:97 iLBC/8000
Now, if you're using 20 ms frame size mode, the remote iLBC encoder SHALL receive the "mode" parameter in the SDP "a=fmtp" attribute. You copy it straight from the MIME media type string, as semicolon-separated parameter=value pairs, where the parameter is "mode". The values can be 0 and 20 (0 is reserved, and 20 is the preferred 20 ms frame size). Here's the example:
m=audio 49120 RTP/AVP 97
a=rtpmap:97 iLBC/8000
a=fmtp:97 mode=20
Important tea โ: the "mode" parameter goes both ways. Both sides of a bi-directional session MUST use the same "mode" value. No mixing!
The offer carries the offerer's preferred mode. The answerer can agree by putting the same mode in the answer, or it can pick a different one. The mode both parties actually use SHALL be the lower of the bandwidth modes in the offer and the answer. So:
- An offer of "mode=20" with an answer of "mode=30" results in "mode=30" being used by both participants.
- An offer of "mode=30" with an answer of "mode=20" also results in "mode=30" being used by both participants.
This matters a LOT when one end is on a bandwidth-constrained link (like a 28.8k modem or slower), since only the smaller frame size will work there ๐ข
Last thing, and it's a big one: you can't use the "ptime" parameter to specify the iLBC operating mode. For certain values it's impossible to tell which mode is in use. For example, when ptime=60, you couldn't tell whether a packet carries 2 frames of 30 ms or 3 frames of 20 ms. Chaotic ๐
Also, naming tea: the payload format (encoding) names are usually written in upper case, and MIME subtypes are usually written in lower case. Both places are case-insensitive. Parameter names are case-insensitive too, both in MIME types and in the default mapping to the SDP a=fmtp attribute. ๐
6. Security Considerations ๐
Serious moment, bestie. RTP packets that use this payload format are subject to the general security considerations discussed in [3], plus any appropriate profile (for example, [4]).
Since this format transports encoded speech, the main security concerns are the confidentiality and authentication of the speech itself. The payload format doesn't have any built-in security mechanisms. Confidentiality of the media streams is achieved through encryption, so external mechanisms, such as SRTP [6], MAY be used for that purpose. The compression used with this payload format is applied end-to-end, so encryption can happen after compression with no conflict between the two operations. ๐ก๏ธ
There's also a potential denial-of-service threat for encodings that use compression techniques with non-uniform receiver-end computational load. An attacker can inject pathological datagrams into the stream that are complex to decode and overload the receiver. The encodings covered in this document don't show any significant non-uniformity, though, so we're good ๐
7. References ๐
7.1. Normative References
- [1] Andersen, S., Duric, A., Astrom, H., Hagen, R., Kleijn, W., and J. Linden, "Internet Low Bit Rate Codec (iLBC)", RFC 3951, December 2004.
- [2] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.
- [3] Schulzrinne, H., Casner, S., Frederick, R., and V. Jacobson, "RTP: A Transport Protocol for Real-Time Applications", STD 64, RFC 3550, July 2003.
- [4] Schulzrinne, H. and S. Casner, "RTP Profile for Audio and Video Conferences with Minimal Control", STD 65, RFC 3551, July 2003.
- [5] Handley, M. and V. Jacobson, "SDP: Session Description Protocol", RFC 2327, April 1998.
- [6] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. Norrman, "The Secure Real-time Transport Protocol", RFC 3711, March 2004.
7.2. Informative References
- [7] ITU-T Recommendation G.711, available online from the ITU bookstore at http://www.itu.int.
8. Acknowledgements ๐ซถ
Huge shoutouts to Henry Sinnreich, Patrik Faltstrom, Alan Johnston and Jean-Francois Mule. They gave great support to the iLBC initiative, plus valuable feedback and comments. Iconic behaviour ๐
Authors' Addresses ๐ธ
Alan Duric
Telio AS
Stoperigt. 2
Oslo, N-0250
Norway
Phone: +47 21673505
EMail: alan.duric@telio.no
Soren Vang Andersen
Department of Communication Technology
Aalborg University
Fredrik Bajers Vej 7A
9200 Aalborg
Denmark
Phone: ++45 9 6358627
EMail: sva@kom.auc.dk
Full Copyright Statement โ๏ธ
Here's the legal stuff, kept word for word:
Copyright (C) The Internet Society (2004).
This document is subject to the rights, licenses and restrictions
contained in BCP 78, and except as set forth therein, the authors
retain all their rights.
This document and the information contained herein are provided on an
"AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET
ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Intellectual Property ๐
The IETF takes no position regarding the validity or scope of any
Intellectual Property Rights or other rights that might be claimed to
pertain to the implementation or use of the technology described in
this document or the extent to which any license under such rights
might or might not be available; nor does it represent that it has
made any independent effort to identify any such rights. Information
on the IETF's procedures with respect to rights in IETF Documents can
be found in BCP 78 and BCP 79.
Copies of IPR disclosures made to the IETF Secretariat and any
assurances of licenses to be made available, or the result of an
attempt made to obtain a general license or permission for the use of
such proprietary rights by implementers or users of this
specification can be obtained from the IETF on-line IPR repository at
http://www.ietf.org/ipr.
The IETF invites any interested party to bring to its attention any
copyrights, patents or patent applications, or other proprietary
rights that may cover technology that may be required to implement
this standard. Please address the information to the IETF at ietf-
ipr@ietf.org.
Acknowledgement ๐
Funding for the RFC Editor function is currently provided by the
Internet Society.
๐ฆ where this page comes from
- ietf: rfc3952 2004-12
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms