2013年1月10日 星期四

RTSP -- Keep alive 的作法

用來實作 RTSP KeppAlive 的方法,大致上分成兩類。

1. 使用 RTSP method,例如:Play, GET_PARAMETER, SET_PARAMETER, OPTIONS
2. 使用 Receiver report RTCP packet


2013年1月9日 星期三

STUN協議簡介


轉載自 http://basiccoder.com/stun-protocal-introduction.html


STUN( Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs))是一种轻量级的协议,它允许应用程序发现它们和公网之间是否存在NATs和防火墙,并确定NATs和防火墙的类型。它也可以让应用程序确定NAT分配给它们的公网IP地址和端口号。STUN是一种client-server的协议,也是一种request-response的协议,STUN的默认端口是3478。

2013年1月8日 星期二

NAT -- 基本概念

NAT (Network Address Translation) 是用來解決IPv4位址不足的一個方法,當IP封包通過路由器或防火牆時,建立一個Private IP與Public IP的對應表格,並且重寫封包內的源IP地址或/和目的IP地址的技術。這種技術被普遍使用在有多台主機但只通過一個公有IP位址訪問網際網路的私有網路中。

IETF 定義的 Private IP如下:
  • Class A: 
    • 10.0.0.0/8 (255.0.0.0) 
    • 10.0.0.0 - 10.255.255.255
  • Class B: 
    • 172.16.0.0/12 (255.240.0.0)
    • 172.16.0.0 - 172.31.255.255
  • Class C: 
    • 192.168.0.0/16 (255.255.0.0)
    • 192.168.0.0 - 192.168.255.255

2013年1月7日 星期一

斷電時的檔案內容保護

當程式執行過程中,發生不預期的斷電,可能會讓正在寫入的檔案發生錯誤,當重新開機之後,系統便產生錯誤。

參考 POSIX 針對 rename() 函數的定義
if a power-cut happens during the re-naming, the original file will be intact because the re-name operation is atomic

NAT -- STUN 測試

近期因為工作上的需要,因此針對 NAT 技術做一粗略的了解,本篇將紀錄使用 STUN 的實驗過程。


STUN簡介

STUN 全名為 Simple Traversal of UDP Through Netwoek Address Translators,利用位於 Internet 上的伺服器幫助防火牆內的UA獲知他們被NAT 轉換過的外部位址, 並協助他人的VoIP呼叫穿透防火牆送達牆內的UA。很多應用層的 VoIP程式必須仰賴 UA 主動提供自身的IP 位址及port number, 讓VoIP兩端的UA 彼此知道對方的IP 位址及port number, 才能互送封包, 建立雙向的通話。但是如果UA 是在NAT 後面, 在沒有外部的協助下,一個UA 無法看到 它自己被NAT 轉換過的外部位址,就無法提供此項資訊,讓 VoIP順利運作。原理部分可參考http://www.cs.nccu.edu.tw/~lien/Writing/NGN/firewall.htm


網路上提供了許多免費的 STUN Server,如下:
  • stun.stunprotocol.org
  • stun.fwdnet.net
  • stun.fwd.org (no DNS SRV record)
  • stun01.sipphone.com (no DNS SRV record)
  • stun.softjoys.com (no DNS SRV record)
  • stun.voipbuster.com (no DNS SRV record)
  • stun.voxgratia.org (no DNS SRV record)
  • stun.xten.com
  • stun1.noc.ams-ix.net (DNS SRV record on domain ams-ix.net not noc.ams-ix.net)

2012年12月28日 星期五

使用 gSoap 2.8.12 產生 ONVIF 程式碼


20121229 更新

1. gSOAP 最新版本為 2.8.12, 此版本在 FAQ 中註明了 ONVIF 程式產生時的 define namespace prefix and type bindings,如此在開發程式時可有一個統一的命名規則。如下:

tds = "http://www.onvif.org/ver10/device/wsdl" tev = "http://www.onvif.org/ver10/events/wsdl" tls = "http://www.onvif.org/ver10/display/wsdl" tmd = "http://www.onvif.org/ver10/deviceIO/wsdl" timg = "http://www.onvif.org/ver20/imaging/wsdl" trt = "http://www.onvif.org/ver10/media/wsdl" tptz = "http://www.onvif.org/ver20/ptz/wsdl" trv = "http://www.onvif.org/ver10/receiver/wsdl" trc = "http://www.onvif.org/ver10/recording/wsdl" tse = "http://www.onvif.org/ver10/search/wsdl" trp = "http://www.onvif.org/ver10/replay/wsdl" tan = "http://www.onvif.org/ver20/analytics/wsdl" tad = "http://www.onvif.org/ver10/analyticsdevice/wsdl" tdn = "http://www.onvif.org/ver10/network/wsdl" tt = "http://www.onvif.org/ver10/schema"

2012年11月6日 星期二

ONVIF -- SIEMENS Vectis HX add a new device


SIEMENS Vectis HX  add a new device (使用 ONVIF 規範)

|Time     | 192.168.0.28                          |
|         |                   | 192.168.0.10      |                
|43.599738000|         POST /onvif/device_           |HTTP/XML: POST /onvif/device_service HTTP/1.1