简体   繁体   English

如何在C或目标C的IP / UDP数据包中对自己的数据包进行帧格式化?

[英]How to Frame,format my own packet within IP/UDP packet in C or objective C?

I have to communicate with a device which listens on a port for all incoming IP/UDP connection , Ethernet frame carries ip/udp packet which in turn have to carry my own packet say own packet, which is to be like following 我必须与在端口上侦听所有传入IP / UDP连接的设备进行通信,以太网帧携带ip / udp数据包,而该数据包又必须携带我自己的数据包,例如自己的数据包,如下所示

|    first field              |   second field   |  third field  | fourth field |
|2byte message sequence number|1byte message type| Reserved field| Message Data |

how do i create my custom packet with these as my packet data? 如何使用这些数据作为我的数据包创建自定义数据包?

  1. Create a new socket, in datagram mode. 在数据报模式下创建一个新的套接字。
  2. Format your content into a buffer. 将内容格式化为缓冲区。
  3. Write the buffer to the socket. 将缓冲区写入套接字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Objective C中发送UDP数据包:数据包到达时没有任何数据 - Sending UDP packets in Objective C: packet arriving without any data 区分目标 C 中“无法到达的 udp 数据包的目的地”和“接收到的有效载荷长度为 0 的数据包” - Distinguishing between 'destination of udp packet unreachable' and 'received packet with payload of length 0' in Objective C Obj-C:如何在GCDAsyncUdpSocket中使UDP数据包的源端口一致? 源端口始终更改 - Obj-C: How to make UDP packet's Source Port consistent in GCDAsyncUdpSocket? source port alway change 目标c:通过套接字在rtp数据包中发送音频数据 - Objective c: Send audio data in rtp packet via socket 如何使用Objective-C从iOS上的iBeacon数据包获取信号强度值 - How do I get the Signal Strength value from an iBeacon packet on iOS using Objective-C 如何识别iOS设备上收到的udp数据包的发件人ip地址? - How to identify sender's ip address of a udp packet received on iOS device? 如何在Objective-C中设置我自己的属性属性? - How to make my own property attribute in objective-c? 如何在Objective-C中处置自己的sharedInstance? - How do I dispose of my own sharedInstance in Objective-C? 如何使用AsyncUdpSocket在Objective C中发送UDP数据? - how to send UDP data in Objective C with AsyncUdpSocket? 在目标c中为我自己的类使用alloc - Using alloc in objective c for my own classes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM