Table of Contents
物理层:LTE_fdd_enb_phy.h
多媒体层:LTE_fdd_enb_mac.h
无线链路控制层:LTE_fdd_enb_rlc.h
无线资源控制:LTE_fdd_enb_rrc.h
分组数据汇聚层:LTE_fdd_enb_pdcp.h
无线载波:LTE_fdd_enb_rb.h
移动管理实体层:LTE_fdd_enb_mme.h
数据库服务:LTE_fdd_enb_hss.h
网关:LTE_fdd_enb_gw.h (S-GW, P-GW)
/*******************************************************************************
Copyright 2013-2017 Ben Wojtowicz
This program 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.
This program 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.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*******************************************************************************
File: LTE_fdd_enb_phy.h
Description: Contains all the definitions for the LTE FDD eNodeB
physical layer.
Revision History
---------- ------------- --------------------------------------------
11/09/2013 Ben Wojtowicz Created file
01/18/2014 Ben Wojtowicz Cached a copy of the interface class and
added the ability to handle late subframes.
05/04/2014 Ben Wojtowicz Added PHICH support.
06/15/2014 Ben Wojtowicz Changed fn_combo to current_tti.
12/16/2014 Ben Wojtowicz Added ol extension to message queue.
02/15/2015 Ben Wojtowicz Moved to new message queue.
07/25/2015 Ben Wojtowicz Combined the DL and UL schedule messages into
a single PHY schedule message.
12/06/2015 Ben Wojtowicz Changed boost::mutex to sem_t.
07/31/2016 Ben Wojtowicz Added an external interface for getting the
current TTIs.
07/29/2017 Ben Wojtowicz Added IPC direct to a UE PHY.
*******************************************************************************/
#ifndef __LTE_FDD_ENB_PHY_H__
#define __LTE_FDD_ENB_PHY_H__
/*******************************************************************************
INCLUDES
*******************************************************************************/
#include "LTE_fdd_enb_interface.h"
#include "LTE_fdd_enb_cnfg_db.h"
#include "LTE_fdd_enb_msgq.h"
#include "LTE_fdd_enb_radio.h"
#include "liblte_phy.h"
/*******************************************************************************
DEFINES
*******************************************************************************/
#define LTE_FDD_ENB_CURRENT_TTI_MAX (LIBLTE_PHY_SFN_MAX*10 + 9)
/*******************************************************************************
FORWARD DECLARATIONS
*******************************************************************************/
/*******************************************************************************
TYPEDEFS
*******************************************************************************/
/*******************************************************************************
CLASS DECLARATIONS
*******************************************************************************/
class LTE_fdd_enb_phy
{
public:
// Singleton
static LTE_fdd_enb_phy* get_instance(void);
static void cleanup(void);
// Start/Stop
void start(LTE_fdd_enb_msgq *from_mac, LTE_fdd_enb_msgq *to_mac, bool direct_to_ue, LTE_fdd_enb_interface *iface);
void stop(void);
// External interface
void update_sys_info(void);
uint32 get_n_cce(void);
void get_current_ttis(uint32 *dl_tti, uint32 *ul_tti);
// Radio interface
void radio_interface(LTE_FDD_ENB_RADIO_TX_BUF_STRUCT *tx_buf, LTE_FDD_ENB_RADIO_RX_BUF_STRUCT *rx_buf);
void radio_interface(LTE_FDD_ENB_RADIO_TX_BUF_STRUCT *tx_buf);
private:
// Singleton
static LTE_fdd_enb_phy *instance;
LTE_fdd_enb_phy();
~LTE_fdd_enb_phy();
// Start/Stop
LTE_fdd_enb_interface *interface;
bool started;
// Communication
void handle_mac_msg(LTE_FDD_ENB_MESSAGE_STRUCT &msg);
void handle_ue_msg(LIBTOOLS_IPC_MSGQ_MESSAGE_STRUCT *msg);
LTE_fdd_enb_msgq *msgq_from_mac;
LTE_fdd_enb_msgq *msgq_to_mac;
libtools_ipc_msgq *msgq_to_ue;
// Generic parameters
LIBLTE_PHY_STRUCT *phy_struct;
// Downlink
void handle_phy_schedule(LTE_FDD_ENB_PHY_SCHEDULE_MSG_STRUCT *phy_sched);
void process_dl(LTE_FDD_ENB_RADIO_TX_BUF_STRUCT *tx_buf);
sem_t sys_info_sem;
sem_t dl_sched_sem;
sem_t ul_sched_sem;
LTE_FDD_ENB_SYS_INFO_STRUCT sys_info;
LTE_FDD_ENB_DL_SCHEDULE_MSG_STRUCT dl_schedule[10];
LTE_FDD_ENB_UL_SCHEDULE_MSG_STRUCT ul_schedule[10];
LIBLTE_PHY_PCFICH_STRUCT pcfich;
LIBLTE_PHY_PHICH_STRUCT phich[10];
LIBLTE_PHY_PDCCH_STRUCT pdcch;
LIBLTE_PHY_SUBFRAME_STRUCT dl_subframe;
LIBLTE_BIT_MSG_STRUCT dl_rrc_msg;
uint32 dl_current_tti;
uint32 last_rts_current_tti;
bool late_subfr;
// Uplink
void process_ul(LTE_FDD_ENB_RADIO_RX_BUF_STRUCT *rx_buf);
LTE_FDD_ENB_PRACH_DECODE_MSG_STRUCT prach_decode;
LTE_FDD_ENB_PUCCH_DECODE_MSG_STRUCT pucch_decode;
LTE_FDD_ENB_PUSCH_DECODE_MSG_STRUCT pusch_decode;
LIBLTE_PHY_SUBFRAME_STRUCT ul_subframe;
uint32 ul_current_tti;
uint32 prach_sfn_mod;
uint32 prach_subfn_mod;
uint32 prach_subfn_check;
bool prach_subfn_zero_allowed;
};
#endif /* __LTE_FDD_ENB_PHY_H__ */
/*******************************************************************************
Copyright 2013-2017 Ben Wojtowicz
This program 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.
This program 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.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*******************************************************************************
File: LTE_fdd_enb_mac.h
Description: Contains all the definitions for the LTE FDD eNodeB
medium access control layer.
Revision History
---------- ------------- --------------------------------------------
11/09/2013 Ben Wojtowicz Created file
01/18/2014 Ben Wojtowicz Cached a copy of the interface class.
05/04/2014 Ben Wojtowicz Added ULSCH handling.
06/15/2014 Ben Wojtowicz Added uplink scheduling and changed fn_combo
to current_tti.
11/29/2014 Ben Wojtowicz Using the byte message struct for SDUs.
12/16/2014 Ben Wojtowicz Added ol extension to message queues.
02/15/2015 Ben Wojtowicz Moved to new message queue.
12/06/2015 Ben Wojtowicz Changed boost::mutex to sem_t and added some
helper functions.
02/13/2016 Ben Wojtowicz Removed boost message queue include.
07/31/2016 Ben Wojtowicz Added a define for max HARQ retransmissions.
07/29/2017 Ben Wojtowicz Added SR support and added IPC direct to a UE
MAC.
*******************************************************************************/
#ifndef __LTE_FDD_ENB_MAC_H__
#define __LTE_FDD_ENB_MAC_H__
/*******************************************************************************
INCLUDES
*******************************************************************************/
#include "LTE_fdd_enb_interface.h"
#include "LTE_fdd_enb_cnfg_db.h"
#include "LTE_fdd_enb_msgq.h"
#include "LTE_fdd_enb_user.h"
#include "liblte_mac.h"
#include "libtools_ipc_msgq.h"
#include
/*******************************************************************************
DEFINES
*******************************************************************************/
#define LTE_FDD_ENB_MAX_HARQ_RETX 5
/*******************************************************************************
FORWARD DECLARATIONS
*******************************************************************************/
/*******************************************************************************
TYPEDEFS
*******************************************************************************/
typedef struct{
LIBLTE_PHY_ALLOCATION_STRUCT dl_alloc;
LIBLTE_PHY_ALLOCATION_STRUCT ul_alloc;
LIBLTE_MAC_RAR_STRUCT rar;
uint32 current_tti;
}LTE_FDD_ENB_RAR_SCHED_QUEUE_STRUCT;
typedef struct{
LIBLTE_PHY_ALLOCATION_STRUCT alloc;
LIBLTE_MAC_PDU_STRUCT mac_pdu;
uint32 current_tti;
}LTE_FDD_ENB_DL_SCHED_QUEUE_STRUCT;
typedef struct{
LIBLTE_PHY_ALLOCATION_STRUCT alloc;
uint32 current_tti;
}LTE_FDD_ENB_UL_SCHED_QUEUE_STRUCT;
typedef struct{
uint32 i_sr;
uint32 n_1_p_pucch;
uint16 rnti;
}LTE_FDD_ENB_UL_SR_SCHED_QUEUE_STRUCT;
/*******************************************************************************
CLASS DECLARATIONS
*******************************************************************************/
class LTE_fdd_enb_mac
{
public:
// Singleton
static LTE_fdd_enb_mac* get_instance(void);
static void cleanup(void);
// Start/Stop
void start(LTE_fdd_enb_msgq *from_phy, LTE_fdd_enb_msgq *from_rlc, LTE_fdd_enb_msgq *to_phy, LTE_fdd_enb_msgq *to_rlc, LTE_fdd_enb_msgq *to_timer, bool direct_to_ue, LTE_fdd_enb_interface *iface);
void stop(void);
// External interface
void update_sys_info(void);
void add_periodic_sr_pucch(uint16 rnti, uint32 i_sr, uint32 n_1_p_pucch);
void remove_periodic_sr_pucch(uint16 rnti);
private:
// Singleton
static LTE_fdd_enb_mac *instance;
LTE_fdd_enb_mac();
~LTE_fdd_enb_mac();
// Start/Stop
sem_t start_sem;
LTE_fdd_enb_interface *interface;
bool started;
// Communication
void handle_phy_msg(LTE_FDD_ENB_MESSAGE_STRUCT &msg);
void handle_rlc_msg(LTE_FDD_ENB_MESSAGE_STRUCT &msg);
void handle_ue_msg(LIBTOOLS_IPC_MSGQ_MESSAGE_STRUCT *msg);
LTE_fdd_enb_msgq *msgq_from_phy;
LTE_fdd_enb_msgq *msgq_from_rlc;
LTE_fdd_enb_msgq *msgq_to_phy;
LTE_fdd_enb_msgq *msgq_to_rlc;
LTE_fdd_enb_msgq *msgq_to_timer;
libtools_ipc_msgq *msgq_to_ue;
// PHY Message Handlers
void handle_ready_to_send(LTE_FDD_ENB_READY_TO_SEND_MSG_STRUCT *rts);
void handle_prach_decode(LTE_FDD_ENB_PRACH_DECODE_MSG_STRUCT *prach_decode);
void handle_pucch_decode(LTE_FDD_ENB_PUCCH_DECODE_MSG_STRUCT *pucch_decode);
void handle_pucch_ack_nack(LTE_fdd_enb_user *user, uint32 current_tti, LIBLTE_BIT_MSG_STRUCT *msg);
void handle_pucch_sr(LTE_fdd_enb_user *user, uint32 current_tti, LIBLTE_BIT_MSG_STRUCT *msg);
void handle_pusch_decode(LTE_FDD_ENB_PUSCH_DECODE_MSG_STRUCT *pusch_decode);
// RLC Message Handlers
void handle_sdu_ready(LTE_FDD_ENB_MAC_SDU_READY_MSG_STRUCT *sdu_ready);
// MAC PDU Handlers
void handle_ulsch_ccch_sdu(LTE_fdd_enb_user *user, uint32 lcid, LIBLTE_BYTE_MSG_STRUCT *sdu);
void handle_ulsch_dcch_sdu(LTE_fdd_enb_user *user, uint32 lcid, LIBLTE_BYTE_MSG_STRUCT *sdu);
void handle_ulsch_ext_power_headroom_report(LTE_fdd_enb_user *user, LIBLTE_MAC_EXT_POWER_HEADROOM_CE_STRUCT *ext_power_headroom);
void handle_ulsch_power_headroom_report(LTE_fdd_enb_user *user, LIBLTE_MAC_POWER_HEADROOM_CE_STRUCT *power_headroom);
void handle_ulsch_c_rnti(LTE_fdd_enb_user **user, LIBLTE_MAC_C_RNTI_CE_STRUCT *c_rnti);
void handle_ulsch_truncated_bsr(LTE_fdd_enb_user *user, LIBLTE_MAC_TRUNCATED_BSR_CE_STRUCT *truncated_bsr);
void handle_ulsch_short_bsr(LTE_fdd_enb_user *user, LIBLTE_MAC_SHORT_BSR_CE_STRUCT *short_bsr);
void handle_ulsch_long_bsr(LTE_fdd_enb_user *user, LIBLTE_MAC_LONG_BSR_CE_STRUCT *long_bsr);
// Data Constructors
void construct_random_access_response(uint8 preamble, uint16 timing_adv, uint32 current_tti);
// Scheduler
void sched_ul(LTE_fdd_enb_user *user, uint32 requested_tbs);
void scheduler(void);
LTE_FDD_ENB_ERROR_ENUM add_to_rar_sched_queue(uint32 current_tti, LIBLTE_PHY_ALLOCATION_STRUCT *dl_alloc, LIBLTE_PHY_ALLOCATION_STRUCT *ul_alloc, LIBLTE_MAC_RAR_STRUCT *rar);
LTE_FDD_ENB_ERROR_ENUM add_to_dl_sched_queue(uint32 current_tti, LIBLTE_MAC_PDU_STRUCT *mac_pdu, LIBLTE_PHY_ALLOCATION_STRUCT *alloc);
LTE_FDD_ENB_ERROR_ENUM add_to_ul_sched_queue(uint32 current_tti, LIBLTE_PHY_ALLOCATION_STRUCT *alloc);
sem_t rar_sched_queue_sem;
sem_t dl_sched_queue_sem;
sem_t ul_sched_queue_sem;
sem_t ul_sr_sched_queue_sem;
std::list rar_sched_queue;
std::list dl_sched_queue;
std::list ul_sched_queue;
std::list ul_sr_sched_queue;
LTE_FDD_ENB_DL_SCHEDULE_MSG_STRUCT sched_dl_subfr[10];
LTE_FDD_ENB_UL_SCHEDULE_MSG_STRUCT sched_ul_subfr[10];
uint8 sched_cur_dl_subfn;
uint8 sched_cur_ul_subfn;
// Parameters
sem_t sys_info_sem;
LTE_FDD_ENB_SYS_INFO_STRUCT sys_info;
// Helpers
uint32 get_n_reserved_prbs(uint32 current_tti);
uint32 add_to_tti(uint32 tti, uint32 addition);
bool is_tti_in_future(uint32 tti_to_check, uint32 current_tti);
};
#endif /* __LTE_FDD_ENB_MAC_H__ */
/*******************************************************************************
Copyright 2013-2016 Ben Wojtowicz
This program 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.
This program 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.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*******************************************************************************
File: LTE_fdd_enb_rlc.h
Description: Contains all the definitions for the LTE FDD eNodeB
radio link control layer.
Revision History
---------- ------------- --------------------------------------------
11/09/2013 Ben Wojtowicz Created file
05/04/2014 Ben Wojtowicz Added communication to MAC and PDCP.
06/15/2014 Ben Wojtowicz Using the latest LTE library.
08/03/2014 Ben Wojtowicz Added transmit functionality.
11/29/2014 Ben Wojtowicz Using the byte message structure.
12/16/2014 Ben Wojtowicz Added ol extension to message queues.
02/15/2015 Ben Wojtowicz Moved to new message queue.
12/06/2015 Ben Wojtowicz Changed boost::mutex to sem_t.
02/13/2016 Ben Wojtowicz Removed boost message queue include.
12/18/2016 Ben Wojtowicz Properly handling multiple AMD PDUs.
*******************************************************************************/
#ifndef __LTE_FDD_ENB_RLC_H__
#define __LTE_FDD_ENB_RLC_H__
/*******************************************************************************
INCLUDES
*******************************************************************************/
#include "LTE_fdd_enb_cnfg_db.h"
#include "LTE_fdd_enb_msgq.h"
/*******************************************************************************
DEFINES
*******************************************************************************/
/*******************************************************************************
FORWARD DECLARATIONS
*******************************************************************************/
/*******************************************************************************
TYPEDEFS
*******************************************************************************/
/*******************************************************************************
CLASS DECLARATIONS
*******************************************************************************/
class LTE_fdd_enb_rlc
{
public:
// Singleton
static LTE_fdd_enb_rlc* get_instance(void);
static void cleanup(void);
// Start/Stop
void start(LTE_fdd_enb_msgq *from_mac, LTE_fdd_enb_msgq *from_pdcp, LTE_fdd_enb_msgq *to_mac, LTE_fdd_enb_msgq *to_pdcp, LTE_fdd_enb_interface *iface);
void stop(void);
// External interface
void update_sys_info(void);
void handle_retransmit(LIBLTE_RLC_SINGLE_AMD_PDU_STRUCT *amd, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
private:
// Singleton
static LTE_fdd_enb_rlc *instance;
LTE_fdd_enb_rlc();
~LTE_fdd_enb_rlc();
// Start/Stop
LTE_fdd_enb_interface *interface;
sem_t start_sem;
bool started;
// Communication
void handle_mac_msg(LTE_FDD_ENB_MESSAGE_STRUCT &msg);
void handle_pdcp_msg(LTE_FDD_ENB_MESSAGE_STRUCT &msg);
LTE_fdd_enb_msgq *msgq_from_mac;
LTE_fdd_enb_msgq *msgq_from_pdcp;
LTE_fdd_enb_msgq *msgq_to_mac;
LTE_fdd_enb_msgq *msgq_to_pdcp;
// MAC Message Handlers
void handle_pdu_ready(LTE_FDD_ENB_RLC_PDU_READY_MSG_STRUCT *pdu_ready);
void handle_tm_pdu(LIBLTE_BYTE_MSG_STRUCT *pdu, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void handle_um_pdu(LIBLTE_BYTE_MSG_STRUCT *pdu, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void handle_am_pdu(LIBLTE_BYTE_MSG_STRUCT *pdu, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void handle_status_pdu(LIBLTE_BYTE_MSG_STRUCT *pdu, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
// PDCP Message Handlers
void handle_sdu_ready(LTE_FDD_ENB_RLC_SDU_READY_MSG_STRUCT *sdu_ready);
void handle_tm_sdu(LIBLTE_BYTE_MSG_STRUCT *sdu, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void handle_um_sdu(LIBLTE_BYTE_MSG_STRUCT *sdu, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void handle_am_sdu(LIBLTE_BYTE_MSG_STRUCT *sdu, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
// Message Constructors
void send_status_pdu(LIBLTE_RLC_STATUS_PDU_STRUCT *status_pdu, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_amd_pdu(LIBLTE_RLC_SINGLE_AMD_PDU_STRUCT *amd, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
// Parameters
sem_t sys_info_sem;
LTE_FDD_ENB_SYS_INFO_STRUCT sys_info;
};
#endif /* __LTE_FDD_ENB_RLC_H__ */
/*******************************************************************************
Copyright 2013-2017 Ben Wojtowicz
Copyright 2016 Przemek Bereski (send_ue_capability_enquiry)
This program 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.
This program 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.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*******************************************************************************
File: LTE_fdd_enb_rrc.h
Description: Contains all the definitions for the LTE FDD eNodeB
radio resource control layer.
Revision History
---------- ------------- --------------------------------------------
11/09/2013 Ben Wojtowicz Created file
05/04/2014 Ben Wojtowicz Added PDCP communication and UL CCCH state
machine.
06/15/2014 Ben Wojtowicz Added UL DCCH message handling and MME NAS
message handling.
08/03/2014 Ben Wojtowicz Added downlink NAS message handling and
connection release.
11/01/2014 Ben Wojtowicz Added RRC connection reconfiguration and
security mode command messages.
11/29/2014 Ben Wojtowicz Added user and rb update to
parse_ul_ccch_message.
12/16/2014 Ben Wojtowicz Added ol extension to message queues.
02/15/2015 Ben Wojtowicz Moved to new message queue.
12/06/2015 Ben Wojtowicz Changed boost::mutex to sem_t.
02/13/2016 Ben Wojtowicz Removed boost message queue include and
add support for connection reestablishment
and connection reestablishment reject.
07/03/2016 Przemek Bereski Added send_ue_capability_enquiry.
07/29/2017 Ben Wojtowicz Added SR support.
*******************************************************************************/
#ifndef __LTE_FDD_ENB_RRC_H__
#define __LTE_FDD_ENB_RRC_H__
/*******************************************************************************
INCLUDES
*******************************************************************************/
#include "LTE_fdd_enb_cnfg_db.h"
#include "LTE_fdd_enb_user.h"
#include "LTE_fdd_enb_msgq.h"
/*******************************************************************************
DEFINES
*******************************************************************************/
/*******************************************************************************
FORWARD DECLARATIONS
*******************************************************************************/
/*******************************************************************************
TYPEDEFS
*******************************************************************************/
/*******************************************************************************
CLASS DECLARATIONS
*******************************************************************************/
class LTE_fdd_enb_rrc
{
public:
// Singleton
static LTE_fdd_enb_rrc* get_instance(void);
static void cleanup(void);
// Start/Stop
void start(LTE_fdd_enb_msgq *from_pdcp, LTE_fdd_enb_msgq *from_mme, LTE_fdd_enb_msgq *to_pdcp, LTE_fdd_enb_msgq *to_mme, LTE_fdd_enb_interface *iface);
void stop(void);
// External interface
void update_sys_info(void);
void handle_cmd(LTE_FDD_ENB_RRC_CMD_READY_MSG_STRUCT *cmd);
private:
// Singleton
static LTE_fdd_enb_rrc *instance;
LTE_fdd_enb_rrc();
~LTE_fdd_enb_rrc();
// Start/Stop
LTE_fdd_enb_interface *interface;
sem_t start_sem;
bool started;
// Communication
void handle_pdcp_msg(LTE_FDD_ENB_MESSAGE_STRUCT &msg);
void handle_mme_msg(LTE_FDD_ENB_MESSAGE_STRUCT &msg);
LTE_fdd_enb_msgq *msgq_from_pdcp;
LTE_fdd_enb_msgq *msgq_from_mme;
LTE_fdd_enb_msgq *msgq_to_pdcp;
LTE_fdd_enb_msgq *msgq_to_mme;
// PDCP Message Handlers
void handle_pdu_ready(LTE_FDD_ENB_RRC_PDU_READY_MSG_STRUCT *pdu_ready);
// MME Message Handlers
void handle_nas_msg(LTE_FDD_ENB_RRC_NAS_MSG_READY_MSG_STRUCT *nas_msg);
// State Machines
void ccch_sm(LIBLTE_BIT_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void dcch_sm(LIBLTE_BIT_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
// Message Parsers
void parse_ul_ccch_message(LIBLTE_BIT_MSG_STRUCT *msg, LTE_fdd_enb_user **user, LTE_fdd_enb_rb **rb);
void parse_ul_dcch_message(LIBLTE_BIT_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
// Message Senders
void send_dl_info_transfer(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb, LIBLTE_BYTE_MSG_STRUCT *msg);
void send_rrc_con_reconfig(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb, LIBLTE_BYTE_MSG_STRUCT *msg);
void send_rrc_con_reest(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_rrc_con_reest_reject(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_rrc_con_release(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_rrc_con_setup(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_security_mode_command(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_ue_capability_enquiry(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
// Helpers
void increment_i_sr(void);
// Parameters
sem_t sys_info_sem;
LTE_FDD_ENB_SYS_INFO_STRUCT sys_info;
uint32 i_sr;
};
#endif /* __LTE_FDD_ENB_RRC_H__ */
/*******************************************************************************
Copyright 2013-2017 Ben Wojtowicz
This program 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.
This program 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.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*******************************************************************************
File: LTE_fdd_enb_pdcp.h
Description: Contains all the definitions for the LTE FDD eNodeB
packet data convergence protocol layer.
Revision History
---------- ------------- --------------------------------------------
11/09/2013 Ben Wojtowicz Created file
05/04/2014 Ben Wojtowicz Added communication to RLC and RRC.
11/29/2014 Ben Wojtowicz Added communication to IP gateway.
12/16/2014 Ben Wojtowicz Added ol extension to message queues.
02/15/2015 Ben Wojtowicz Moved to new message queue.
12/06/2015 Ben Wojtowicz Changed boost::mutex to sem_t.
02/13/2016 Ben Wojtowicz Removed boost message queue include.
07/29/2017 Ben Wojtowicz Moved away from singleton pattern.
*******************************************************************************/
#ifndef __LTE_FDD_ENB_PDCP_H__
#define __LTE_FDD_ENB_PDCP_H__
/*******************************************************************************
INCLUDES
*******************************************************************************/
#include "LTE_fdd_enb_cnfg_db.h"
#include "LTE_fdd_enb_msgq.h"
/*******************************************************************************
DEFINES
*******************************************************************************/
/*******************************************************************************
FORWARD DECLARATIONS
*******************************************************************************/
/*******************************************************************************
TYPEDEFS
*******************************************************************************/
/*******************************************************************************
CLASS DECLARATIONS
*******************************************************************************/
class LTE_fdd_enb_pdcp
{
public:
// Constructor/Destructor
LTE_fdd_enb_pdcp();
~LTE_fdd_enb_pdcp();
// Start/Stop
void start(LTE_fdd_enb_msgq *from_rlc, LTE_fdd_enb_msgq *from_rrc, LTE_fdd_enb_msgq *from_gw, LTE_fdd_enb_msgq *to_rlc, LTE_fdd_enb_msgq *to_rrc, LTE_fdd_enb_msgq *to_gw, LTE_fdd_enb_interface *iface);
void stop(void);
// External interface
void update_sys_info(void);
private:
// Start/Stop
LTE_fdd_enb_interface *interface;
sem_t start_sem;
bool started;
// Communication
void handle_rlc_msg(LTE_FDD_ENB_MESSAGE_STRUCT &msg);
void handle_rrc_msg(LTE_FDD_ENB_MESSAGE_STRUCT &msg);
void handle_gw_msg(LTE_FDD_ENB_MESSAGE_STRUCT &msg);
LTE_fdd_enb_msgq *msgq_from_rlc;
LTE_fdd_enb_msgq *msgq_from_rrc;
LTE_fdd_enb_msgq *msgq_from_gw;
LTE_fdd_enb_msgq *msgq_to_rlc;
LTE_fdd_enb_msgq *msgq_to_rrc;
LTE_fdd_enb_msgq *msgq_to_gw;
// RLC Message Handlers
void handle_pdu_ready(LTE_FDD_ENB_PDCP_PDU_READY_MSG_STRUCT *pdu_ready);
// RRC Message Handlers
void handle_sdu_ready(LTE_FDD_ENB_PDCP_SDU_READY_MSG_STRUCT *sdu_ready);
// GW Message Handlers
void handle_data_sdu_ready(LTE_FDD_ENB_PDCP_DATA_SDU_READY_MSG_STRUCT *data_sdu_ready);
// Parameters
sem_t sys_info_sem;
LTE_FDD_ENB_SYS_INFO_STRUCT sys_info;
};
#endif /* __LTE_FDD_ENB_PDCP_H__ */
/*******************************************************************************
Copyright 2014-2017 Ben Wojtowicz
This program 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.
This program 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.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*******************************************************************************
File: LTE_fdd_enb_rb.h
Description: Contains all the definitions for the LTE FDD eNodeB
radio bearer class.
Revision History
---------- ------------- --------------------------------------------
05/04/2014 Ben Wojtowicz Created file
06/15/2014 Ben Wojtowicz Added more states and procedures, QoS, MME,
RLC, and uplink scheduling functionality.
08/03/2014 Ben Wojtowicz Added MME procedures/states, RRC NAS support,
RRC transaction id, PDCP sequence numbers,
and RLC transmit variables.
09/03/2014 Ben Wojtowicz Added more MME states and ability to store
the contention resolution identity.
11/01/2014 Ben Wojtowicz Added more MME states and PDCP security.
11/29/2014 Ben Wojtowicz Added more DRB support, MME states, MME
procedures, and PDCP configs, moved almost
everything to byte messages structs, added
IP gateway and RLC UMD support.
12/16/2014 Ben Wojtowicz Added QoS for default data services.
12/24/2014 Ben Wojtowicz Added asymmetric QoS support.
02/15/2015 Ben Wojtowicz Split UL/DL QoS TTI frequency, added reset
user support, and added multiple UMD RLC data
support.
03/11/2015 Ben Wojtowicz Added detach handling.
07/25/2015 Ben Wojtowicz Moved QoS structure to the user class and
fixed RLC AM TX and RX buffers.
12/06/2015 Ben Wojtowicz Changed boost::mutex to sem_t.
02/13/2016 Ben Wojtowicz Added a wait for RRC connection
reestablishment complete RRC state.
12/18/2016 Ben Wojtowicz Properly handling multiple RLC AMD PDUs.
07/29/2017 Ben Wojtowicz Remove last TTI storage.
*******************************************************************************/
#ifndef __LTE_FDD_ENB_RB_H__
#define __LTE_FDD_ENB_RB_H__
/*******************************************************************************
INCLUDES
*******************************************************************************/
#include "LTE_fdd_enb_common.h"
#include "liblte_rlc.h"
#include "liblte_rrc.h"
#include
#include
/*******************************************************************************
Copyright 2013-2017 Ben Wojtowicz
This program 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.
This program 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.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*******************************************************************************
File: LTE_fdd_enb_mme.h
Description: Contains all the definitions for the LTE FDD eNodeB
mobility management entity layer.
Revision History
---------- ------------- --------------------------------------------
11/09/2013 Ben Wojtowicz Created file
01/18/2014 Ben Wojtowicz Added an explicit include for boost mutexes.
06/15/2014 Ben Wojtowicz Added RRC NAS message handler.
08/03/2014 Ben Wojtowicz Added message parsers, state machines, and
message senders.
09/03/2014 Ben Wojtowicz Added authentication and security support.
11/01/2014 Ben Wojtowicz Added attach accept/complete, ESM info
transfer, and default bearer setup support.
11/29/2014 Ben Wojtowicz Added service request, service reject, and
activate dedicated EPS bearer context
request support.
12/16/2014 Ben Wojtowicz Added ol extension to message queue and
sending of EMM information message.
02/15/2015 Ben Wojtowicz Moved to new message queue.
03/11/2015 Ben Wojtowicz Added detach handling.
12/06/2015 Ben Wojtowicz Changed boost::mutex to sem_t.
02/13/2016 Ben Wojtowicz Removed boost message queue include.
07/29/2017 Ben Wojtowicz Moved away from singleton pattern.
*******************************************************************************/
#ifndef __LTE_FDD_ENB_MME_H__
#define __LTE_FDD_ENB_MME_H__
/*******************************************************************************
INCLUDES
*******************************************************************************/
#include "LTE_fdd_enb_cnfg_db.h"
#include "LTE_fdd_enb_msgq.h"
/*******************************************************************************
DEFINES
*******************************************************************************/
/*******************************************************************************
FORWARD DECLARATIONS
*******************************************************************************/
/*******************************************************************************
TYPEDEFS
*******************************************************************************/
/*******************************************************************************
CLASS DECLARATIONS
*******************************************************************************/
class LTE_fdd_enb_mme
{
public:
// Constructor/Destructor
LTE_fdd_enb_mme();
~LTE_fdd_enb_mme();
// Start/Stop
void start(LTE_fdd_enb_msgq *from_rrc, LTE_fdd_enb_msgq *to_rrc, LTE_fdd_enb_interface *iface);
void stop(void);
// External interface
void update_sys_info(void);
private:
// Start/Stop
LTE_fdd_enb_interface *interface;
sem_t start_sem;
bool started;
// Communication
void handle_rrc_msg(LTE_FDD_ENB_MESSAGE_STRUCT &msg);
LTE_fdd_enb_msgq *msgq_from_rrc;
LTE_fdd_enb_msgq *msgq_to_rrc;
// RRC Message Handlers
void handle_nas_msg(LTE_FDD_ENB_MME_NAS_MSG_READY_MSG_STRUCT *nas_msg);
void handle_rrc_cmd_resp(LTE_FDD_ENB_MME_RRC_CMD_RESP_MSG_STRUCT *rrc_cmd_resp);
// Message Parsers
void parse_attach_complete(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_attach_request(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user **user, LTE_fdd_enb_rb **rb);
void parse_authentication_failure(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_authentication_response(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_detach_request(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_identity_response(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_security_mode_complete(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_security_mode_reject(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_service_request(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_activate_default_eps_bearer_context_accept(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_esm_information_response(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_pdn_connectivity_request(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
// State Machines
void attach_sm(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void service_req_sm(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void detach_sm(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
// Message Senders
void send_attach_accept(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_attach_reject(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_authentication_reject(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_authentication_request(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_detach_accept(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_emm_information(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_identity_request(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb, uint8 id_type);
void send_security_mode_command(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_service_reject(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb, uint8 cause);
void send_activate_dedicated_eps_bearer_context_request(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_esm_information_request(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_rrc_command(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb, LTE_FDD_ENB_RRC_CMD_ENUM cmd);
// Parameters
sem_t sys_info_sem;
LTE_FDD_ENB_SYS_INFO_STRUCT sys_info;
// Helpers
uint32 get_next_ip_addr(void);
uint32 next_ip_addr;
uint32 dns_addr;
};
#endif /* __LTE_FDD_ENB_MME_H__ */
/*******************************************************************************
Copyright 2014-2015 Ben Wojtowicz
This program 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.
This program 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.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*******************************************************************************
File: LTE_fdd_enb_hss.h
Description: Contains all the definitions for the LTE FDD eNodeB
home subscriber server.
Revision History
---------- ------------- --------------------------------------------
06/15/2014 Ben Wojtowicz Created file
08/03/2014 Ben Wojtowicz Added authentication vector support.
09/03/2014 Ben Wojtowicz Added sequence number resynch.
11/01/2014 Ben Wojtowicz Added user file support.
11/29/2014 Ben Wojtowicz Added support for regenerating eNodeB
security data.
12/06/2015 Ben Wojtowicz Changed boost::mutex to sem_t.
*******************************************************************************/
#ifndef __LTE_FDD_ENB_HSS_H__
#define __LTE_FDD_ENB_HSS_H__
/*******************************************************************************
INCLUDES
*******************************************************************************/
#include "LTE_fdd_enb_interface.h"
#include "LTE_fdd_enb_user.h"
#include
/*******************************************************************************
DEFINES
*******************************************************************************/
#define LTE_FDD_ENB_IND_HE_N_BITS 5
#define LTE_FDD_ENB_IND_HE_MASK 0x1FUL
#define LTE_FDD_ENB_IND_HE_MAX_VALUE 31
#define LTE_FDD_ENB_SEQ_HE_MAX_VALUE 0x7FFFFFFFFFFFUL
/*******************************************************************************
FORWARD DECLARATIONS
*******************************************************************************/
/*******************************************************************************
TYPEDEFS
*******************************************************************************/
typedef struct{
uint8 k[16];
}LTE_FDD_ENB_STORED_DATA_STRUCT;
typedef struct{
LTE_FDD_ENB_AUTHENTICATION_VECTOR_STRUCT auth_vec;
uint64 sqn_he;
uint64 seq_he;
uint8 ak[6];
uint8 mac[8];
uint8 k_asme[32];
uint8 k_enb[32];
uint8 k_up_enc[32];
uint8 k_up_int[32];
uint8 ind_he;
}LTE_FDD_ENB_GENERATED_DATA_STRUCT;
typedef struct{
LTE_FDD_ENB_USER_ID_STRUCT id;
LTE_FDD_ENB_STORED_DATA_STRUCT stored_data;
LTE_FDD_ENB_GENERATED_DATA_STRUCT generated_data;
}LTE_FDD_ENB_HSS_USER_STRUCT;
/*******************************************************************************
CLASS DECLARATIONS
*******************************************************************************/
class LTE_fdd_enb_hss
{
public:
// Singleton
static LTE_fdd_enb_hss* get_instance(void);
static void cleanup(void);
// External interface
LTE_FDD_ENB_ERROR_ENUM add_user(std::string imsi, std::string imei, std::string k);
LTE_FDD_ENB_ERROR_ENUM del_user(std::string imsi);
std::string print_all_users(void);
bool is_imsi_allowed(uint64 imsi);
bool is_imei_allowed(uint64 imei);
LTE_FDD_ENB_USER_ID_STRUCT* get_user_id_from_imsi(uint64 imsi);
LTE_FDD_ENB_USER_ID_STRUCT* get_user_id_from_imei(uint64 imei);
void generate_security_data(LTE_FDD_ENB_USER_ID_STRUCT *id, uint16 mcc, uint16 mnc);
void security_resynch(LTE_FDD_ENB_USER_ID_STRUCT *id, uint16 mcc, uint16 mnc, uint8 *auts);
LTE_FDD_ENB_AUTHENTICATION_VECTOR_STRUCT* regenerate_enb_security_data(LTE_FDD_ENB_USER_ID_STRUCT *id, uint32 nas_count_ul);
LTE_FDD_ENB_AUTHENTICATION_VECTOR_STRUCT* get_auth_vec(LTE_FDD_ENB_USER_ID_STRUCT *id);
// User File
void set_use_user_file(bool uuf);
void read_user_file(void);
private:
// Singleton
static LTE_fdd_enb_hss *instance;
LTE_fdd_enb_hss();
~LTE_fdd_enb_hss();
// Allowed users
sem_t user_sem;
std::list user_list;
// User File
void write_user_file(void);
void delete_user_file(void);
bool use_user_file;
};
#endif /* __LTE_FDD_ENB_HSS_H__ */
/*******************************************************************************
Copyright 2014-2015, 2017 Ben Wojtowicz
This program 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.
This program 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.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*******************************************************************************
File: LTE_fdd_enb_gw.h
Description: Contains all the definitions for the LTE FDD eNodeB
IP gateway.
Revision History
---------- ------------- --------------------------------------------
11/29/2014 Ben Wojtowicz Created file
12/16/2014 Ben Wojtowicz Added ol extension to message queue.
02/15/2015 Ben Wojtowicz Moved to new message queue.
12/06/2015 Ben Wojtowicz Changed boost::mutex to sem_t.
07/29/2017 Ben Wojtowicz Moved away from singleton pattern.
*******************************************************************************/
#ifndef __LTE_FDD_ENB_GW_H__
#define __LTE_FDD_ENB_GW_H__
/*******************************************************************************
INCLUDES
*******************************************************************************/
#include "LTE_fdd_enb_interface.h"
#include "LTE_fdd_enb_msgq.h"
/*******************************************************************************
DEFINES
*******************************************************************************/
/*******************************************************************************
FORWARD DECLARATIONS
*******************************************************************************/
/*******************************************************************************
TYPEDEFS
*******************************************************************************/
/*******************************************************************************
CLASS DECLARATIONS
*******************************************************************************/
class LTE_fdd_enb_gw
{
public:
// Constructor/Destructor
LTE_fdd_enb_gw();
~LTE_fdd_enb_gw();
// Start/Stop
bool is_started(void);
LTE_FDD_ENB_ERROR_ENUM start(LTE_fdd_enb_msgq *from_pdcp, LTE_fdd_enb_msgq *to_pdcp, char *err_str, LTE_fdd_enb_interface *iface);
void stop(void);
private:
// Start/Stop
LTE_fdd_enb_interface *interface;
sem_t start_sem;
bool started;
// Communication
void handle_pdcp_msg(LTE_FDD_ENB_MESSAGE_STRUCT &msg);
LTE_fdd_enb_msgq *msgq_from_pdcp;
LTE_fdd_enb_msgq *msgq_to_pdcp;
// PDCP Message Handlers
void handle_gw_data(LTE_FDD_ENB_GW_DATA_READY_MSG_STRUCT *gw_data);
// GW Receive
static void* receive_thread(void *inputs);
pthread_t rx_thread;
// TUN device
int32 tun_fd;
};
#endif /* __LTE_FDD_ENB_GW_H__ */
开源项目:https://github.com/mgp25/OpenLTE
感谢:Ben Wojtowicz