srsLTE源码学习:逻辑信道多路复用与MAC CE分解pdu_queue.h,pdu_queue.cc
Logical Channel Demultiplexing and MAC CE dissassemble -
逻辑信道多路复用与MAC CE分解
- CE设备:Customer Edge,客户侧边缘设备,一般用来与PTN网络的边缘设备对接。
- PE设备:Provider Edge,网络侧边缘设备,通常要求具备封装与解封装能力。
- P设备:Provider,核心设备,要求具备标签交换能力。
pdu_queue.h
lib\include\srslte\common 2596 4/11/2019 1
/**** \section COPYRIGHT** Copyright 2013-2015 Software Radio Systems Limited** \section LICENSE** This file is part of the srsUE library.** srsUE is free software: you can redistribute it and/or modify* it under the terms of the GNU Affero General Public License as* published by the Free Software Foundation, either version 3 of* the License, or (at your option) any later version.** srsUE is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU Affero General Public License for more details.** A copy of the GNU Affero General Public License can be found in* the LICENSE file in the top-level directory of this distribution* and at http://www.gnu.org/licenses/.**/#ifndef SRSLTE_PDU_QUEUE_H
#define SRSLTE_PDU_QUEUE_H#include "srslte/common/log.h"
#include "srslte/common/block_queue.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/timers.h"
#include "srslte/common/pdu.h"/* Logical Channel Demultiplexing and MAC CE dissassemble 逻辑信道多路复用与MAC CE分解
CE设备:Customer Edge,客户侧边缘设备,一般用来与PTN网络的边缘设备对接。
PE设备:Provider Edge,网络侧边缘设备,通常要求具备封装与解封装能力。
P设备:Provider,核心设备,要求具备标签交换能力。
*/ namespace srslte {class pdu_queue
{
public:typedef enum {DCH,BCH,MCH} channel_t;class process_callback{public:virtual void process_pdu(uint8_t *buff, uint32_t len, channel_t channel, uint32_t tstamp) = 0;};pdu_queue(uint32_t pool_size = DEFAULT_POOL_SIZE) : pool(pool_size), callback(NULL), log_h(NULL) {}void init(process_callback *callback, log* log_h_);uint8_t* request(uint32_t len);void deallocate(uint8_t* pdu);void push(uint8_t *ptr, uint32_t len, channel_t channel = DCH, uint32_t tstamp = 0);bool process_pdus();private:const static int DEFAULT_POOL_SIZE = 64; // Number of PDU buffers in totalconst static int MAX_PDU_LEN = 150*1024/8; // ~ 150 Mbpstypedef struct {uint8_t ptr[MAX_PDU_LEN];uint32_t len;uint32_t tstamp;channel_t channel;#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLEDchar debug_name[128];#endif} pdu_t; block_queue<pdu_t*> pdu_q; buffer_pool<pdu_t> pool;process_callback *callback; log *log_h;
};} // namespace srslte#endif // SRSLTE_PDU_QUEUE_H
pdu_queue.cc
lib\src\common 2980 2/28/2019 57
/**** \section COPYRIGHT** Copyright 2013-2015 Software Radio Systems Limited** \section LICENSE** This file is part of the srsUE library.** srsUE is free software: you can redistribute it and/or modify* it under the terms of the GNU Affero General Public License as* published by the Free Software Foundation, either version 3 of* the License, or (at your option) any later version.** srsUE is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU Affero General Public License for more details.** A copy of the GNU Affero General Public License can be found in* the LICENSE file in the top-level directory of this distribution* and at http://www.gnu.org/licenses/.**/#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)#include "srslte/common/pdu_queue.h"namespace srslte {void pdu_queue::init(process_callback *callback_, log* log_h_)
{callback = callback_;log_h = log_h_;
}uint8_t* pdu_queue::request(uint32_t len)
{ if (len > MAX_PDU_LEN) {fprintf(stderr, "Error request buffer of invalid size %d. Max bytes %d\n", len, MAX_PDU_LEN);return NULL; }pdu_t *pdu = pool.allocate("pdu_queue::request");if (!pdu) {if (log_h) {log_h->error("Not enough buffers for MAC PDU\n"); }fprintf(stderr, "Not enough buffers for MAC PDU\n");}if ((void*) pdu->ptr != (void*) pdu) {fprintf(stderr, "Fatal error in memory alignment in struct pdu_queue::pdu_t\n");exit(-1);}return pdu->ptr;
}void pdu_queue::deallocate(uint8_t* pdu)
{if (!pool.deallocate((pdu_t*) pdu)) {log_h->warning("Error deallocating from buffer pool in deallocate(): buffer not created in this pool.\n");}
}/* Demultiplexing of logical channels and dissassemble of MAC CE * This function enqueues the packet and returns quicly because ACK * deadline is important here. */
void pdu_queue::push(uint8_t *ptr, uint32_t len, channel_t channel, uint32_t tstamp)
{if (ptr) {pdu_t *pdu = (pdu_t*) ptr;pdu->len = len;pdu->tstamp = tstamp;pdu->channel = channel;pdu_q.push(pdu);} else {log_h->warning("Error pushing pdu: ptr is empty\n");}
}bool pdu_queue::process_pdus()
{bool have_data = false;uint32_t cnt = 0;pdu_t *pdu;while(pdu_q.try_pop(&pdu)) {if (callback) {callback->process_pdu(pdu->ptr, pdu->len, pdu->channel, pdu->tstamp);}cnt++;have_data = true;}if (cnt > 20) {if (log_h) {log_h->warning("PDU queue dispatched %d packets\n", cnt);}printf("Warning PDU queue dispatched %d packets\n", cnt);}return have_data;
}}
srsLTE源码学习:逻辑信道多路复用与MAC CE分解pdu_queue.h,pdu_queue.cc相关推荐
- srsLTE源码学习:度量中心:metrics_hub.h
Table of Contents metrics_hub.h PS:<srsLTE源码学习:绑核创建线程threads.h, threads.c> metrics_hub.h lib\i ...
- srsLTE源码学习:安全证书polarssl
Table of Contents liblte_ssl.h liblte_ssl.h lib\include\srslte\common 2101 4/8/2019 19 #ifn ...
- srsLTE源码学习:S1接口抓包s1ap_pcap.h,s1ap_pcap.cc
Table of Contents 介绍 图例 代码 s1ap_pcap.h s1ap_pcap.cc s1ap_test.cc 介绍 S1接口是LTE eNodeB(基站)与 EPC(分组核心网)之 ...
- srsLTE源码学习:生成多播信道表gen_mch_tables
Table of Contents gen_mch_tables.h gen_mch_tables.c 我在代码里做出了注释,如下: sf_alloc -> 1234 4321 2345 543 ...
- srsLTE源码学习:GTP:GPRS Turning Protocol- GPRS隧道协议
Table of Contents gtpc.h * GTP-C v2 Header GPRS Turning Protocol <GPRS Turning Protocol> GPRS ...
- srsLTE源码学习:RLC,无线链路控制子层抓包rlc_pcap.h,rlc_pcap.cc
RLC,无线链路控制子层 RLC(Radio Link Control,无线链路层控制协议)是GPRS/WCDMA/TD-SCDMA/LTE 等无线通信系统中的无线链路控制层协议.在WCDMA系统中, ...
- srsLTE源码学习:协议数据单元PDU:pdu.h
TX与RX TXD 发送数据 Transmit(tx) Data 的简写形式. RXD 接收数据 Receive(rx) Data 的简写形式. x没有特定的意思,就是一开始这么写,之后都这么用了,约 ...
- srsLTE源码学习:网络附属存储抓包nas_pcap.h
Table of Contents nas_pcap.h lib\include\srslte\common 667 4/10/2019 1 nas_pcap.cc li ...
- srsLTE源码学习:MAC层抓包pcap
Table of Contents pcap.h lib\include\srslte\common 13945 2/28/2019 182 mac_pcap.h lib ...
最新文章
- 每个软件开发人员都应该精通的10个基本工具
- Android 访问WebService
- 多喜临门,BCH币价应声上涨
- 前端性能优化之jQuery按需加载轮播图
- 别瞎操心了!机器人根本不会抢你的饭碗
- 在Android Studio中进行代码混淆
- 1.SQL数据定义语言(基础)
- java发送邮件所需jar包_javamail 发邮件所需jar 包两个 activation.jar,mail.jar | 学步园...
- c# opencv 轮廓检测_C#中OpenCVSharp实现轮廓检测
- 构造函数和复制函数java_什么是Java构造函数?
- 2019,国产手机生死存亡的一年
- c++ thread(2.1)---join()
- WPF中XAML中使用String.Format格式化字符串示例
- AR标记时虚实融合投影仪和相机的手动标定
- winform设置文本框ctrl+A和双击实现全选
- C语言实现扫雷游戏(详解)
- FL studio20.9中文版水果编曲软件更新介绍
- 硬盘突然变raw格式_移动硬盘分区变为RAW格式的终极解决办法
- 去掉Win7快捷方式小箭头
- 商业智能,数据仓库,ETL,数仓调度工具informatica介绍手账(三)
热门文章
- SpringBoot学习(四)
- AcWing 180. 排书
- doc.update
- vue实现对数据的增删改查(CURD)
- [DFS] [BFS] poj1979 poj3009 poj3669
- 最短路径之dijkstra算法的C语言实现
- Android笔记:invalidate()和postInvalidate() 的区别及使用(转载)
- 给你一碗孟婆汤,你会忘记什么?
- usb连接不上 艾德克斯电源_工程师,USB与SPI之间如何通信?什么芯片方案可以实现...
- 网络摄像头转usb接口_Arduino + USB Host Sheild 实现USB鼠标转PS/2接口