简体   繁体   English

从客户端读取来自 GNU Radio UDP 接收器的信号

[英]Reading signal from GNU Radio UDP sink from client side

To be honest I am a bit confused and I guess the error is quite obvious.老实说,我有点困惑,我想这个错误很明显。 Anyway.反正。

So, on one side I have a UDP sink from GNU Radio sending data to a Python client.因此,一方面,我有一个来自 GNU Radio 的 UDP 接收器将数据发送到 Python 客户端。

The problem is the data I am receiving does not make much sense (I am able to properly read the data if, instead I read it from a file sink, so it has to do with the way I am doing the network part).问题是我收到的数据没有多大意义(如果我从文件接收器读取数据,我能够正确读取数据,所以它与我做网络部分的方式有关)。

I tried already as little endian and also big endian, just in case, I still get rubbish.我已经尝试过小端和大端,以防万一,我仍然会得到垃圾。

So, on the sink side (the server side) the block config is:因此,在接收端(服务器端),块配置是:

self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, "the_ip",8080,1472,True)

So, on the other side I will get 1500 bytes, no?所以,另一方面,我会得到 1500 个字节,不是吗? 1472 of payload +28 of the UDP header. 1472 的有效载荷 +28 的 UDP header。

What I did, and based on this[1] example seems ok, is reading 1500 bytes in the client side and assume the header is taken out by recvfrom method:我所做的,基于this [1] example似乎没问题,正在客户端读取1500字节并假设header是通过recvfrom方法取出的:

data_tmp, addr = sock.recvfrom(1500)

I assume data_tmp shall be the 1472 bytes of data, at least the length matches).我假设 data_tmp 应该是 1472 字节的数据,至少长度匹配)。

As I am sending gr_complex I read 8 bytes (two floats little endian, one for I and one for Q components).当我发送 gr_complex 时,我读取了 8 个字节(两个浮点小端序,一个用于 I,一个用于 Q 组件)。

So, what am I missing?那么,我错过了什么?

Thanks!!谢谢!!

[1] There are many other like this one, the point is I assume the method splits the header from the payload. [1] 还有很多类似的,关键是我假设该方法将 header 从有效负载中分离出来。 https://www.binarytides.com/programming-udp-sockets-in-python/ https://www.binarytides.com/programming-udp-sockets-in-python/

when you read from a socket, the UDP header is already removed, so you shouldn't try to read 1500 bytes but 1472.当您从套接字读取时, UDP header 已被删除,因此您不应尝试读取 1500 字节而是 1472。

Other than that, this looks fine.除此之外,这看起来不错。

I'd generally recommend not using UDP (you'll have to deal with packet loss, potentially even L2 fragmentation etc yourself), but one of the ZeroMQ sinks (PUSH Socket would be a good idea here) and your favourite Python ZeroMQ library (pyzmq) as other end (PULL socket);我通常建议不要使用 UDP (您必须自己处理数据包丢失,甚至可能是 L2 碎片等),但是其中一个 ZeroMQ 接收器(PUSH Socket 在这里是个好主意)和您最喜欢的 Python ZeroMQ 库( pyzmq) 作为另一端(PULL 套接字); you get low-overhead data passing interface over TCP (if you need to go over network), IPC (if your GNU Radio flow graph and the receiving program can use Unix inter-process communication) or a couple "specialist" transports.您将通过 TCP 获得低开销的数据传输接口(如果您需要通过网络传输 go)、IPC(如果您的 GNU Radio 流程图和接收程序可以使用 Unix 进程间通信)或一对“专家”传输。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM