当前位置:网站首页>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;
}
边栏推荐
- ROS - create workspace
- [robot learning] matlab kinematics and ADMAS dynamics analysis of manipulator gripper
- How does DataGrid export and recover the entire database data, using a single SQL file
- VISO fast rendering convolution block
- 腾讯云使用pem登录
- Easy to use remote sensing data set download website~~~
- How close can QA be to business code Direct exposure of defects through codediff
- 深入C语言(2)——结构的定义与使用
- 暴力递归到动态规划 01 (机器人移动)
- How dare you write a resume that is proficient in concurrent programming? Why do you use a two-way linked list in AQS?
猜你喜欢

Photo scale correction tool: DxO viewpoint 3 direct mount version

Idea configuration web container and war packaging

Summarize the knowledge points of the ten JVM modules. If you don't believe it, you still don't understand it

Implement Lmax disruptor queue from scratch (VI) analysis of the principle of disruptor solving pseudo sharing and consumers' elegant stopping

今晚7:30 | 连界、将门、百度、碧桂园创投四位大佬眼中的AI世界,是继续高深还是回归商业本质?...

接口自动化测试实践指导(上):接口自动化需要做哪些准备工作

Rongyun real-time community solution

Practical guidance for interface automation testing (Part I): what preparations should be made for interface automation

AI_ Drug: VAE of molecular generation model (I)

MySQL installation and configuration super detailed tutorial and simple database and table building method
随机推荐
Code speed optimization
美联储再加息,75基点 鲍威尔“放鸽”,美股狂欢
一种简单通用的获取函数栈空间大小的方法
Simple understanding of CDN, SDN and QoS
STC单片机驱动1.8‘TFT SPI屏幕演示示例(含资料包)
Simple code implementation of decision tree
How to realize multi line annotation in MATLAB
ROS-Errror:Did you forget to specify generate_ messages(DEPENDENCIES ...)?
Precautions for using latex
反脆弱·从不确定性中获益---管理?
Introduction and advanced level of MySQL (11)
力扣刷题之数组序号计算(每日一题7/28)
Rdkit: introduce smiles code, smart code and Morgan fingerprint (ECFP)
A case of gradually analyzing the splitting of classes -- colorful ball collisions
Photo scale correction tool: DxO viewpoint 3 direct mount version
再学EXKMP(EXKMP模板)
Asynchronous callback future mode of concurrent mode
Division and description of military technical documents
Configure vscade to realize ROS writing
Shortcut key for adjusting terminal size in ROS