Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to send/receive RTP packets from behind NAT #56

Open
par5er opened this issue Mar 5, 2025 · 2 comments
Open

Unable to send/receive RTP packets from behind NAT #56

par5er opened this issue Mar 5, 2025 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@par5er
Copy link

par5er commented Mar 5, 2025

Hi,

I'm trying to connect to a SIP server and send a call. The SIP communication works well, but I am unable to send or receive audio data. Attached below are the logs. I have anonymized some information, but basically:

  • 10.0.0.0 is my private IP (I am behind NAT)
  • 1.2.3.4 is the SIP server's public IP
  • 22.22.22.22 is my public IP

Any help would be appreciated, thank you very much.

$ go run main.go
10:26PM DBG /go/pkg/mod/github.com/emiago/[email protected]/sip/transport_layer.go:465 > DNS Resolving host=sip.rocks
10:26PM DBG /go/pkg/mod/github.com/emiago/[email protected]/sip/transport_layer.go:405 > Via header used for creating connection host=10.0.0.0 network=udp port=19060
10:26PM DBG /go/pkg/mod/github.com/emiago/[email protected]/sip/transport_udp.go:122 > New connection raddr=1.2.3.4:7777
10:26PM DBG /go/pkg/mod/github.com/emiago/[email protected]/sip/sip.go:41 > UDP write to 10.0.0.0:19060 -> 1.2.3.4:7777:
INVITE sip:[email protected]:7777 SIP/2.0
Via: SIP/2.0/UDP 10.0.0.0:19060;branch=z9hG4bK.ngQ2WOHnBG84Dbiz;rport
From: "myuser" <sip:[email protected]:7777>;tag=GXKIhhO4obIDweGy
Call-ID: 85c8cb11-a6fa-476e-b4c4-4cdae490bba8
CSeq: 1 INVITE
Max-Forwards: 70
To: <sip:[email protected]:7777>
Contact: <sip:[email protected]:19060>
Content-Type: application/sdp
Content-Length: 182

v=0
o=- 3950187999 3950187999 IN IP4 10.0.0.0
s=Sip Go Media
c=IN IP4 10.0.0.0
t=0 0
m=audio 44171 RTP/AVP 8
a=rtpmap:8 PCMA/8000
a=ptime:20
a=maxptime:20
a=sendrecv
10:26PM DBG ../../../../go/pkg/mod/github.com/emiago/[email protected]/sip/transaction_client_tx.go:75 > Client transaction initialized tx=z9hG4bK.ngQ2WOHnBG84Dbiz__INVITE
10:26PM INF ../../../../go/pkg/mod/github.com/serfreeman1337/[email protected]/diago.go:662 > Waiting answer call_id=85c8cb11-a6fa-476e-b4c4-4cdae490bba8
10:26PM DBG ../../../../go/pkg/mod/github.com/emiago/[email protected]/sip/sip.go:33 > UDP read from 10.0.0.0:19060 <- 1.2.3.4:7777:
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 10.0.0.0:19060;branch=z9hG4bK.ngQ2WOHnBG84Dbiz;rport=19060;received=22.22.22.22
From: "myuser" <sip:[email protected]:7777>;tag=GXKIhhO4obIDweGy
To: <sip:[email protected]:7777>;tag=9r8gQ6UDgp5ap
Call-ID: 85c8cb11-a6fa-476e-b4c4-4cdae490bba8
CSeq: 1 INVITE
User-Agent: FreeSWITCH
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Allow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
Proxy-Authenticate: Digest realm="sip.rocks", nonce="...", algorithm=MD5, qop="auth"
Content-Length: 0


10:26PM DBG ../../../../go/pkg/mod/github.com/emiago/[email protected]/sip/sip.go:41 > UDP write to 10.0.0.0:19060 -> 1.2.3.4:7777:
ACK sip:[email protected]:7777 SIP/2.0
Via: SIP/2.0/UDP 10.0.0.0:19060;branch=z9hG4bK.ngQ2WOHnBG84Dbiz;rport
Max-Forwards: 70
From: "myuser" <sip:[email protected]:7777>;tag=GXKIhhO4obIDweGy
To: <sip:[email protected]:7777>;tag=9r8gQ6UDgp5ap
Call-ID: 85c8cb11-a6fa-476e-b4c4-4cdae490bba8
CSeq: 1 ACK
Contact: <sip:[email protected]:19060>
Content-Length: 0


10:26PM DBG ../../../../go/pkg/mod/github.com/emiago/[email protected]/sip/transport_udp.go:369 > UDP reference decrement dst=10.0.0.0:19060 ref=2 src=10.0.0.0:19060
10:26PM DBG ../../../../go/pkg/mod/github.com/emiago/[email protected]/sip/transaction_client_tx.go:227 > Client transaction destroyed tx=z9hG4bK.ngQ2WOHnBG84Dbiz__INVITE
10:26PM DBG ../../../../go/pkg/mod/github.com/emiago/[email protected]/sip/sip.go:41 > UDP write to 10.0.0.0:19060 -> 1.2.3.4:7777:
INVITE sip:[email protected]:7777 SIP/2.0
Via: SIP/2.0/UDP 10.0.0.0:19060;branch=z9hG4bK.USNQ5tOi68AKZtYn;rport
From: "myuser" <sip:[email protected]:7777>;tag=GXKIhhO4obIDweGy
Call-ID: 85c8cb11-a6fa-476e-b4c4-4cdae490bba8
CSeq: 2 INVITE
Max-Forwards: 70
To: <sip:[email protected]:7777>
Contact: <sip:[email protected]:19060>
Content-Type: application/sdp
Content-Length: 182
Proxy-Authorization: Digest username="myuser", realm="sip.rocks", nonce="...", uri="sip:[email protected]:7777", algorithm=MD5, cnonce=""...", qop=auth, nc=00000001, response="..."

v=0
o=- 3950187999 3950187999 IN IP4 10.0.0.0
s=Sip Go Media
c=IN IP4 10.0.0.0
t=0 0
m=audio 44171 RTP/AVP 8
a=rtpmap:8 PCMA/8000
a=ptime:20
a=maxptime:20
a=sendrecv
10:26PM DBG ../../../../go/pkg/mod/github.com/emiago/[email protected]/sip/transaction_client_tx.go:75 > Client transaction initialized tx=z9hG4bK.USNQ5tOi68AKZtYn__INVITE
10:26PM DBG ../../../../go/pkg/mod/github.com/emiago/[email protected]/sip/sip.go:33 > UDP read from 10.0.0.0:19060 <- 1.2.3.4:7777:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.0.0.0:19060;branch=z9hG4bK.USNQ5tOi68AKZtYn;rport=19060;received=22.22.22.22
From: "myuser" <sip:[email protected]:7777>;tag=GXKIhhO4obIDweGy
To: <sip:[email protected]:7777>
Call-ID: 85c8cb11-a6fa-476e-b4c4-4cdae490bba8
CSeq: 2 INVITE
User-Agent: FreeSWITCH
Content-Length: 0


10:26PM DBG ../../../../go/pkg/mod/github.com/emiago/[email protected]/sip/sip.go:33 > UDP read from 10.0.0.0:19060 <- 1.2.3.4:7777:
SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP 10.0.0.0:19060;branch=z9hG4bK.USNQ5tOi68AKZtYn;rport=19060;received=22.22.22.22
From: "myuser" <sip:[email protected]:7777>;tag=GXKIhhO4obIDweGy
To: <sip:[email protected]:7777>;tag=a219r1cHDZUXH
Call-ID: 85c8cb11-a6fa-476e-b4c4-4cdae490bba8
CSeq: 2 INVITE
Contact: <sip:[email protected]:7777;transport=udp>
User-Agent: FreeSWITCH
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Allow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 224
Remote-Party-ID: "Outbound Call" <sip:[email protected]>;party=calling;privacy=off;screen=no

v=0
o=FreeSWITCH 1741173366 1741173367 IN IP4 1.2.3.4
s=FreeSWITCH
c=IN IP4 1.2.3.4
t=0 0
m=audio 25838 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20

10:26PM INF main.go:109 > got dialog media: &{mu:{state:0 sema:0} mediaSession:0x4000170000 rtpSession:0x40000dc000 RTPPacketReader:0x40000de000 RTPPacketWriter:0x40000ba280 audioReader:<nil> audioWriter:<nil> lastInvite:<nil> onClose:0x260d00 closed:false}
10:26PM DBG ../../../../go/pkg/mod/github.com/serfreeman1337/[email protected]/diago.go:698 > RTP Session setuped laddr=10.0.0.0:44171 raddr=1.2.3.4:25838
10:26PM DBG ../../../../go/pkg/mod/github.com/serfreeman1337/[email protected]/media/rtp_session.go:329 > RTCP reader started laddr=10.0.0.0:44172
10:26PM DBG ../../../../go/pkg/mod/github.com/serfreeman1337/[email protected]/media/rtp_session.go:348 > RTCP writer started raddr=1.2.3.4:25839
10:26PM DBG ../../../../go/pkg/mod/github.com/serfreeman1337/[email protected]/media/media_session.go:419 > RTP write 10.0.0.0:44171 > 1.2.3.4:25838:
RTP PACKET:
	Version: 2
	Marker: true
	Payload Type: 8
	Sequence Number: 45136
	Timestamp: 0
	SSRC: 61042746 (3a3703a)
	Payload Length: 80

wrote pcm: 160 <nil>
10:26PM DBG ../../../../go/pkg/mod/github.com/serfreeman1337/[email protected]/media/media_session.go:445 > RTCP write: 
SenderReport from 3a3703a
	NTPTime:	16965928315057260442
	RTPTIme:	39834
	PacketCount:	1
	OctetCount:	80
	Profile Extension Data: []
@par5er
Copy link
Author

par5er commented Mar 7, 2025

With the https://github.com/jart/gosip library I do not have this problem

@emiago emiago added the documentation Improvements or additions to documentation label Mar 8, 2025
@emiago
Copy link
Owner

emiago commented Mar 8, 2025

Hi @par5er. First of all welcome. Dealing with NAT is provided, but you need to configure it. Check diago.Transport . You can provide your external IP address, but also you can set your specific IP for media.
Also you can check RewriteContact option.
Documentation is not the best, but will be in future.
Anyway there is also goal for supporting RTP symetric but it is not yet supported.

I hope this helps. Play with different settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants