Liever in het Nederlands? Klik hier.

Fritz box nice-to-knows

Use nvi instead of vi.

When editing .cfg files in the fritz box, vi is not an option. Instead use "nvi". This is a script made by AVM. It will copy the data in the .cfg to a normal format, allow you to edit it, and write it back in the special format that is needed.

Adjusting the used codecs in your fritz!box. < tip

First thing to do is switch-on telnet by dialing #96*7* Attention: This makes the webinterface display the message: "The modifications to your FRITZ!Box are not supported by the manufacturer." or in the newer firmware "Changes not supported by manufacturer". The message does not bother me.

You will need putty or a dosbox to make a telnet connection to your fitz!box.

The file you need to edit is /var/flash/voip.cfg. It can be edited using
nvi /var/flash/voip.cfg

The interesting lines are:
     use_audiocodecs = no;
     audiocodecs = "PCMA", "PCMU", "G726-32";

Changing the no to a yes makes the fritz box use the codecs in a preference order shown in the second line. The default is not the best choise. G729 is realy needed to be able to receive calls from parties who only support this codec. This is how my settings look:

     use_audiocodecs = yes;
     audiocodecs = "PCMA", "PCMU", "G726-32", "G729";

Additionally you will need to restart the voipd deamon. This can be done using these commands:

     voipd -s     (to stop)
     voipd        (to start)

Wireshark / ethereal

After the change wireshark traces show this (g729 is missing; old screenshot):

Click to enlarge. Media type


Media Format: ITU-T G.711 PCMA = in the .cfg PCMA
Media Format: ITU-T G.711 PCMU = in the .cfg PCMU
Media Format: 101 = in the .cfg G726-32

The old list, seen with wireshark, before changing the no to yes looked like this.

fritz box media format

Packet trace

You can make a packet trace using your fritz box. Copy and past this link to you browser and things will get clear.

http://fritz.box/html/capture.html

How codec sellection works in VoIP?

A SIP invite contains a part called the "media description". In this part the the initiating party gives it's list of preferred codecs in order of frefference. The receiving party receives this list and comparis it to it's own list. If the first codec in the invite message is supported by the receiver, this will be used. If not, the next in the list will be sellected. In the SIP reply messge will be a 200 OK containing a list of codecs that are mutually supported. These will be in the same order as in the invite.

This means that for receiving or making a call, different codecs could be used if the preference order is different. The initiating party is sending the invite. For receiving a call you will receive the invite.

Why change this?

Because you experience bad audio quality and have seen in settings > telephony > internet telephony > voice transmission that you are using G.729a as a codec. This is a 8 Kbit codec and you probably would prefer G.711 which is a 64Kbit codec and delivers better audio.

Only budgetphone?

Yup. I use two VoIP providers. Voipbuster for outgoining and incomming calls and Budgetphone for incomming calls only. Only budgetphone gave me the codec issue. Why? I'll show you.

Here are the two media description parts of a SIP Invite comming into my fritz box.

First from an invite from budgetphone. G.729 is at the second place and G.711 is at the 4th.

Update Juli 2008: Budgetphone has changed their settings. PCMA and PCMU are the first two in their list. I do not know when this was changed.

budgetphone

And from an invite from voipbuster. G.711 is at the first place.

voipbuster

Which codec has which name?

Media description MIME Type    
8 PCMA = G711 64 Kb/s
0 PCMU = G711 64 Kb/s
18 G729   8 Kb/s
4 G723    

These are the most important codecs that I've seen. There are many more and the fritzbox supports many more. This site shows a more complete list.

Adjusting your fritz!box firewall.

No changes to the firewall can be made via the GUI. The only way is to use the telnet tool again. In /var/flash/you can find a file called ar7.cfg. This file can be edited using again nvi.

In this change I've blocked ICMP traffic from a certain host.

dsldpconfig {
security = dpsec_firewall;
lowinput {
policy = "permit";
accesslist =
"deny ip any 242.0.0.0 255.0.0.0",
"deny ip any host 255.255.255.255",
"deny udp any any eq 135",
"deny tcp any any eq 135",
"deny udp any any range 137 139",
"deny tcp any any range 137 139",
"deny udp any any range 161 162",
"deny udp any any eq 520",
"deny udp any any eq 111",
"deny udp any any eq 22289",
"deny udp any any eq 1710",
"deny udp any any eq 1048",
"deny udp any any eq 158",
"deny icmp host 81.207.240.17 any",
"deny udp any any eq 515";

ar7cfgchanged is the command that you need to enter after the change to apply the new settings.