Multiple peer/call counter issues


i have 4 peer setup with the same remote ip/port, each peer can only do 1 call at a time incoming or outgoing, everything is working fine, i can receive inbound and do outbound calls, now my problem is with call counters if i have incoming calls for peer no. 3 the counter counts peer no1. showing in sip show inuse, even incoming call for peer no.4 it is counted on peer no.1 , probably because they are on the same ip address and type=peer checks the source ip firsthand. is there any other way to make incoming calls count the correct peer instead of defaulting to the first peer ? and another issue is that asterisk cant figure out device_state properly, even if peer 3 has an existing calls sip show inuse shows that it is not in use.

my sip.conf setup
register =>1111@111.222.333.444
register =>2222@111.222.333.444
register =>3333@111.222.333.444
register =>4444@111.222.333.444




In this setup asterisk will not distingusih the peers as asterisk may only differ peers by differnt IP-addresses.
Nevertheless You may look into the SIP-Headers (eg the TO_HEADER - They will differ). With this difference You can set up special GROUP()-statements in Your dialplan and handle Your kimitations (outbound) with GROUP_COUNT().
The DEVICE_STATE won’t work out of the box as well, but - after successfull differentiation of the peers by inspecting the Headers You may use Custom Device States which will be correct than.

thanks abw1oim,
on my wireshark capture i can see the invite header is pointing to the correct peer, is it possible to use this for differentiation? never thought it would be this complex :smiley:

Session Initiation Protocol (INVITE)
Request-Line: INVITE sip:44444@xx.xx.xx.xx SIP/2.0
Method: INVITE
Request-URI: sip:44444@xx.xx.xx.xx
Request-URI User Part: 444444
Request-URI Host Part: xx.xx.xx.xx
Request-URI Host Port: 5060
[Resent Packet: False]
Message Header
Via: SIP/2.0/UDP xx.xx.xx.xx:5060;branch=z9hG4bK33t0m230fo7ghust8451.1
Transport: UDP
Sent-by Address: xx.xx.xx.xx
Sent-by port: 5060
Branch: z9hG4bK33t0m230fo7ghust8451.1

No, the problem is, that Asterisk matches peers by IP. Thus having multiple peers with the same IP You’ll got non-differented matches.
But You may try to distinguish between as I wrote before. (IÄm doing this here in a setup with up to 10 peers at the same IP).
BTW: You’ll facing the same problem if You have one (logical) peer which works with Load-Balancing. There You’ll get inbound calls from different IPs which need to be aggregated in one logical peer to counnt the available channels …

hi abw1oim,
if it is not much to ask, can you show an example header based differentiation


standard example (as from Your wireshark data), differentiation possible by TO-Header

exten => _X.,1,NoOp(Extension: ${EXTEN}; TO_HEADER: ${SIPHEADER(TO)})
exten => _X.,n,Set(GROUP(${EXTEN})=${EXTEN})
exten => _X.,n,Set(GROUP(TOTAL)=${EXTEN})
exten => _X.,n,Dial(....)
exten => _X.,n,Hangup

exten => _X.,1,NoOp(Extension: ${EXTEN}; Checking for free Channel)
exten => _X.,n,GotoIf($[${GROUP_COUNT(TOTAL)} = 0 ]?rand:search)
exten => _X.,n(rand),Goto(switch_${RAND(1,4)})
exten => _X.,n(switch_1),Set(Line=1111)
exten => _X.,n,Goto(check)
exten => _X.,n(switch_2),Set(Line=2222)
exten => _X.,n,Goto(check)
exten => _X.,n(switch_3),Set(Line=3333)
exten => _X.,n,Goto(check)
exten => _X.,n(switch_4),Set(Line=4444)
exten => _X.,n,Goto(check)
exten => _X.,n(search),GotoIf($[${GROUP_COUNT(1111)} > 0 ]?s2222)
exten => _X.,n,Set(Line=1111)
exten => _X.,n,Goto(check)
exten => _X.,n(s2222),GotoIf($[${GROUP_COUNT(2222)} > 0 ]?s3333)
exten => _X.,n,Set(Line=2222)
exten => _X.,n,Goto(check)
exten => _X.,n(s3333),GotoIf($[${GROUP_COUNT(3333)} > 0 ]?s4444)
exten => _X.,n,Set(Line=3333)
exten => _X.,n,Goto(check)
exten => _X.,n(s4444),GotoIf($[${GROUP_COUNT(4444)} > 0 ]?check)
exten => _X.,n,Set(Line=4444)
exten => _X.,n(check),GotoIf($[${ISNULL(${Line})}=0]?dial) 
exten => _X.,n,Busy
exten => _X.,n(dial),Set(GROUP(${Line})=${Line}) 
exten => _X.,n,Set(GROUP(TOTAL)=${Line}) 
exten => _X.,n,Dial(SIP/${Line}/${EXTEN})
exten => _X.,n,Hangup

The user field in the INVITE becomes the initial extension in Asterisk. If you have distinct user fields, just define an extension for each of them in your initial context.

thanks a lot guys, ill give it a try