GNUradio tools for packet-switched transmission(message source 和message sink)

 

Packet-switching in GNUradio

  • In packet-switched transmission, packets of data arrive asynchronously from the data source on the transmit side and from the USRP on the receive side.
  • In order to accommodate the asynchronous nature of packet-switched transmission in the signal flow graph operation of GNUradio:
    1. Special source and sink blocks that contain buffers to hold packets are needed.
    2. Provisions for inserting packets into and extracting packets from the buffers in the source and sink blocks are needed.
    3. The flow graph needs to be halted when the buffers are empty, and packets may need to be discarded when the buffers are full.

Message and message queue classes

  • The GNUradio gr_message and gr_msq_queue classes provide the underlying buffering support for packet-switched source and sink blocks.
Message
  • A message is a gr_message class object, which is constructed by providing thetype (0=data,1=EOF), 2 optional arguments (arg1 andarg2), and length of the message.
  • The following methods are provided to set the contents and access the various parameters of a message object:
    • gr_make_message_from_string (const std::string s, long type, double arg1, double arg2)
    • to_string(): returns the message string
    • set_type(long type) and type()
    • set_arg1(long arg1) and arg1()
    • set_arg2(long arg1) and arg2()
    • length()
    • msq(): returns a pointer to the message string
Message queue
  • A message queue is a gr_msg_queue class object, which is a linked list of message objects. The maximum length limit of a message queue is set when constructing the queue.
  • Thread synchronizing access to a message queue is provided by the following two methods:
    • insert_tail(gr_message_sptr msg): inserts the messagemsq into the tail of the queue if queue is not full; otherwise waits until some messages are removed from the queue by other threads.
    • delete_head(): greps a message from the head of the queue if queue is not empty; otherwise waits until some messages are inserted into the queue by other threads.
  • Other methods (no thread synchronization) are also provided to manage a message queue:
    • flush(): deletes all messages from the queue
    • empty_p(): is the queue empty?
    • full_p(): is the queue full?
    • count(): returns number of messages in queue
    • limit(): returns the maximum queue length

Transmit side operations

  • Use the GNUradio message source block gr_message_source to create a new message queue (or use an existing queue).
  • The message source block extracts messages from the queue to provide a character stream to the next block in the signal flow graph until it encounters an EOF message (type=-1). It waits (halts the output character stream) when the queue is empty.
  • The message source block provides the method msgq() to expose the message queue. Users can employ theinsert_tail() method of exposed message queue to add packets to the queue asynchronously.
  • The set of python programs starting at the top level with benchmark_tx.py in the directory$GR_INSTALL/share/gnuradio/examples/digital illustrates how to perform packet-switched transmission using the message source block.

Receive side operations

  • On the receive side, since the packet arrival process is not known in advance, one must search for packets from the received signal samples obtained from the USRP. This means:
    • One must continuously perform carrier sensing, carrier synchronization, symbol synchronization, and demodulation (assuming high SNR), and then acquisition to extract packets from the USRP signal samples.
    • The packet extraction function may be performed in a GNUradio sink block, which should also insert the extracted packets to a message queue. An example of such a sink block is the GNUradio blockgr_framer_sink_1.
    • A separate process is needed to monitor the message queue. The process should initiate acallback when a packet is inserted into the queue by the sink block. This can be achieved by using the thread-synchronizing message queue access methoddelete_head() in the monitoring process.
  • The set of python programs starting at the top level with benchmark_rx.py in the directory$GR_INSTALL/share/gnuradio/examples/digital illustrates how to perform packet-switched reception using the framer sink blockgr_framer_sink_1 and the message queue class.
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值