当前位置:网站首页>How to judge stun protocol
How to judge stun protocol
2022-07-29 03:27:00 【qianbo_ insist】
STUN Full name :(Session Traversal Utilities for NAT)NAT Session traversal application , Allow in NAT( Or multiple NAT) After the client to find out their own public network address , Find out what kind of NAT After that and NAT Bound to a local port Internet End port . This information is used to be in NAT Create... Between hosts after router UDP signal communication . Agreement by the RFC 5389 Definition .
1、stun Magic of message cookie
//fixed value 0x2112A442
const uint8_t stun_packet::magic_cookie[] = { 0x21, 0x12, 0xA4, 0x42 };
Four bytes , and RTP The agreement is similar to , But more , There are four , Namely 0x21,0x12, 0xA4, 0x42
according to RFC 5389, The protocol header is shown below :
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0 0| STUN Message Type | Message Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Magic Cookie |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| Transaction ID (96 bits) |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2、 How to determine
bool is_stun_pack(const uint8_t* data, size_t len) {
if ((len >= STUN_HEADER_SIZE) && (data[0] < 3) &&
(data[4] == 0x21) && (data[5] == 0x12) &&
(data[6] == 0xA4) && (data[7] == 0x42)) {
return true;
}
return false;
}
边栏推荐
- Introduction and advanced level of MySQL (11)
- How to deploy sentinel cluster of redis
- web-uploader不能多文件上传
- for_each用法示例
- Several methods of converting object to string
- Web uploader cannot upload multiple files
- 年内首个“三连跌” 95号汽油回归“8元时代“
- Rdkit: introduce smiles code, smart code and Morgan fingerprint (ECFP)
- Arm architecture and neural network
- Flask creation process day05-06 creation project
猜你喜欢

04 | background login: login method based on account and password (Part 1)

Detailed steps for installing MySQL 8.0 under Linux

makefile详解

How dare you write a resume that is proficient in concurrent programming? Why do you use a two-way linked list in AQS?

ROS-Errror:Did you forget to specify generate_ messages(DEPENDENCIES ...)?

Simple code implementation of decision tree

exness:鸽派决议帮助黄金反弹,焦点转向美国GDP

Does domestic ERP have a chance to beat sap?

The Federal Reserve raised interest rates again, Powell "let go of doves" at 75 basis points, and US stocks reveled

Digital image processing Chapter 10 - image segmentation
随机推荐
CUDA GDB prompt: /tmp/tmpxft**** cudafe1.stub. c: No such file or directory.
力扣刷题之分数加减运算(每日一题7/27)
2 neural network toolbox NN
Implement Lmax disruptor queue from scratch (VI) analysis of the principle of disruptor solving pseudo sharing and consumers' elegant stopping
军品研制过程-转阶段
Practical guidance for interface automation testing (Part I): what preparations should be made for interface automation
Arm architecture and neural network
During the year, the first "three consecutive falls" of No. 95 gasoline returned to the "8 Yuan era"“
Producer consumer model of concurrent model
Configure vscade to realize ROS writing
How close can QA be to business code QA conducts testability transformation on business code
腾讯云使用pem登录
Anaconda offline installation environment
Introduction and advanced MySQL (XIV)
[robot learning] matlab kinematics and ADMAS dynamics analysis of manipulator gripper
3D高级渲染器:Artlantis studio 2021.2中文版
Notes on letter symbol marking of papers
MOS管 —— 快速复苏应用笔记(贰)[参数与应用]
Design of smoke temperature, humidity and formaldehyde monitoring based on single chip microcomputer
Idea configuration web container and war packaging