MusicOnHold in two directions

I would like to monitor a VOIP line for dropouts in both directions.
I have installed an asterisk server at the client and one at the office in the setup as shown in the diagram below.
Both Asterisk servers have been registered at the SIP provider, each with their own number.
To test the outgoing traffic from the client, I call ext 200 from the VOIP phone, which calls the Asterisk2 server via the provider.
The Asterisk1 server plays musiconhold which is monitored at the head of out network.

I would like to monitor the other direction at the same time. Is it possible to have both servers play musiconhold?
I tried to call the StartMusicOnHold application before the Dial call, but the music stops as soon as the Dial call is made.
Is this somehow possible?

snippet asterisk2 dialplan

; call to 200 calls asterisk 1 server
exten => 200,1,NoOp(calling 200)
same => n,Dial(SIP/provider/00xxxxxxxxx)
same => n,Hangup

snippet asterisk1 dialplan

[provider-in]
exten => s,1,NoOp(provider calling ${EXTEN})
same => n,Answer()
same => n,Playback(hello)
same => n,MusicOnHold(default,60)
same => n,Hangup

Why cannot you use the various RTP statistics, or do a capture and use the statistics from wireshark?

You should be urgently planning to replace chan_sip with chan_pjsip.

If you really wanted to inject audio at the client Asterisk,you could use originate and chan_spy’s whisper facility, but that seems overcomplicated when monitoring the statistics, on silence, should be enough.

Hello David,
I was not clear. I capture the traffic using tcpdump (in the Monitor) and analyse it using wireshark RTP analysis. But for this I need continuous traffic, which I am generating using MusicOnHold. This works fine in either direction, but not at the same time.

I installed Asterisk on raspberry Pi’s using the default installation. Not even sure if that comes with chan_sip or chan_pjsip…

But there is a bridged incoming call on the A side which should be providing media.

What you’d have to do is configure Asterisk2 itself to call Asterisk1; you may be able to specify the call actions on Asterisk2 to just start playing MusicOnHold.

You won’t do this from dialing a phone on Asterisk2 unless you somehow conference musiconhold in to the channel. So you’d have to do something like create a conference on Asterisk2, then add both Asterisk1 and MOH to this.

Also,

This tells Asterisk to time-out MusicOnHold after 60 seconds; which is not what I want if you’re doing a test like this.

What they should do, if they don’t want the initiating party to left in the call, is to use Originate, in which case MusicOnHold could be the application to run.

You might try the ‘G’ option to Dial() which will redirect upon answer to another context/exten/priority that plays your music.

Thank you for all your comments.
There is, indeed the possibility to inject sounds via the VOIP phone, but I do not have MsicOHoldfacilities on that phone (that I know of)
The options on the Dial command appear to be most straightforward, but I have not yet been able to make that work.
Perhaps I am not understanding the principle of this.
I’ve tried several things. I would hope the G option would split the call into two parts, one of which would be executed immediately, the other executed when the call is termintaed from the remote end.
This is clearly not the case.
What am I doing wrong?



exten => 500,1,NoOp(calling 500)
same => n,Dial(SIP/provider/00xxxxxxxxxxx,G(600,1))

exten => 600,1,Goto(650,1)
same => n,NoOp(Play+1)
same => n,Hangup

exten => 650,1,NoOp(calling 650)
same => n,Playback(hello-world)
same => n,Hangup

Just an open microphone should generate media from the phone, although you should disable any comfort noise feature. (Asterisk doesn’t handle that well, even in normal use.)

Hi David,
I’m afraid that is not going to work for me. Might be OK for wireshark statistics, but I need to show the results to the clients. They assess the audio quality. And for privacy reasons music is best.
But if you have a suggestion on how to use the dial application G option, that would be great.

Music is not a good way of evaluating the audio quality of VoIP calls, as the codecs used don’t have the bandwidth for good quality music, and the lower bit rate ones are based on vocal tract models, and have real difficulty in representing sounds that are not consistent with that.

Yes, that is frustrating. The G splits immediately upon Answer. Curious to see the flow, here is an example I put together that saves output into 12 separate wav files, maybe it helps you:

; Example context for showing off of the Dial() application G option.
;
; Trigger this with a spooled call:
; sudo -u asterisk echo -e "Channel: Local/split@PenGuin-PBX-test-G\nContext: PenGuin-PBX-test-G\nExtension: legA" > /tmp/pbxtestG.call
; sudo -u asterisk cp /tmp/pbxtestG.call /var/spool/asterisk/outgoing/
;
[PenGuin-PBX-test-G]

exten = split,1,Dial(Local/legB@PenGuin-PBX-test-G,69,G(feet,1))

exten = feet,1,Goto(footA,1)
exten = feet,2,Goto(footB,1)

exten = legA,1,Set(x=PNGN-${EPOCH}-LEG-A-CALLER)
 same = n,Answer()
 same = n,MixMonitor(${x}.wav,r(${x}-rx.wav)t(${x}-tx.wav))
 same = n,Playback(hello-world&silence/10&silence/10&beep)

exten = legB,1,Set(x=PNGN-${EPOCH}-LEG-B-CALLEE)
 same = n,Answer()
 same = n,MixMonitor(${x}.wav,r(${x}-rx.wav)t(${x}-tx.wav))
 same = n,Playback(from&sunny&colorado&silence/10&silence/10&beep)

exten = footA,1,Set(x=PNGN-${EPOCH}-FOOT-A-CALLER)
 same = n,Answer()
 same = n,MixMonitor(${x}.wav,r(${x}-rx.wav)t(${x}-tx.wav))
 same = n,Milliwatt(m)

exten = footB,1,Set(x=PNGN-${EPOCH}-FOOT-B-CALLEE)
 same = n,Answer()
 same = n,MixMonitor(${x}.wav,r(${x}-rx.wav)t(${x}-tx.wav))
 same = n,Milliwatt(m)

exten = h,1,Verbose(2,FINISHED ${x} AT ${EPOCH})