Index: pbx/pbx_dundi.c =================================================================== --- pbx/pbx_dundi.c (revision 89394) +++ pbx/pbx_dundi.c (working copy) @@ -4724,7 +4724,7 @@ 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")) { @@ -4858,7 +4858,7 @@ 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"); Index: channels/chan_h323.c =================================================================== --- channels/chan_h323.c (revision 89394) +++ channels/chan_h323.c (working copy) @@ -973,7 +973,7 @@ 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); @@ -2854,13 +2854,13 @@ } else { memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr)); } - } else if (!strcasecmp(v->name, "tos")) { + } else if (!strcasecmp(v->name, "tos_audio")) { 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, "cos_audio")) { 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, "gatekeeper")) { if (!strcasecmp(v->value, "DISABLE")) { Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 89394) +++ channels/chan_sip.c (working copy) @@ -523,9 +523,9 @@ #define DEFAULT_TOS_AUDIO 0 /*!< Audio packets should be marked as DSCP EF (Expedited Forwarding), but the default is 0 to be compatible with previous versions. */ #define DEFAULT_TOS_VIDEO 0 /*!< Video packets should be marked as DSCP AF41, but the default is 0 to be compatible with previous versions. */ #define DEFAULT_TOS_TEXT 0 /*!< Text packets should be marked as XXXX XXXX, but the default is 0 to be compatible with previous versions. */ -#define DEFAULT_COS_SIP 4 -#define DEFAULT_COS_AUDIO 5 -#define DEFAULT_COS_VIDEO 6 +#define DEFAULT_COS_SIP 0 +#define DEFAULT_COS_AUDIO 0 +#define DEFAULT_COS_VIDEO 0 #define DEFAULT_COS_TEXT 0 #define DEFAULT_ALLOW_EXT_DOM TRUE #define DEFAULT_REALM "asterisk" @@ -5039,14 +5039,14 @@ 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); @@ -5054,7 +5054,7 @@ 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); } @@ -18298,24 +18298,28 @@ 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) { @@ -18484,7 +18488,7 @@ } 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"); } } } Index: channels/iax2-provision.c =================================================================== --- channels/iax2-provision.c (revision 89394) +++ channels/iax2-provision.c (working copy) @@ -325,7 +325,7 @@ 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)) Index: channels/chan_iax2.c =================================================================== --- channels/chan_iax2.c (revision 89394) +++ channels/chan_iax2.c (working copy) @@ -10377,13 +10377,13 @@ 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")){ @@ -10556,10 +10556,10 @@ 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")) { Index: channels/chan_skinny.c =================================================================== --- channels/chan_skinny.c (revision 89394) +++ channels/chan_skinny.c (working copy) @@ -53,6 +53,7 @@ #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" @@ -93,6 +94,13 @@ #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 regcontext[AST_MAX_CONTEXT]; /* Context for auto-extension */ @@ -2978,9 +2986,11 @@ 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 */ @@ -5517,6 +5527,24 @@ 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")) { @@ -5605,6 +5633,7 @@ } 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); } } Index: channels/chan_mgcp.c =================================================================== --- channels/chan_mgcp.c (revision 89394) +++ channels/chan_mgcp.c (working copy) @@ -156,8 +156,9 @@ 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; @@ -2594,8 +2595,10 @@ 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); @@ -4099,10 +4102,16 @@ 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); @@ -4186,7 +4195,7 @@ } 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); Index: channels/chan_unistim.c =================================================================== --- channels/chan_unistim.c (revision 89394) +++ channels/chan_unistim.c (working copy) @@ -61,6 +61,7 @@ #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" @@ -215,6 +216,10 @@ 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, }; @@ -2115,8 +2120,10 @@ 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); @@ -5375,7 +5382,19 @@ 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")) @@ -5556,6 +5575,7 @@ "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; } Index: doc/tex/qos.tex =================================================================== --- doc/tex/qos.tex (revision 89394) +++ doc/tex/qos.tex (working copy) @@ -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,57 +91,23 @@ 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. +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. -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} - \subsubsection{Reference} IEEE 802.1Q Standard: @@ -113,4 +133,3 @@ 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} - Index: include/asterisk/rtp.h =================================================================== --- include/asterisk/rtp.h (revision 89394) +++ include/asterisk/rtp.h (working copy) @@ -168,7 +168,7 @@ 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); Index: include/asterisk/netsock.h =================================================================== --- include/asterisk/netsock.h (revision 89394) +++ include/asterisk/netsock.h (working copy) @@ -53,7 +53,7 @@ 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); Index: main/rtp.c =================================================================== --- main/rtp.c (revision 89394) +++ main/rtp.c (working copy) @@ -2281,9 +2281,9 @@ 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) Index: main/udptl.c =================================================================== --- main/udptl.c (revision 89394) +++ main/udptl.c (working copy) @@ -863,7 +863,7 @@ 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) Index: main/netsock.c =================================================================== --- main/netsock.c (revision 89394) +++ main/netsock.c (working copy) @@ -131,7 +131,7 @@ return NULL; } - ast_netsock_set_qos(netsocket, tos, cos); + ast_netsock_set_qos(netsocket, tos, cos, "IAX2"); ast_enable_packet_fragmentation(netsocket); @@ -157,24 +157,27 @@ 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); + ast_log(LOG_WARNING, "Unable to set %s TOS to %d, may be you have no root privileges\n", desc, tos); else { - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Using TOS bits %d\n", tos); + if (option_verbose > 1 && tos) + ast_verbose(VERBOSE_PREFIX_2 "Using %s TOS bits %d\n", desc, tos); } -#if defined(linux) +#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); + ast_log(LOG_WARNING, "Unable to set %s CoS to %d\n", desc, cos); else { - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Using CoS mark %d\n", cos); + if (option_verbose > 1 && cos) + ast_verbose(VERBOSE_PREFIX_2 "Using %s CoS mark %d\n", desc, cos); } +#else + if (cos) + ast_log(LOG_WARNING, "Using 802.1p priority isn't supported on your system!\n"); #endif return res; Index: configs/skinny.conf.sample =================================================================== --- configs/skinny.conf.sample (revision 89394) +++ configs/skinny.conf.sample (working copy) @@ -28,6 +28,14 @@ ;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 Index: configs/iax.conf.sample =================================================================== --- configs/iax.conf.sample (revision 89394) +++ configs/iax.conf.sample (working copy) @@ -225,7 +225,7 @@ ; ;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 ; Index: configs/mgcp.conf.sample =================================================================== --- configs/mgcp.conf.sample (revision 89394) +++ configs/mgcp.conf.sample (working copy) @@ -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 Index: configs/sip.conf.sample =================================================================== --- configs/sip.conf.sample (revision 89394) +++ configs/sip.conf.sample (working copy) @@ -57,16 +57,16 @@ ; 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) Index: configs/iaxprov.conf.sample =================================================================== --- configs/iaxprov.conf.sample (revision 89394) +++ configs/iaxprov.conf.sample (working copy) @@ -53,7 +53,7 @@ ; 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 Index: configs/unistim.conf.sample =================================================================== --- configs/unistim.conf.sample (revision 89394) +++ configs/unistim.conf.sample (working copy) @@ -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 Index: configs/dundi.conf.sample =================================================================== --- configs/dundi.conf.sample (revision 89394) +++ configs/dundi.conf.sample (working copy) @@ -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 Index: configs/h323.conf.sample =================================================================== --- configs/h323.conf.sample (revision 89394) +++ configs/h323.conf.sample (working copy) @@ -4,8 +4,11 @@ [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 ; are used in the generation of call detail records.