同某个厂家的摄像头做国标gb28181的联调,遇到一些问题这里做一下记录
情况是这样子的,这次项目的特点是使用国标gb28181做为摄像机和平台之间的通信协议方式,并且平台是上级在公网上,有一个公网ip,摄像头是下级,在内网里,要经过网关同公网上的平台通信。在我司和对方的厂家的内网里都有测试用摄像头,都能通到外网去。环境搭建好后将两个地点的摄像头向公网上的平台注册。
首先发现的问题是对方网络里的摄像头无法注册成功,我方网络里的摄像头则可以成功。两边的配置信息都是对的,后来发现该厂商的摄像头在请求注册时没有在via里加上rport参数导致。
因为我们这个项目是内网到外网,再从外网到内网,有内网穿透的情况,内网映射到外网的端口会发生改变,所以要有一套机制来做穿透,因为国标是基于sip协议的,sip下做内网穿透的事rport机制,如果发送的请求不带rport标识就是不启用这套机制,所以在外网到内网时会出问题。因为内网的头在发送信息到公网上会经过一个网关,网关会使用nat协议转换内网的端口,这个映射到公网上的端口可能和内网的一致,也有可能不一致!而刚好在我方的网络里这个端口恰巧一致了!而对方的不一致。
公网上的平台在收到摄像头的注册信息里因为没有发现rport参数,在返回注册响应时,直接使用请求里的摄像头内网端口信息了,直接导致对方网络里的摄像头得不到注册成功信息,而我方因为刚好映射为了相同的端口,却能收到注册响应能注册上。
如下是osip里打印出的日志,反应出了这个问题,收到的端口是17961,发送时却到了内网的39512上
-
| INFO1 | 63978 <eXtl_udp.c: 452> Message received from: 113.118.241.57:17961
-
| INFO1 | 63978 <udp.c: 1408> Received message len=500 from 113.118.241.57:17961:
-
REGISTER sip:[email protected]:5066 SIP/2.0
-
Via: SIP/2.0/UDP 192.168.1.200:39512;branch=z9hG4bKa5394e4c
-
From: <sip:34020000001320000205@340200>;tag=5f7b2db0
-
To: <sip:34020000001320000205@340200>
-
Contact: <sip:[email protected]:39512>
-
Call-ID: [email protected]
-
CSeq: 548 REGISTER
-
Max-Forwards: 70
-
Expires: 3600
-
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
-
User-Agent: HTSIP AGENT 2.0
-
Content-Length: 0
-
| INFO3 | 63978 <udp.c: 1426> MESSAGE REC. CALLID:023D9B1335824B31
-
| INFO1 | 63978 <udp.c: 1473> no transaction for message
-
| INFO2 | 63978 <osip_transaction.c: 136> allocating transaction resource 45 023D9B1335824B31
-
| INFO2 | 63978 <nist.c: 31> allocating NIST context
-
| INFO4 | 63979 <osip_transaction.c: 349> sipevent tr->transactionid: 45
-
| INFO4 | 63979 <osip_transaction.c: 350> sipevent tr->state: 15
-
| INFO4 | 63979 <osip_transaction.c: 351> sipevent evt->type: 12
-
| INFO4 | 63979 <osip_transaction.c: 352> sipevent evt->sip: c4033050
-
| INFO3 | 63979 <jcallback.c: 358> cb_rcvregister (id=45)
-
| INFO4 | 63979 <osip_transaction.c: 373> sipevent evt: method called!
-
| INFO4 | 63980 <osip_transaction.c: 349> sipevent tr->transactionid: 45
-
| INFO4 | 63980 <osip_transaction.c: 350> sipevent tr->state: 16
-
| INFO4 | 63980 <osip_transaction.c: 351> sipevent evt->type: 20
-
| INFO4 | 63980 <osip_transaction.c: 352> sipevent evt->sip: bc005f00
-
| INFO2 | 63980 <eXutils.c: 755> DNS resolution with 113.118.241.57:39512
-
| INFO2 | 63980 <eXutils.c: 779> getaddrinfo returned: 113.118.241.57 port 39512
-
| INFO1 | 63980 <eXtl_udp.c: 779> Message sent: (to dest=113.118.241.57:39512)
-
SIP/2.0 200 OK
-
Via: SIP/2.0/UDP 192.168.1.200:39512;branch=z9hG4bKa5394e4c;received=113.118.241.57
-
From: <sip:34020000001320000205@340200>;tag=5f7b2db0
-
To: <sip:34020000001320000205@340200>;tag=1082451661
-
Call-ID: [email protected]
-
CSeq: 548 REGISTER
-
User-Agent: JUNTAI SIP UAS/1.0
-
Date: 2019-06-29T21:52:10.001
-
Expires: 3600
-
Content-Length: 0
其次,在摄像头取到流,关闭流发送BYE时也存在问题,如下,在返回ack和bye时,找到的地址不对了,是内网的ip或地址去了
-
| INFO1 | 369109 <jcallback.c: 1528> cb_sndreq_retransmission (id=133)
-
| INFO4 | 369109 <osip_transaction.c: 373> sipevent evt: method called!
-
| INFO2 | 369522 <osip_transaction.c: 136> allocating transaction resource 134 385231458
-
| INFO2 | 369522 <ict.c: 32> allocating ICT context
-
| INFO4 | 369522 <osip.c: 1456> 1 Pending event already in transaction !
-
| INFO4 | 369522 <osip_transaction.c: 349> sipevent tr->transactionid: 134
-
| INFO4 | 369522 <osip_transaction.c: 350> sipevent tr->state: 0
-
| INFO4 | 369522 <osip_transaction.c: 351> sipevent evt->type: 16
-
| INFO4 | 369522 <osip_transaction.c: 352> sipevent evt->sip: 8038f730
-
| INFO2 | 369522 <eXutils.c: 755> DNS resolution with 113.118.241.57:18669
-
| INFO2 | 369522 <eXutils.c: 779> getaddrinfo returned: 113.118.241.57 port 18669
-
| INFO1 | 369522 <eXtl_udp.c: 779> Message sent: (to dest=113.118.241.57:18669)
-
INVITE sip:[email protected]:18669 SIP/2.0
-
Via: SIP/2.0/UDP 192.168.200.2:5066;rport;branch=z9hG4bK1721778447
-
From: <sip:[email protected]:5066>;tag=332179470
-
To: <sip:[email protected]:18669>
-
Call-ID: 385231458
-
CSeq: 4 INVITE
-
Contact: <sip:[email protected]:5066>
-
Content-Type: application/sdp
-
Max-Forwards: 70
-
User-Agent: JUNTAI SIP UAS/1.0
-
Subject: 34020000001320000205:1,34020000002000000065:1
-
Content-Length: 165
-
v=0
-
o=34020000002000000065 0 0 IN IP4 112.33.56.65
-
s=Play
-
c=IN IP4 112.33.56.65
-
t=0 0
-
m=video 33508 RTP/AVP 96
-
a=recvonly
-
a=rtpmap:96 PS/90000
-
y=0200000681
-
| INFO3 | 369535 <udp.c: 1426> MESSAGE REC. CALLID:385231458
-
| INFO4 | 369535 <osip.c: 1456> 1 Pending event already in transaction !
-
| INFO4 | 369535 <osip_transaction.c: 349> sipevent tr->transactionid: 134
-
| INFO4 | 369535 <osip_transaction.c: 350> sipevent tr->state: 1
-
| INFO4 | 369535 <osip_transaction.c: 351> sipevent evt->type: 13
-
| INFO4 | 369535 <osip_transaction.c: 352> sipevent evt->sip: 90003ae0
-
| INFO3 | 369535 <jcallback.c: 511> cb_rcv1xx (id=134)
-
| INFO4 | 369535 <osip_transaction.c: 373> sipevent evt: method called!
-
| INFO1 | 369536 <eXtl_udp.c: 452> Message received from: 113.118.241.57:18669
-
| INFO1 | 369536 <udp.c: 1408> Received message len=664 from 113.118.241.57:18669:
-
SIP/2.0 200 OK
-
Via: SIP/2.0/UDP 192.168.200.2:5066;rport;branch=z9hG4bK1721778447
-
From: <sip:[email protected]:5066>;tag=332179470
-
To: <sip:34020000001320000205@340200>;tag=717142644a97aa49
-
Contact: <sip:[email protected]:53922>
-
Call-ID: 385231458
-
CSeq: 4 INVITE
-
Max-Forwards: 70
-
Allow: ACK,BYE,CANCEL,INVITE,NOTIFY,REFER,UPDATE,INFO
-
Supported: timer
-
Session-Expires: 200;refresher=uac
-
Server: WER Agent Ver 1.0
-
Content-Type: application/sdp
-
Content-Length: 153
-
v=0
-
o=34020000001320000205 0 0 IN IP4 192.168.1.200
-
s=Play
-
c=IN IP4 192.168.1.200
-
t=0 0
-
m=video 19002 RTP/AVP 96
-
a=rtpmap:96 PS/90000
-
a=sendonly
-
| INFO3 | 369536 <udp.c: 1426> MESSAGE REC. CALLID:385231458
-
| INFO4 | 369536 <osip.c: 1456> 1 Pending event already in transaction !
-
| INFO4 | 369536 <osip_transaction.c: 349> sipevent tr->transactionid: 134
-
| INFO4 | 369536 <osip_transaction.c: 350> sipevent tr->state: 2
-
| INFO4 | 369536 <osip_transaction.c: 351> sipevent evt->type: 14
-
| INFO4 | 369536 <osip_transaction.c: 352> sipevent evt->sip: 900035d0
-
| INFO3 | 369536 <jcallback.c: 930> cb_rcv2xx (id=134)
-
| INFO2 | 369536 <eXosip.c: 1444> Allow header contains UPDATE
-
| INFO1 | 369536 <jcallback.c: 217> cb_nict_kill_transaction (id=134)
-
| INFO4 | 369536 <osip_transaction.c: 373> sipevent evt: method called!
-
| INFO4 | 369537 <sdp_message.c: 1481> The rfc2327 says there should be at least an email or a phone header!- anyway, we don't mind about it.
-
| INFO2 | 369538 <eXutils.c: 755> DNS resolution with 113.118.241.57:53922
-
| INFO2 | 369538 <eXutils.c: 779> getaddrinfo returned: 113.118.241.57 port 53922
-
| INFO1 | 369538 <eXtl_udp.c: 779> Message sent: (to dest=113.118.241.57:53922)
-
ACK sip:[email protected]:53922 SIP/2.0
-
Via: SIP/2.0/UDP 192.168.200.2:5066;rport;branch=z9hG4bK396241289
-
From: <sip:[email protected]:5066>;tag=332179470
-
To: <sip:34020000001320000205@340200>;tag=717142644a97aa49
-
Call-ID: 385231458
-
CSeq: 4 ACK
-
Contact: <sip:[email protected]:5066>
-
Max-Forwards: 70
-
User-Agent: JUNTAI SIP UAS/1.0
-
Content-Length: 0
-
| INFO1 | 373733 <udp.c: 1264> ACK restransmission sent.
-
| INFO4 | 374410 <osip_transaction.c: 349> sipevent tr->transactionid: 121
-
| INFO4 | 374410 <osip_transaction.c: 350> sipevent tr->state: 18
-
| INFO4 | 374411 <osip_transaction.c: 351> sipevent evt->type: 9
-
| INFO4 | 374411 <osip_transaction.c: 352> sipevent evt->sip: 0
-
| INFO1 | 374411 <jcallback.c: 217> cb_nict_kill_transaction (id=121)
-
| INFO4 | 374411 <osip_transaction.c: 373> sipevent evt: method called!
-
| INFO4 | 374411 <osip_transaction.c: 265> transaction already removed from list 121!
-
| INFO2 | 374411 <osip_transaction.c: 281> free transaction resource 121 zxw34020000001320000244-191679322
-
| INFO2 | 374411 <nist.c: 73> free nist resource
-
| INFO2 | 374484 <osip_transaction.c: 136> allocating transaction resource 137 385231458
-
| INFO2 | 374484 <nict.c: 32> allocating NICT context
-
| INFO4 | 374484 <osip_transaction.c: 349> sipevent tr->transactionid: 137
-
| INFO4 | 374484 <osip_transaction.c: 350> sipevent tr->state: 10
-
| INFO4 | 374484 <osip_transaction.c: 351> sipevent evt->type: 18
-
| INFO4 | 374484 <osip_transaction.c: 352> sipevent evt->sip: 801c7150
-
| INFO2 | 374484 <eXutils.c: 755> DNS resolution with 192.168.1.200:53922
-
| INFO2 | 374484 <eXutils.c: 779> getaddrinfo returned: 192.168.1.200 port 53922
-
| INFO1 | 374484 <eXtl_udp.c: 779> Message sent: (to dest=192.168.1.200:53922)
-
BYE sip:[email protected]:53922 SIP/2.0
-
Via: SIP/2.0/UDP 192.168.200.2:5066;rport;branch=z9hG4bK1886964964
-
From: <sip:[email protected]:5066>;tag=332179470
-
To: <sip:34020000001320000205@340200>;tag=717142644a97aa49
-
Call-ID: 385231458
-
CSeq: 5 BYE
-
Contact: <sip:[email protected]:5066>
-
Max-Forwards: 70
-
User-Agent: JUNTAI SIP UAS/1.0
-
Content-Length: 0