IAX2 and INVAL packets

Home » Asterisk Users » IAX2 and INVAL packets
Asterisk Users 3 Comments

Is anybody here familiar with the meaning of INVAL packets for IAX2?

Every few days I get a dropped outgoing call in the middle of the
conversation (the outgoing call has been connected for few minutes) when
an incoming call comes in. The log reads the following when this happens:

[Nov 17 15:25:04] DEBUG[5138] chan_iax2.c: Immediately destroying 2963,
having received INVAL
[Nov 17 15:25:04] DEBUG[5138] chan_iax2.c: Destroying call 2963
[Nov 17 15:25:04] DEBUG[11242] chan_iax2.c: We’re hanging up
IAX2/ihs_trunk_out-2963 now…
[Nov 17 15:25:04] VERBOSE[11242] chan_iax2.c: — Hungup
‘IAX2/ihs_trunk_out-2963’

And more setup details, for those who still have the will to live 🙂

Asterisk version: 1.6.2.13
Internal externsions: everything on SIP – 3 Grandstream GXP-2000, 2
analog phones on a pci OpenVox card and 2 Linphone softphones
Trunks: IAX2
Trunks provider: Gradwell
Asterisk machine: 800Mhz Intel Pentium, 512MB of RAM
Internet connection: Tiscali business ADSL

I am happy to post here any config files and logs you might think would
be relevant.

This is not consistent – and I’ve managed to have 4 concurrent calls
which held 30 minutes (before I hung them up) when I tried. So not easy
to replicate.

Sebastian

3 thoughts on - IAX2 and INVAL packets

  • An INVAL response basically means that the remote Asterisk box received
    a packet for a call that it did not think existed. So likely, something
    else caused the call to hangup (such as an unrelated error crashing a
    process, and the replacement process had no record of such a call, so it
    sent an INVAL response to any subsequent packet).

    Technically, this could also be done as a MITM attack. If something were
    to see even a single packet related to the call, it is able to fake an
    INVAL packet. BTW, this is not unique to IAX2; a MITM attack can also fake
    a SIP CANCEL.

  • Hi Tilghman and thank you for replying. I have been working on narrowing
    this down for a few months now – without much success.

    Do you have any suggestions on taking further steps to find the cause?

    In case it helps:

    1. I use iptables to only allow in IAX2 connections from the IP
    addresses of the VoIP provider (Gradwell).
    2. I also restrict incoming connections in iax.conf only to the same ip
    ranges.

    The drops occur randomly, once every few days normally (but there have
    been some cases of few drops in one day).

    Again, not sure if it is relevant – but here is the same log – only
    including few extra earlier lines. The strange thing is that, just
    before hanging up the call I’m interested in (2963), it seems to be
    hanging up another call – it reads “destroying 706” – but I can’t find
    any reference to a call “706” anywhere earlier in the log. So I can’t
    understand what call is that, and why does it get hung-up:

    [Nov 17 15:25:01] DEBUG[5137] chan_iax2.c: Determining if address
    212.11.91.202 with username xxxxxxxxx_in requires calltoken validation.
    Optional = 1 calltoken_required = 0
    [Nov 17 15:25:01] DEBUG[5137] chan_iax2.c: ip callno count incremented
    to 1 for 212.11.91.202
    [Nov 17 15:25:01] DEBUG[5132] chan_iax2.c: Immediately destroying 706,
    having received hangup
    [Nov 17 15:25:01] DEBUG[5132] chan_iax2.c: schedule decrement of callno
    used for 212.11.91.202 in 60 seconds
    [Nov 17 15:25:04] DEBUG[5138] chan_iax2.c: Immediately destroying 2963,
    having received INVAL
    [Nov 17 15:25:04] DEBUG[5138] chan_iax2.c: Destroying call 2963
    [Nov 17 15:25:04] DEBUG[11242] chan_iax2.c: We’re hanging up
    IAX2/ihs_trunk_out-2963 now…
    [Nov 17 15:25:04] VERBOSE[11242] chan_iax2.c: — Hungup
    ‘IAX2/ihs_trunk_out-2963’

    Any suggestion to help take this further is much appreciated.

    Sebastian

  • Just answering myself here. After spending few months troubleshooting
    this completely erratic fault – it turns out that it was the ADSL
    router. I still don’t know for certain the exact mechanism of the fault
    – but it looks like my IAX provider would receive some packets which
    were invalid from my direction – and hang-up calls randomly. There was
    no rhyme or reason for it. Sometime it would happen few times a day,
    sometime once every few days. Sometime 10 seconds into the call,
    sometime when another call would come in. But it always seemed to be
    connected with the “received INVAL” message in the logs.

    I replaced the router (a TP-Link ADSL router) with a Belkin router
    (that’s what I had to hand) and everything is fine now for more then a
    week. The other router did not give any signs of trouble otherwise – all
    other Internet, email, openvpn and any other traffic going through it
    was fine. But somehow it would generate this problem with Asterisk.

    I just thought it might help somebody some day.

    Sebastian