dect
/
asterisk
Archived
13
0
Fork 0

HUGE improvements to QoS/CoS handling by IgorG

- Refer to the proper documentation
- Implement separate signalling/media QoS/CoS in many channels using RTP
- Improve warnings and verbose messages
- Deprecate some old settings

Minor modifications by me, a big effort from IgorG.
Thanks!


Reported by: IgorG
Patches: 
      qoscleanup-89394-4-trunk.patch uploaded by IgorG (license 20)
Tested by: IgorG
(closes issue #11145)


git-svn-id: http://svn.digium.com/svn/asterisk/trunk@93163 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
oej 2007-12-16 10:51:53 +00:00
parent 85bbad5334
commit b9b03966fb
24 changed files with 242 additions and 122 deletions

View File

@ -116,6 +116,11 @@ Skinny changes
-------------
* Added skinny show device, skinny show line, and skinny show settings CLI commands.
* Proper codec support in chan_skinny.
* Added settings for IP and Ethernet QoS requests
MGCP changes
------------
* Added separate settings for media QoS in mgcp.conf
DUNDi changes
-------------

View File

@ -132,6 +132,9 @@ Channel Drivers:
* chan_local.c: the comma delimiter inside the channel name has been changed to a
semicolon, in order to make the Local channel driver compatible with the comma
delimiter change in applications.
* H323: The "tos" setting has changed name to "tos_audio" and "cos" to "cos_audio"
to be compatible with settings in sip.conf. The "tos" and "cos" configuration
is deprecated and will stop working in the next release of Asterisk.
Configuration:

View File

@ -970,7 +970,7 @@ static int __oh323_rtp_create(struct oh323_pvt *pvt)
if (h323debug)
ast_debug(1, "Created RTP channel\n");
ast_rtp_setqos(pvt->rtp, tos, cos);
ast_rtp_setqos(pvt->rtp, tos, cos, "H323 RTP");
if (h323debug)
ast_debug(1, "Setting NAT on RTP to %d\n", pvt->options.nat);
@ -2904,13 +2904,23 @@ static int reload_config(int is_reload)
} else {
memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr));
}
} else if (!strcasecmp(v->name, "tos")) {
} else if (!strcasecmp(v->name, "tos")) { /* Needs to be removed in next release */
ast_log(LOG_WARNING, "The \"tos\" setting is deprecated in this version of Asterisk. Please change to \"tos_audio\".\n");
if (ast_str2tos(v->value, &tos)) {
ast_log(LOG_WARNING, "Invalid tos value at line %d, for more info read doc/qos.tex\n", v->lineno);
ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, refer to QoS documentation\n", v->lineno);
}
} else if (!strcasecmp(v->name, "cos")) {
} else if (!strcasecmp(v->name, "tos_audio")) {
if (ast_str2tos(v->value, &tos)) {
ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, refer to QoS documentation\n", v->lineno);
}
} else if (!strcasecmp(v->name, "cos")) {
ast_log(LOG_WARNING, "The \"cos\" setting is deprecated in this version of Asterisk. Please change to \"cos_audio\".\n");
if (ast_str2cos(v->value, &cos)) {
ast_log(LOG_WARNING, "Invalid cos value at line %d, for more info read doc/qos.tex\n", v->lineno);
ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno);
}
} else if (!strcasecmp(v->name, "cos_audio")) {
if (ast_str2cos(v->value, &cos)) {
ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno);
}
} else if (!strcasecmp(v->name, "gatekeeper")) {
if (!strcasecmp(v->value, "DISABLE")) {

View File

@ -10422,13 +10422,13 @@ static int set_config(char *config_file, int reload)
tosval = ast_variable_retrieve(cfg, "general", "tos");
if (tosval) {
if (ast_str2tos(tosval, &tos))
ast_log(LOG_WARNING, "Invalid tos value, see doc/qos.tex for more information.\n");
ast_log(LOG_WARNING, "Invalid tos value, refer to QoS documentation\n");
}
/* Seed initial cos value */
tosval = ast_variable_retrieve(cfg, "general", "cos");
if (tosval) {
if (ast_str2cos(tosval, &cos))
ast_log(LOG_WARNING, "Invalid cos value, see doc/qos.tex for more information.\n");
ast_log(LOG_WARNING, "Invalid cos value, refer to QoS documentation\n");
}
while(v) {
if (!strcasecmp(v->name, "bindport")){
@ -10601,10 +10601,10 @@ static int set_config(char *config_file, int reload)
ast_context_create(NULL, regcontext, "IAX2");
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, see doc/qos.tex for more information.'\n", v->lineno);
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos")) {
if (ast_str2cos(v->value, &cos))
ast_log(LOG_WARNING, "Invalid cos value at line %d, see doc/qos.tex for more information.'\n", v->lineno);
ast_log(LOG_WARNING, "Invalid cos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "accountcode")) {
ast_copy_string(accountcode, v->value, sizeof(accountcode));
} else if (!strcasecmp(v->name, "mohinterpret")) {

View File

@ -153,8 +153,9 @@ static ast_group_t cur_callergroup = 0;
static ast_group_t cur_pickupgroup = 0;
static unsigned int tos = 0;
static unsigned int tos_audio = 0;
static unsigned int cos = 0;
static unsigned int cos_audio = 0;
static int immediate = 0;
@ -2591,8 +2592,10 @@ static void start_rtp(struct mgcp_subchannel *sub)
sub->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
if (sub->rtp && sub->owner)
ast_channel_set_fd(sub->owner, 0, ast_rtp_fd(sub->rtp));
if (sub->rtp)
if (sub->rtp) {
ast_rtp_setqos(sub->rtp, tos_audio, cos_audio, "MGCP RTP");
ast_rtp_setnat(sub->rtp, sub->nat);
}
#if 0
ast_rtp_set_callback(p->rtp, rtpready);
ast_rtp_set_data(p->rtp, p);
@ -4097,10 +4100,16 @@ static int reload_config(int reload)
capability &= ~format;
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, see doc/qos.tex for more information.\n", v->lineno);
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "tos_audio")) {
if (ast_str2tos(v->value, &tos_audio))
ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos")) {
if (ast_str2cos(v->value, &cos))
ast_log(LOG_WARNING, "Invalid cos value at line %d, see doc/qos.tex for more information.\n", v->lineno);
ast_log(LOG_WARNING, "Invalid cos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos_audio")) {
if (ast_str2cos(v->value, &cos_audio))
ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "port")) {
if (sscanf(v->value, "%d", &ourport) == 1) {
bindaddr.sin_port = htons(ourport);
@ -4184,7 +4193,7 @@ static int reload_config(int reload)
} else {
ast_verb(2, "MGCP Listening on %s:%d\n",
ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
ast_netsock_set_qos(mgcpsock, tos, cos);
ast_netsock_set_qos(mgcpsock, tos, cos, "MGCP");
}
}
ast_mutex_unlock(&netlock);

View File

@ -545,7 +545,7 @@ static const struct cfsip_options {
#define DEFAULT_COS_SIP 4
#define DEFAULT_COS_AUDIO 5
#define DEFAULT_COS_VIDEO 6
#define DEFAULT_COS_TEXT 0
#define DEFAULT_COS_TEXT 5
#define DEFAULT_ALLOW_EXT_DOM TRUE
#define DEFAULT_REALM "asterisk"
#define DEFAULT_NOTIFYRINGING TRUE
@ -5130,14 +5130,14 @@ static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *si
ast_free(p);
return NULL;
}
ast_rtp_setqos(p->rtp, global_tos_audio, global_cos_audio);
ast_rtp_setqos(p->rtp, global_tos_audio, global_cos_audio, "SIP RTP");
ast_rtp_setdtmf(p->rtp, ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
ast_rtp_setdtmfcompensate(p->rtp, ast_test_flag(&p->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
ast_rtp_set_rtptimeout(p->rtp, global_rtptimeout);
ast_rtp_set_rtpholdtimeout(p->rtp, global_rtpholdtimeout);
ast_rtp_set_rtpkeepalive(p->rtp, global_rtpkeepalive);
if (p->vrtp) {
ast_rtp_setqos(p->vrtp, global_tos_video, global_cos_video);
ast_rtp_setqos(p->vrtp, global_tos_video, global_cos_video, "SIP VRTP");
ast_rtp_setdtmf(p->vrtp, 0);
ast_rtp_setdtmfcompensate(p->vrtp, 0);
ast_rtp_set_rtptimeout(p->vrtp, global_rtptimeout);
@ -5145,7 +5145,7 @@ static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *si
ast_rtp_set_rtpkeepalive(p->vrtp, global_rtpkeepalive);
}
if (p->trtp) {
ast_rtp_setqos(p->trtp, global_tos_text, global_cos_text);
ast_rtp_setqos(p->trtp, global_tos_text, global_cos_text, "SIP TRTP");
ast_rtp_setdtmf(p->trtp, 0);
ast_rtp_setdtmfcompensate(p->trtp, 0);
}
@ -18575,24 +18575,28 @@ static int reload_config(enum channelreloadreason reason)
registry_count++;
} else if (!strcasecmp(v->name, "tos_sip")) {
if (ast_str2tos(v->value, &global_tos_sip))
ast_log(LOG_WARNING, "Invalid tos_sip value at line %d, recommended value is 'cs3'. See doc/qos.tex.\n", v->lineno);
ast_log(LOG_WARNING, "Invalid tos_sip value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "tos_audio")) {
if (ast_str2tos(v->value, &global_tos_audio))
ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, recommended value is 'ef'. See doc/qos.tex.\n", v->lineno);
ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "tos_video")) {
if (ast_str2tos(v->value, &global_tos_video))
ast_log(LOG_WARNING, "Invalid tos_video value at line %d, recommended value is 'af41'. See doc/qos.tex.\n", v->lineno);
ast_log(LOG_WARNING, "Invalid tos_video value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "tos_text")) {
if (ast_str2tos(v->value, &global_tos_text))
ast_log(LOG_WARNING, "Invalid tos_text value at line %d, recommended value is 'af41'. See doc/qos.tex.\n", v->lineno);
ast_log(LOG_WARNING, "Invalid tos_text value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos_sip")) {
ast_str2cos(v->value, &global_cos_sip);
if (ast_str2cos(v->value, &global_cos_sip))
ast_log(LOG_WARNING, "Invalid cos_sip value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos_audio")) {
ast_str2cos(v->value, &global_cos_audio);
if (ast_str2cos(v->value, &global_cos_audio))
ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos_video")) {
ast_str2cos(v->value, &global_cos_video);
if (ast_str2cos(v->value, &global_cos_video))
ast_log(LOG_WARNING, "Invalid cos_video value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos_text")) {
ast_str2cos(v->value, &global_cos_text);
if (ast_str2cos(v->value, &global_cos_text))
ast_log(LOG_WARNING, "Invalid cos_text value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "bindport")) {
int i;
if (sscanf(v->value, "%d", &i) == 1) {
@ -18761,7 +18765,7 @@ static int reload_config(enum channelreloadreason reason)
} else {
ast_verb(2, "SIP Listening on %s:%d\n",
ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
ast_netsock_set_qos(sipsock, global_tos_sip, global_cos_sip);
ast_netsock_set_qos(sipsock, global_tos_sip, global_cos_sip, "SIP");
}
}
}

View File

@ -50,6 +50,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/sched.h"
#include "asterisk/io.h"
#include "asterisk/rtp.h"
#include "asterisk/netsock.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/cli.h"
@ -90,6 +91,13 @@ enum skinny_codecs {
#define DEFAULT_SKINNY_BACKLOG 2
#define SKINNY_MAX_PACKET 1000
static unsigned int tos = 0;
static unsigned int tos_audio = 0;
static unsigned int tos_video = 0;
static unsigned int cos = 0;
static unsigned int cos_audio = 0;
static unsigned int cos_video = 0;
static int keep_alive = 120;
static char vmexten[AST_MAX_EXTENSION]; /* Voicemail pilot number */
static char used_context[AST_MAX_EXTENSION]; /* Voicemail pilot number */
@ -2976,9 +2984,11 @@ static void start_rtp(struct skinny_subchannel *sub)
ast_channel_set_fd(sub->owner, 3, ast_rtcp_fd(sub->vrtp));
}
if (sub->rtp) {
ast_rtp_setqos(sub->rtp, tos_audio, cos_audio, "Skinny RTP");
ast_rtp_setnat(sub->rtp, l->nat);
}
if (sub->vrtp) {
ast_rtp_setqos(sub->vrtp, tos_video, cos_video, "Skinny VRTP");
ast_rtp_setnat(sub->vrtp, l->nat);
}
/* Set Frame packetization */
@ -5516,6 +5526,24 @@ static int reload_config(void)
ast_copy_string(regcontext, v->value, sizeof(regcontext));
} else if (!strcasecmp(v->name, "dateformat")) {
memcpy(date_format, v->value, sizeof(date_format));
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "tos_audio")) {
if (ast_str2tos(v->value, &tos_audio))
ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "tos_video")) {
if (ast_str2tos(v->value, &tos_video))
ast_log(LOG_WARNING, "Invalid tos_video value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos")) {
if (ast_str2cos(v->value, &cos))
ast_log(LOG_WARNING, "Invalid cos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos_audio")) {
if (ast_str2cos(v->value, &cos_audio))
ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos_video")) {
if (ast_str2cos(v->value, &cos_video))
ast_log(LOG_WARNING, "Invalid cos_video value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "allow")) {
ast_parse_allow_disallow(&default_prefs, &default_capability, v->value, 1);
} else if (!strcasecmp(v->name, "disallow")) {
@ -5604,6 +5632,7 @@ static int reload_config(void)
}
ast_verb(2, "Skinny listening on %s:%d\n",
ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
ast_netsock_set_qos(skinnysock, tos, cos, "Skinny");
ast_pthread_create_background(&accept_t,NULL, accept_thread, NULL);
}
}

View File

@ -59,6 +59,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/sched.h"
#include "asterisk/io.h"
#include "asterisk/rtp.h"
#include "asterisk/netsock.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/cli.h"
@ -214,6 +215,10 @@ static int unistim_port;
static enum autoprovision autoprovisioning = AUTOPROVISIONING_NO;
static int unistim_keepalive;
static int unistimsock = -1;
static unsigned int tos = 0;
static unsigned int tos_audio = 0;
static unsigned int cos = 0;
static unsigned int cos_audio = 0;
static struct io_context *io;
static struct sched_context *sched;
static struct sockaddr_in public_ip = { 0, };
@ -2075,8 +2080,10 @@ static void start_rtp(struct unistim_subchannel *sub)
sub->owner->fds[0] = ast_rtp_fd(sub->rtp);
sub->owner->fds[1] = ast_rtcp_fd(sub->rtp);
}
if (sub->rtp)
if (sub->rtp) {
ast_rtp_setqos(sub->rtp, tos_audio, cos_audio, "UNISTIM RTP");
ast_rtp_setnat(sub->rtp, sub->parent->parent->nat);
}
/* Create the RTP connection */
ast_rtp_get_us(sub->rtp, &us);
@ -5330,7 +5337,19 @@ static int reload_config(void)
unistim_keepalive = atoi(v->value);
else if (!strcasecmp(v->name, "port"))
unistim_port = atoi(v->value);
else if (!strcasecmp(v->name, "autoprovisioning")) {
else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "tos_audio")) {
if (ast_str2tos(v->value, &tos_audio))
ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos")) {
if (ast_str2cos(v->value, &cos))
ast_log(LOG_WARNING, "Invalid cos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos_audio")) {
if (ast_str2cos(v->value, &cos_audio))
ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "autoprovisioning")) {
if (!strcasecmp(v->value, "no"))
autoprovisioning = AUTOPROVISIONING_NO;
else if (!strcasecmp(v->value, "yes"))
@ -5511,6 +5530,7 @@ static int reload_config(void)
"UNISTIM Listening on %s:%d\n",
ast_inet_ntoa(bindaddr.sin_addr), htons(bindaddr.sin_port));
}
ast_netsock_set_qos(unistimsock, tos, cos, "UNISTIM");
}
return 0;
}

View File

@ -323,7 +323,7 @@ static int iax_template_parse(struct iax_template *cur, struct ast_config *cfg,
ast_log(LOG_WARNING, "Ignoring invalid codec '%s' for '%s' at line %d\n", v->value, s, v->lineno);
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &cur->tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, see doc/qos.tex for more information.\n", v->lineno);
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "user")) {
strncpy(cur->user, v->value, sizeof(cur->user) - 1);
if (strcmp(cur->user, v->value))

View File

@ -27,7 +27,7 @@
;bindaddr=0.0.0.0
;port=4520
;
; See doc/qos.tex for a description of the tos parameter.
; See qos.tex or Quality of Service section of asterisk.pdf for a description of the tos parameter.
;tos=ef
;
; Our entity identifier (Should generally be the MAC address of the

View File

@ -4,7 +4,10 @@
[general]
port = 1720
;bindaddr = 1.2.3.4 ; this SHALL contain a single, valid IP address for this machine
;tos=ef
;
; See qos.tex or Quality of Service section of asterisk.pdf for a description of these parameters.
;tos_audio=ef ; Sets TOS for RTP audio packets.
;cos_audio=5 ; Sets 802.1p priority for RTP audio packets.
;
; You may specify a global default AMA flag for iaxtel calls. It must be
; one of 'default', 'omit', 'billing', or 'documentation'. These flags

View File

@ -225,7 +225,7 @@ forcejitterbuffer=no
;
;authdebug=no
;
; See doc/qos.tex for a description of the tos parameters.
; See qos.tex or Quality of Service section of asterisk.pdf for a description of these parameters.
;tos=ef
;cos=5
;

View File

@ -53,7 +53,7 @@ codec=ulaw
;
flags=register,heartbeat
;
; See doc/qos.tex for a description of this parameter.
; See qos.tex or Quality of Service section of asterisk.pdf for a description of this parameter.
;tos=ef
;
; Example iaxy provisioning

View File

@ -5,8 +5,11 @@
;port = 2427
;bindaddr = 0.0.0.0
; See doc/qos.tex for a description of the tos parameters.
;tos=ef
; See qos.tex or Quality of Service section of asterisk.pdf for a description of these parameters.
;tos=cs3 ; Sets TOS for signaling packets.
;tos_audio=ef ; Sets TOS for RTP audio packets.
;cos=3 ; Sets 802.1p priority for signaling packets.
;cos_audio=5 ; Sets 802.1p priority for RTP audio packets.
;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
; jbenable = yes ; Enables the use of a jitterbuffer on the receiving side of a

View File

@ -66,16 +66,16 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
; and multiline formatted headers for strict
; SIP compatibility (defaults to "no")
; See doc/qos.tex for a description of these parameters.
; See qos.tex or Quality of Service section of asterisk.pdf for a description of these parameters.
;tos_sip=cs3 ; Sets TOS for SIP packets.
;tos_audio=ef ; Sets TOS for RTP audio packets.
;tos_video=af41 ; Sets TOS for RTP video packets.
;tos_text=af41 ; Sets TOS for RTP text packets.
;cos_sip=4 ; Sets CoS for SIP packets.
;cos_audio=6 ; Sets CoS for RTP audio packets.
;cos_video=5 ; Sets CoS for RTP video packets.
;cos_text=0 ; Sets CoS for RTP text packets.
;cos_sip=3 ; Sets 802.1p priority for SIP packets.
;cos_audio=5 ; Sets 802.1p priority for RTP audio packets.
;cos_video=4 ; Sets 802.1p priority for RTP video packets.
;cos_text=3 ; Sets 802.1p priority for RTP text packets.
;maxexpiry=3600 ; Maximum allowed time of incoming registrations
; and subscriptions (seconds)

View File

@ -28,6 +28,14 @@ keepalive=120
;allow=all ; see doc/rtp-packetization for framing options
;disallow=
; See qos.tex or Quality of Service section of asterisk.pdf for a description of these parameters.
;tos=cs3 ; Sets TOS for signaling packets.
;tos_audio=ef ; Sets TOS for RTP audio packets.
;tos_video=af41 ; Sets TOS for RTP video packets.
;cos=3 ; Sets 802.1p priority for signaling packets.
;cos_audio=5 ; Sets 802.1p priority for RTP audio packets.
;cos_video=4 ; Sets 802.1p priority for RTP video packets.
;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
;jbenable = yes ; Enables the use of a jitterbuffer on the receiving side of a
; skinny channel. Defaults to "no". An enabled jitterbuffer will

View File

@ -4,6 +4,13 @@
[general]
port=5000 ; UDP port
;
; See qos.tex or Quality of Service section of asterisk.pdf for a description of these parameters.
;tos=cs3 ; Sets TOS for signaling packets.
;tos_audio=ef ; Sets TOS for RTP audio packets.
;cos=3 ; Sets 802.1p priority for signaling packets.
;cos_audio=5 ; Sets 802.1p priority for RTP audio packets.
;
;keepalive=120 ; in seconds, default = 120
;public_ip= ; if asterisk is behind a nat, specify your public IP
;autoprovisioning=no ; Allow undeclared phones to register an extension. See README for important

View File

@ -1,31 +1,85 @@
\subsubsection{Introduction}
Asterisk can set the Type of Service (TOS) byte on outgoing IP packets
for various protocols. The TOS byte is used by the network to provide
some level of Quality of Service (QoS) even if the network is
congested with other traffic.
Asterisk support different QoS settings on application level on various protocol
on any of signaling and media. Type of Service (TOS) byte can be set on
outgoing IP packets for various protocols. The TOS byte is used by the network
to provide some level of Quality of Service (QoS) even if the network is
congested with other traffic.
Also asterisk running on Linux can set 802.1p CoS marks in VLAN packets
for all used VoIP protocols. It is useful when you are working in switched
enviropment. For maping skb-$>$priority and VLAN CoS mark you need to use
command "vconfig set\_egress\_map [vlan-device] [skb-priority] [vlan-qos]".
Also asterisk running on Linux can set 802.1p CoS marks in VLAN packets for all
used VoIP protocols. It is useful when you are working in switched environment.
In fact asterisk only set priority for Linux socket. For mapping this priority
and VLAN CoS mark you need to use this command:
\subsubsection{SIP}
\begin{verbatim}
vconfig set_egress_map [vlan-device] [skb-priority] [vlan-qos]
\end{verbatim}
In sip.conf, there are three parameters that control the TOS settings:
"tos\_sip", "tos\_audio" and "tos\_video". tos\_sip controls what TOS SIP
call signalling packets are set to. tos\_audio controls what TOS RTP audio
packets are set to. tos\_video controls what TOS RTP video packets are
set to.
In table behind shown all voice channels and other modules of asterisk, that
support QoS settings for network traffic and type of traffic which can have
QoS settings.
There are four parameters to control 802.1p CoS: "cos\_sip", "cos\_audio",
"cos\_video" and "cos\_text". It's behavior the same as writen above.
\begin{verbatim}
Channel Drivers
+==============+===========+=====+=====+=====+
| | Signaling |Audio|Video| Text|
+==============+===========+=====+=====+=====+
|chan_sip | + | + | + | + |
|--------------+-----------+-----+-----+-----+
|chan_skinny | + | + | + | |
|--------------+-----------+-----+-----+-----+
|chan_mgcp | + | + | | |
|--------------+-----------+-----+-----+-----+
|chan_unistim | + | + | | |
|--------------+-----------+-----+-----+-----+
|chan_h323 | | + | | |
|--------------+-----------+-----+-----+-----+
|chan_iax2 | + |
+==============+=============================+
Other
+==============+=============================+
| dundi.conf | + (tos setting) |
|--------------+-----------------------------+
| iaxprov.conf | + (tos setting) |
+==============+=============================+
\end{verbatim}
There is a "tos" parameter that is supported for backwards
compatibility. The tos parameter should be avoided in sip.conf
because it sets all three tos settings in sip.conf to the same value.
\subsubsection{IP TOS values}
The allowable values for any of the tos* parameters are:
CS0, CS1, CS2, CS3, CS4, CS5, CS6, CS7, AF11, AF12, AF13, AF21, AF22, AF23,
AF31, AF32, AF33, AF41, AF42, AF43 and ef (expedited forwarding),
The tos* parameters also take numeric values.
NOTE, that on Linux system you can not use ef value if your asterisk running
from user other then root.
The lowdelay, throughput, reliability, mincost, and none values are removed
in current releases.
\subsubsection{802.1p CoS values}
As far as 802.1p uses 3 bites from VLAN header, there are parameter can take
integer values from 0 to 7.
\subsubsection{Recommended values}
Recommended values shown above and also included in sample configuration files:
\begin{verbatim}
+============+=========+======+
| | tos | cos |
+============+=========+======+
|Signaling | cs3 | 3 |
|Audio | ef | 5 |
|Video | af41 | 4 |
|Text | af41 | 3 |
|Other | ef | |
+============+=========+======+
\end{verbatim}
\subsubsection{IAX2}
In iax.conf, there is a "tos" parameter that sets the global default TOS
for IAX packets generated by chan\_iax2. Since IAX connections combine
signalling, audio, and video into one UDP stream, it is not possible
@ -37,56 +91,22 @@ IAX packets generated by an IAXy cannot have different TOS settings
based upon the type of packet. However different IAXy devices can
have different TOS settings.
\subsubsection{H.323}
Also support TOS and CoS.
\subsubsection{SIP}
\subsubsection{MGCP}
Also support TOS and CoS.
In sip.conf, there are three parameters that control the TOS settings:
"tos\_sip", "tos\_audio", "tos\_video" and "tos\_text". tos\_sip controls
what TOS SIP call signaling packets are set to. tos\_audio, tos\_video
and tos\_text controls what TOS RTP audio, video or text accordingly
packets are set to.
\subsubsection{IP TOS values}
There are four parameters to control 802.1p CoS: "cos\_sip", "cos\_audio",
"cos\_video" and "cos\_text". It behavior the same as written above.
The allowable values for any of the tos* parameters are:
CS0, CS1, CS2, CS3, CS4, CS5, CS6, CS7, AF11, AF12, AF13,
AF21, AF22, AF23, AF31, AF32, AF33, AF41, AF42, AF43 and
ef (expedited forwarding),
\subsubsection{Other RTP channels}
The tos* parameters also take numeric values.
The lowdelay, throughput, reliability, mincost, and none values are
removed in current releases.
\subsubsection{802.1p CoS values}
As 802.1p uses 3 bites from VLAN header, there are parameter can take
integer values from 0 to 7.
\begin{verbatim}
+==============+============+==============+
|Configuration | Parameter | Recommended |
|File | Setting | |
+--------------+------------+--------------+
| | tos_sip | cs3 |
| | tos_audio | ef |
| | tos_video | af41 |
| sip.conf | tos_text | af41 |
| | cos_sip | 4 |
| | cos_audio | 6 |
| | cos_video | 5 |
| | cos_text | 0 |
+--------------+------------+--------------+
| iax.conf | tos | ef |
| | cos | 6 |
+--------------+------------+--------------+
| iaxprov.conf | tos | ef |
+--------------+------------+--------------+
| mgcp.conf | tos | ef |
| | cos | 6 |
+--------------+------------+--------------+
| h323.conf | tos | ef |
| | cos | 6 |
+==============+============+==============+
\end{verbatim}
chan\_mgcp, chan\_h323, chan\_skinny and chan\_unistim also support TOS and
CoS via setting tos and cos parameters in correspond to module config
files. Naming style and behavior same as for chan\_sip.
\subsubsection{Reference}
@ -113,4 +133,3 @@ For more information on Quality of
Service for VoIP networks see the "Enterprise QoS Solution Reference
Network Design Guide" version 3.3 from Cisco at:
\url{http://www.cisco.com/application/pdf/en/us/guest/netsol/ns432/c649/ccmigration\_09186a008049b062.pdf}

View File

@ -53,7 +53,7 @@ int ast_netsock_release(struct ast_netsock_list *list);
struct ast_netsock *ast_netsock_find(struct ast_netsock_list *list,
struct sockaddr_in *sa);
int ast_netsock_set_qos(int netsocket, int tos, int cos);
int ast_netsock_set_qos(int netsocket, int tos, int cos, const char *desc);
int ast_netsock_sockfd(const struct ast_netsock *ns);

View File

@ -168,7 +168,7 @@ int ast_rtp_senddigit_end(struct ast_rtp *rtp, char digit);
int ast_rtp_sendcng(struct ast_rtp *rtp, int level);
int ast_rtp_setqos(struct ast_rtp *rtp, int tos, int cos);
int ast_rtp_setqos(struct ast_rtp *rtp, int tos, int cos, char *desc);
/*! \brief Setting RTP payload types from lines in a SDP description: */
void ast_rtp_pt_clear(struct ast_rtp* rtp);

View File

@ -117,7 +117,7 @@ struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct i
return NULL;
}
ast_netsock_set_qos(netsocket, tos, cos);
ast_netsock_set_qos(netsocket, tos, cos, "IAX2");
ast_enable_packet_fragmentation(netsocket);
@ -143,20 +143,20 @@ struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct i
return ns;
}
int ast_netsock_set_qos(int netsocket, int tos, int cos)
int ast_netsock_set_qos(int netsocket, int tos, int cos, const char *desc)
{
int res;
if ((res = setsockopt(netsocket, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))))
ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos);
else
ast_verb(2, "Using TOS bits %d\n", tos);
ast_log(LOG_WARNING, "Unable to set %s TOS to %d, may be you have no root privileges\n", desc, tos);
else if (tos)
ast_verb(2, "Using %s TOS bits %d\n", desc, tos);
#if defined(linux)
if (setsockopt(netsocket, SOL_SOCKET, SO_PRIORITY, &cos, sizeof(cos)))
ast_log(LOG_WARNING, "Unable to set CoS to %d\n", cos);
else
ast_verb(2, "Using CoS mark %d\n", cos);
ast_log(LOG_WARNING, "Unable to set %s CoS to %d\n", desc, cos);
else if (cos)
ast_verb(2, "Using %s CoS mark %d\n", desc, cos);
#endif
return res;

View File

@ -2292,9 +2292,9 @@ struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io,
return ast_rtp_new_with_bindaddr(sched, io, rtcpenable, callbackmode, ia);
}
int ast_rtp_setqos(struct ast_rtp *rtp, int tos, int cos)
int ast_rtp_setqos(struct ast_rtp *rtp, int tos, int cos, char *desc)
{
return ast_netsock_set_qos(rtp->s, tos, cos);
return ast_netsock_set_qos(rtp->s, tos, cos, desc);
}
void ast_rtp_set_peer(struct ast_rtp *rtp, struct sockaddr_in *them)

View File

@ -849,7 +849,7 @@ struct ast_udptl *ast_udptl_new(struct sched_context *sched, struct io_context *
int ast_udptl_setqos(struct ast_udptl *udptl, int tos, int cos)
{
return ast_netsock_set_qos(udptl->fd, tos, cos);
return ast_netsock_set_qos(udptl->fd, tos, cos, "UDPTL");
}
void ast_udptl_set_peer(struct ast_udptl *udptl, struct sockaddr_in *them)

View File

@ -4722,7 +4722,7 @@ static int set_config(char *config_file, struct sockaddr_in* sin, int reload)
ast_log(LOG_WARNING, "Invalid global endpoint identifier '%s' at line %d\n", v->value, v->lineno);
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, please read docs/qos.tex\n", v->lineno);
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "department")) {
ast_copy_string(dept, v->value, sizeof(dept));
} else if (!strcasecmp(v->name, "organization")) {
@ -4856,7 +4856,7 @@ static int load_module(void)
return AST_MODULE_LOAD_FAILURE;
}
ast_netsock_set_qos(netsocket, tos, 0);
ast_netsock_set_qos(netsocket, tos, 0, "DUNDi");
if (start_network_thread()) {
ast_log(LOG_ERROR, "Unable to start network thread\n");