当前位置:网站首页>Gb28181 protocol -- timing
Gb28181 protocol -- timing
2022-06-25 06:16:00 【jimte_ pro】
1、 brief introduction
according to 《GB/T 28181 —2016》7.10、9.10 The requirements of ,GB28181 The equipment network timing function is described as follows :
In networked systems IP Network server equipment should support NTP( see IETF RFC2030) Network unified timing service based on Protocol . Network timing equipment is divided into clock source and client , Support customers / The working mode of the server ; The clock source shall support TCP/IP、UDP And NTP agreement , It can convert the input or self generated time signal to standard NTP Packet format output . In networked systems IP The network access equipment shall support SIP Unified timing of signaling , The access device shall accept the data from SIP The server passes the message header Date Time service carried by domain .
2、 The basic flow
Intranet device support is based on SIP Method or NTP Network timing function of mode , The standard time is Beijing time . The process is as follows :
If the registration is successful , The last part of the registration process SIP Reply message 200 OK Medium Date The header field carries the time information . The format is XML A standard format :Date: yyyy-MM-dd’T’HH: mm:ss.SSS.
if SIP The agent corrects the time through registration , Its registration expiration time should be set to less than SIP Agency and SIP The server appears 1 s The elapsed time of the error . for example :SIP Agency and SIP After the server timing ,SIP The agent runs 10 h Post equipment time and SIP The server time difference is greater than 1 s, The registration expiration time should be set to 10 h(36 000s) , In order to make sure SIP Agency and SIP The time error between servers is less than 1 s.
3、 be based on SIP Timing of
sip Signaling processing :
int SipReg(GB28181Param_t *pGB28181Param, int isReg)
{
int ret = 0;
int len = 0;
char *msg;
int expires = 0 ;
int regState = 0;
int unAuthorized = 0;
eXosip_event_t *je = NULL;
osip_header_t *dest = NULL;
osip_message_t *reg = NULL;
long interval = GetSysSec();
if (!pGB28181Param)
{
return SIP_FAILED;
}
if (isReg)
{
expires = strtoul(pGB28181Param->userParam.sipExpires, 0, 0);
}
while(GetSysSec() -interval <= MAX_SIP_REG_TIMEOUT_SEC)
{
// Advanced bank does not have certification registration
if (0 == unAuthorized)
{
ret = SipRegisterUnauthorized(pGB28181Param, expires);
if (ret < 0)
{
if(je)
{
eXosip_event_free(je);
}
return SIP_FAILED;
}
else
{
unAuthorized = 1;
}
}
je = eXosip_event_wait(0, 100); /* Waiting for new news */
if(NULL == je)
{
/* The following statement will result in eXosip_register_send_register Failure */
eXosip_automatic_action();
usleep(100*1000);
continue;
}
/* Return registration failure */
if(EXOSIP_REGISTRATION_FAILURE == je->type)
{
/* Unauthenticated registration failed , Then use authentication to register */
if((je->response!=NULL) && (401==je->response->status_code))
{
ret = SipRegisterAuthorized(pGB28181Param, je->rid, expires);
eXosip_event_free(je);
if(ret != OSIP_SUCCESS)
{
return SIP_FAILED;
}
}
else
{
eXosip_event_free(je);
unAuthorized = 0; /* Registration failed , Go through the registration process again */
if (isReg)
{
return SIP_REREG_AFTER_60S;
}
return SIP_FAILED;
}
}
else if (EXOSIP_REGISTRATION_SUCCESS == je->type)
{
regState = 1;
/* The registration returned by the server is successful */
g_SipState.registerID = je->rid;
if (MSG_IS_REGISTER(je->request) && je->response)
{
if (OSIP_SUCCESS == osip_message_to_str(je->response, &msg, &len))
{
if (osip_message_get_date(je->response, 0, &dest) > 0)
{
SipSetSystemTime(dest->hvalue);
}
}
}
eXosip_execute();
eXosip_automatic_action();
eXosip_event_free(je);
break;
}
else
{
eXosip_event_free(je);
}
}
if( (GetSysSec() -interval > MAX_SIP_REG_TIMEOUT_SEC) && (regState == 0))
{
return SIP_FAILED;
}
pthread_mutex_lock(&g_SipState.mutex);
// to update sip Registration status of
if (isReg)
{
g_SipState.sipRegStatus = 1;
g_SipState.keepliveAckTime = GetSysSec();
}
else
{
g_SipState.sipRegStatus = 0;
}
pthread_mutex_unlock(&g_SipState.mutex);
return SIP_SUCCESS;
}
Set the system time interface :
static int SipSetSystemTime(char *timeStr)
{
char *beginStr = timeStr;
char *endStr = NULL;
char tempStr[10] = {
0, };
struct tm st_time = {
0, };
struct timeval tv = {
0, };
uint32_t stime = 0;
if (!timeStr)
{
return SIP_FAILED;
}
if ((endStr = strstr(beginStr, "-")))
{
memset(tempStr, 0, sizeof(tempStr));
strncpy(tempStr, beginStr, endStr-beginStr);
beginStr = endStr + 1;
stime = strtoul(tempStr, NULL, sizeof(tempStr));
st_time.tm_year = stime - 1900;
}
if ((endStr = strstr(beginStr, "-")))
{
memset(tempStr, 0, sizeof(tempStr));
strncpy(tempStr, beginStr, endStr-beginStr);
beginStr = endStr + 1;
stime = strtoul(tempStr, NULL, sizeof(tempStr));
st_time.tm_mon = stime - 1;
}
if ((endStr = strstr(beginStr, "T")))
{
memset(tempStr, 0, sizeof(tempStr));
strncpy(tempStr, beginStr, endStr-beginStr);
beginStr = endStr + 1;
stime = strtoul(tempStr, NULL, sizeof(tempStr));
st_time.tm_mday = stime;
}
if ((endStr = strstr(beginStr, ":")))
{
memset(tempStr, 0, sizeof(tempStr));
strncpy(tempStr, beginStr, endStr-beginStr);
beginStr = endStr + 1;
stime = strtoul(tempStr, NULL, sizeof(tempStr));
st_time.tm_hour = stime;
}
if ((endStr = strstr(beginStr, ":")))
{
memset(tempStr, 0, sizeof(tempStr));
strncpy(tempStr, beginStr, endStr-beginStr);
beginStr = endStr + 1;
stime = strtoul(tempStr, NULL, sizeof(tempStr));
st_time.tm_min = stime;
}
if ((endStr = strstr(beginStr, ".")))
{
memset(tempStr, 0, sizeof(tempStr));
strncpy(tempStr, beginStr, endStr-beginStr);
beginStr = endStr + 1;
stime = strtoul(tempStr, NULL, sizeof(tempStr));
st_time.tm_sec = stime;
}
// Set system time
if ((tv.tv_sec = mktime(&st_time)) < 0)
{
GB_PrintError("mktime failed\n");
return SIP_FAILED;
}
settimeofday(&tv, NULL);
// Set up RTC Time
struct tm *stTime = gmtime(&tv);
if (SetRtcTime(stTime) < 0)
{
return SIP_FAILED;
}
return SIP_SUCCESS;
}
Reference material :
《GBT 28181-2016 Public security video monitoring network system information transmission 、 In exchange for 、 Control technical requirements 》
Recommended reading :GB28181 agreement – Device registration and logout
边栏推荐
- Websocket in the promotion of vegetable farmers
- How the sap ui5 framework performs single step debugging of batch requests
- John
- Part 34 of SAP ui5 application development tutorial - device adaptation of SAP ui5 application based on device type
- CST8227
- How often should you refactor- How often should you refactor?
- Differences and connections between sap ui5 and openui5
- Uni app wechat applet customer service chat function
- RT thread i/o device model and layering
- Ping command – test network connectivity between hosts
猜你喜欢
Configuration file ui5 local in SAP ui5 tools Configuration points of yaml

Vegetables sklearn - xgboost (2)

Soft exam information system project manager_ Management Science (Operations Research) 2--- senior information system project manager of soft test 034
![[open source sharing] deeply study KVM, CEPH, fuse features, including open source projects, code cases, articles, videos, architecture brain maps, etc](/img/9d/9bcf52f521e92cf97eb1d545931c68.jpg)
[open source sharing] deeply study KVM, CEPH, fuse features, including open source projects, code cases, articles, videos, architecture brain maps, etc
Various errors and solutions encountered when deploying SAP ui5 application to ABAP server with SAP Fiori tools

Soft exam information system project manager_ Management Science (Operations Research) -- senior information system project manager of soft test 033
Go language map sorting (key/value sorting)

Mongodb basic concept learning - Documentation

C simple operation mongodb

RT thread i/o device model and layering
随机推荐
What elements are indispensable for the development of the character? What are the stages
Netstat command – displays network status
[road of system analyst] collection of wrong questions in the chapters of Applied Mathematics and economic management
BGP - basic concept
Huawei machine test question: splicing URL
SAP ui5 beginner tutorial 25 - using proxy server to solve the cross domain problem of SAP ui5 application accessing remote OData service trial version
Es11 new methods: dynamic import(), bigint, globalthis, optional chain, and null value merging operator
C simple operation mongodb
Leetcode sword finger offer question brushing - day 27
Jz-066- motion range of robot
Some common errors and solutions of using SAP ui5 to consume OData services
Global and Chinese kaolin market operation scale and investment development proposal report 2022
What changes have taken place in the project file after SAP ui5 tools ran the Fiori add deploy config command
Part 33 of SAP ui5 application development tutorial - trial version of responsiveness of SAP ui5 applications
2022-02-19: fence installation. In a two-dimensional garden, there are some trees represented by (x, y) coordinates. As the installation cost is very expensive, your task is to enclose all the trees w
SAP ui5 beginner tutorial No. 27 - unit test tool quNit introduction trial version for SAP ui5 application
PHP and WMI – explore windows with PHP
SAP ui5 Application Development Tutorial Part 30 - parameter transfer in the routing process of SAP ui5
Go language map sorting (key/value sorting)
Research Report on investment share and application prospect of 1,3-propanediol (PDO) industry in the world and China 2022