phone A is behind NAT and phone-B is in public netwrok.
I configured directmedia=yes.
Now, when I try to call Phone-B to A,
Phone-B sends INVITE to asterisk.
asterisk sends INVITE to A(with its own media IP and port).
A sends back 200 OK.
asterisk sends 200 OK to B.
both asterisk and phone-B sends RTP packets to A.
question #1: here is why asterisk is sending 200 OK to B even before it is sending RE-INVITE with phone-B media ?
Is this expected ? I feel that B should receive 200 OK only after asterisk sends re-INVITE with B’s media.
Now, asterisk sends RE-INVITE with Phone-B media
A sends back 200 OK to asterisk.
question #2: What settings I should make to not create media session between asterisk and A.
NAT and SIP fit together rather uncomfortably, so you are going to need a detailed understanding of the individual nat= options (nat=yes is deprecated, probably for this reason, from version 11), and how the router and phone handle such environments. In particular, routers that use SIPALG are known to cause problems. I know neither enough about your system, nor the subtleties of the NAT workrounds in Asterisk, to say much more than don’t try for direct media.
You might want to look into (from the documentation for the trunk version):
[quote];directrtpsetup=yes ; Enable the new experimental direct RTP setup. This sets up
; the call directly with media peer-2-peer without re-invites.
; Will not work for video and cases where the callee sends
; RTP payloads and fmtp headers in the 200 OK that does not match the
; callers INVITE. This will also fail if directmedia is enabled when
; the device is actually behind NAT.
[/quote]
But you should note that this has been classed as experimental for many years.