OpenLTE 基站相关头文件:PHY、MAC、RLC、RRC、PDCP、RB、MME、HSS、GW

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)


物理层: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_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__ */

多媒体层:LTE_fdd_enb_mac.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__ */

无线链路控制层:LTE_fdd_enb_rlc.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__ */

无线资源控制:LTE_fdd_enb_rrc.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__ */

分组数据汇聚层:LTE_fdd_enb_pdcp.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__ */

无线载波:LTE_fdd_enb_rb.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 
#include 

/*******************************************************************************
                              DEFINES
*******************************************************************************/


/*******************************************************************************
                              FORWARD DECLARATIONS
*******************************************************************************/

class LTE_fdd_enb_user;

/*******************************************************************************
                              TYPEDEFS
*******************************************************************************/

typedef enum{
    LTE_FDD_ENB_RB_SRB0 = 0,
    LTE_FDD_ENB_RB_SRB1,
    LTE_FDD_ENB_RB_SRB2,
    LTE_FDD_ENB_RB_DRB1,
    LTE_FDD_ENB_RB_DRB2,
    LTE_FDD_ENB_RB_N_ITEMS,
}LTE_FDD_ENB_RB_ENUM;
static const char LTE_fdd_enb_rb_text[LTE_FDD_ENB_RB_N_ITEMS][20] = {"SRB0",
                                                                     "SRB1",
                                                                     "SRB2",
                                                                     "DRB1",
                                                                     "DRB2"};

typedef enum{
    LTE_FDD_ENB_MME_PROC_IDLE = 0,
    LTE_FDD_ENB_MME_PROC_ATTACH,
    LTE_FDD_ENB_MME_PROC_SERVICE_REQUEST,
    LTE_FDD_ENB_MME_PROC_DETACH,
    LTE_FDD_ENB_MME_PROC_N_ITEMS,
}LTE_FDD_ENB_MME_PROC_ENUM;
static const char LTE_fdd_enb_mme_proc_text[LTE_FDD_ENB_MME_PROC_N_ITEMS][100] = {"IDLE",
                                                                                  "ATTACH",
                                                                                  "SERVICE REQUEST",
                                                                                  "DETACH"};

typedef enum{
    LTE_FDD_ENB_MME_STATE_IDLE = 0,
    LTE_FDD_ENB_MME_STATE_ID_REQUEST_IMSI,
    LTE_FDD_ENB_MME_STATE_REJECT,
    LTE_FDD_ENB_MME_STATE_AUTHENTICATE,
    LTE_FDD_ENB_MME_STATE_AUTH_REJECTED,
    LTE_FDD_ENB_MME_STATE_ENABLE_SECURITY,
    LTE_FDD_ENB_MME_STATE_RELEASE,
    LTE_FDD_ENB_MME_STATE_RRC_SECURITY,
    LTE_FDD_ENB_MME_STATE_ESM_INFO_TRANSFER,
    LTE_FDD_ENB_MME_STATE_ATTACH_ACCEPT,
    LTE_FDD_ENB_MME_STATE_ATTACHED,
    LTE_FDD_ENB_MME_STATE_SETUP_DRB,
    LTE_FDD_ENB_MME_STATE_SEND_DETACH_ACCEPT,
    LTE_FDD_ENB_MME_STATE_N_ITEMS,
}LTE_FDD_ENB_MME_STATE_ENUM;
static const char LTE_fdd_enb_mme_state_text[LTE_FDD_ENB_MME_STATE_N_ITEMS][100] = {"IDLE",
                                                                                    "ID REQUEST IMSI",
                                                                                    "REJECT",
                                                                                    "AUTHENTICATE",
                                                                                    "AUTH REJECTED",
                                                                                    "ENABLE SECURITY",
                                                                                    "RELEASE",
                                                                                    "RRC SECURITY",
                                                                                    "ESM INFO TRANSFER",
                                                                                    "ATTACH ACCEPT",
                                                                                    "ATTACHED",
                                                                                    "SETUP DRB",
                                                                                    "SEND DETACH ACCEPT"};

typedef enum{
    LTE_FDD_ENB_RRC_PROC_IDLE = 0,
    LTE_FDD_ENB_RRC_PROC_RRC_CON_REQ,
    LTE_FDD_ENB_RRC_PROC_RRC_CON_REEST_REQ,
    LTE_FDD_ENB_RRC_PROC_N_ITEMS,
}LTE_FDD_ENB_RRC_PROC_ENUM;
static const char LTE_fdd_enb_rrc_proc_text[LTE_FDD_ENB_RRC_PROC_N_ITEMS][100] = {"IDLE",
                                                                                  "RRC CON REQ",
                                                                                  "RRC CON REEST REQ"};

typedef enum{
    LTE_FDD_ENB_RRC_STATE_IDLE = 0,
    LTE_FDD_ENB_RRC_STATE_SRB1_SETUP,
    LTE_FDD_ENB_RRC_STATE_WAIT_FOR_CON_SETUP_COMPLETE,
    LTE_FDD_ENB_RRC_STATE_RRC_CONNECTED,
    LTE_FDD_ENB_RRC_STATE_WAIT_FOR_CON_REEST_COMPLETE,
    LTE_FDD_ENB_RRC_STATE_N_ITEMS,
}LTE_FDD_ENB_RRC_STATE_ENUM;
static const char LTE_fdd_enb_rrc_state_text[LTE_FDD_ENB_RRC_STATE_N_ITEMS][100] = {"IDLE",
                                                                                    "SRB1 SETUP",
                                                                                    "WAIT FOR CON SETUP COMPLETE",
                                                                                    "RRC CONNECTED",
                                                                                    "WAIT FOR CON REEST COMPLETE"};

typedef enum{
    LTE_FDD_ENB_PDCP_CONFIG_N_A = 0,
    LTE_FDD_ENB_PDCP_CONFIG_SECURITY,
    LTE_FDD_ENB_PDCP_CONFIG_LONG_SN,
    LTE_FDD_ENB_PDCP_CONFIG_N_ITEMS,
}LTE_FDD_ENB_PDCP_CONFIG_ENUM;
static const char LTE_fdd_enb_pdcp_config_text[LTE_FDD_ENB_PDCP_CONFIG_N_ITEMS][20] = {"N/A",
                                                                                       "SECURITY",
                                                                                       "LONG SN"};

typedef enum{
    LTE_FDD_ENB_RLC_CONFIG_TM = 0,
    LTE_FDD_ENB_RLC_CONFIG_UM,
    LTE_FDD_ENB_RLC_CONFIG_AM,
    LTE_FDD_ENB_RLC_CONFIG_N_ITEMS,
}LTE_FDD_ENB_RLC_CONFIG_ENUM;
static const char LTE_fdd_enb_rlc_config_text[LTE_FDD_ENB_RLC_CONFIG_N_ITEMS][20] = {"TM",
                                                                                     "UM",
                                                                                     "AM"};

typedef enum{
    LTE_FDD_ENB_MAC_CONFIG_TM = 0,
    LTE_FDD_ENB_MAC_CONFIG_N_ITEMS,
}LTE_FDD_ENB_MAC_CONFIG_ENUM;
static const char LTE_fdd_enb_mac_config_text[LTE_FDD_ENB_MAC_CONFIG_N_ITEMS][20] = {"TM"};

/*******************************************************************************
                              CLASS DECLARATIONS
*******************************************************************************/

class LTE_fdd_enb_rb
{
public:
    // Constructor/Destructor
    LTE_fdd_enb_rb(LTE_FDD_ENB_RB_ENUM _rb, LTE_fdd_enb_user *_user);
    ~LTE_fdd_enb_rb();

    // Identity
    LTE_FDD_ENB_RB_ENUM get_rb_id(void);
    LTE_fdd_enb_user* get_user(void);
    void reset_user(LTE_fdd_enb_user *_user);

    // GW
    void queue_gw_data_msg(LIBLTE_BYTE_MSG_STRUCT *gw_data);
    LTE_FDD_ENB_ERROR_ENUM get_next_gw_data_msg(LIBLTE_BYTE_MSG_STRUCT **gw_data);
    LTE_FDD_ENB_ERROR_ENUM delete_next_gw_data_msg(void);

    // MME
    void queue_mme_nas_msg(LIBLTE_BYTE_MSG_STRUCT *nas_msg);
    LTE_FDD_ENB_ERROR_ENUM get_next_mme_nas_msg(LIBLTE_BYTE_MSG_STRUCT **nas_msg);
    LTE_FDD_ENB_ERROR_ENUM delete_next_mme_nas_msg(void);
    void set_mme_procedure(LTE_FDD_ENB_MME_PROC_ENUM procedure);
    LTE_FDD_ENB_MME_PROC_ENUM get_mme_procedure(void);
    void set_mme_state(LTE_FDD_ENB_MME_STATE_ENUM state);
    LTE_FDD_ENB_MME_STATE_ENUM get_mme_state(void);

    // RRC
    LIBLTE_RRC_UL_CCCH_MSG_STRUCT ul_ccch_msg;
    LIBLTE_RRC_UL_DCCH_MSG_STRUCT ul_dcch_msg;
    LIBLTE_RRC_DL_CCCH_MSG_STRUCT dl_ccch_msg;
    LIBLTE_RRC_DL_DCCH_MSG_STRUCT dl_dcch_msg;
    void queue_rrc_pdu(LIBLTE_BIT_MSG_STRUCT *pdu);
    LTE_FDD_ENB_ERROR_ENUM get_next_rrc_pdu(LIBLTE_BIT_MSG_STRUCT **pdu);
    LTE_FDD_ENB_ERROR_ENUM delete_next_rrc_pdu(void);
    void queue_rrc_nas_msg(LIBLTE_BYTE_MSG_STRUCT *nas_msg);
    LTE_FDD_ENB_ERROR_ENUM get_next_rrc_nas_msg(LIBLTE_BYTE_MSG_STRUCT **nas_msg);
    LTE_FDD_ENB_ERROR_ENUM delete_next_rrc_nas_msg(void);
    void set_rrc_procedure(LTE_FDD_ENB_RRC_PROC_ENUM procedure);
    LTE_FDD_ENB_RRC_PROC_ENUM get_rrc_procedure(void);
    void set_rrc_state(LTE_FDD_ENB_RRC_STATE_ENUM state);
    LTE_FDD_ENB_RRC_STATE_ENUM get_rrc_state(void);
    uint8 get_rrc_transaction_id(void);
    void set_rrc_transaction_id(uint8 transaction_id);

    // PDCP
    void queue_pdcp_pdu(LIBLTE_BYTE_MSG_STRUCT *pdu);
    LTE_FDD_ENB_ERROR_ENUM get_next_pdcp_pdu(LIBLTE_BYTE_MSG_STRUCT **pdu);
    LTE_FDD_ENB_ERROR_ENUM delete_next_pdcp_pdu(void);
    void queue_pdcp_sdu(LIBLTE_BIT_MSG_STRUCT *sdu);
    LTE_FDD_ENB_ERROR_ENUM get_next_pdcp_sdu(LIBLTE_BIT_MSG_STRUCT **sdu);
    LTE_FDD_ENB_ERROR_ENUM delete_next_pdcp_sdu(void);
    void queue_pdcp_data_sdu(LIBLTE_BYTE_MSG_STRUCT *sdu);
    LTE_FDD_ENB_ERROR_ENUM get_next_pdcp_data_sdu(LIBLTE_BYTE_MSG_STRUCT **sdu);
    LTE_FDD_ENB_ERROR_ENUM delete_next_pdcp_data_sdu(void);
    void set_pdcp_config(LTE_FDD_ENB_PDCP_CONFIG_ENUM config);
    LTE_FDD_ENB_PDCP_CONFIG_ENUM get_pdcp_config(void);
    uint32 get_pdcp_rx_count(void);
    void set_pdcp_rx_count(uint32 rx_count);
    uint32 get_pdcp_tx_count(void);
    void set_pdcp_tx_count(uint32 tx_count);

    // RLC
    void queue_rlc_pdu(LIBLTE_BYTE_MSG_STRUCT *pdu);
    LTE_FDD_ENB_ERROR_ENUM get_next_rlc_pdu(LIBLTE_BYTE_MSG_STRUCT **pdu);
    LTE_FDD_ENB_ERROR_ENUM delete_next_rlc_pdu(void);
    void queue_rlc_sdu(LIBLTE_BYTE_MSG_STRUCT *sdu);
    LTE_FDD_ENB_ERROR_ENUM get_next_rlc_sdu(LIBLTE_BYTE_MSG_STRUCT **sdu);
    LTE_FDD_ENB_ERROR_ENUM delete_next_rlc_sdu(void);
    LTE_FDD_ENB_RLC_CONFIG_ENUM get_rlc_config(void);
    uint16 get_rlc_vrr(void);
    void set_rlc_vrr(uint16 vrr);
    void update_rlc_vrr(void);
    uint16 get_rlc_vrmr(void);
    uint16 get_rlc_vrh(void);
    void set_rlc_vrh(uint16 vrh);
    void rlc_add_to_am_reception_buffer(LIBLTE_RLC_SINGLE_AMD_PDU_STRUCT *amd_pdu);
    void rlc_get_am_reception_buffer_status(LIBLTE_RLC_STATUS_PDU_STRUCT *status);
    LTE_FDD_ENB_ERROR_ENUM rlc_am_reassemble(LIBLTE_BYTE_MSG_STRUCT *sdu);
    uint16 get_rlc_vta(void);
    void set_rlc_vta(uint16 vta);
    uint16 get_rlc_vtms(void);
    uint16 get_rlc_vts(void);
    void set_rlc_vts(uint16 vts);
    void rlc_add_to_transmission_buffer(LIBLTE_RLC_SINGLE_AMD_PDU_STRUCT *amd_pdu);
    void rlc_update_transmission_buffer(LIBLTE_RLC_STATUS_PDU_STRUCT *status);
    void rlc_start_t_poll_retransmit(void);
    void rlc_stop_t_poll_retransmit(void);
    void handle_t_poll_retransmit_timer_expiry(uint32 timer_id);
    void set_rlc_vruh(uint16 vruh);
    uint16 get_rlc_vruh(void);
    void set_rlc_vrur(uint16 vrur);
    uint16 get_rlc_vrur(void);
    uint16 get_rlc_um_window_size(void);
    void rlc_add_to_um_reception_buffer(LIBLTE_RLC_UMD_PDU_STRUCT *umd_pdu, uint32 idx);
    LTE_FDD_ENB_ERROR_ENUM rlc_um_reassemble(LIBLTE_BYTE_MSG_STRUCT *sdu);
    void set_rlc_vtus(uint16 vtus);
    uint16 get_rlc_vtus(void);

    // MAC
    void queue_mac_sdu(LIBLTE_BYTE_MSG_STRUCT *sdu);
    LTE_FDD_ENB_ERROR_ENUM get_next_mac_sdu(LIBLTE_BYTE_MSG_STRUCT **sdu);
    LTE_FDD_ENB_ERROR_ENUM delete_next_mac_sdu(void);
    LTE_FDD_ENB_MAC_CONFIG_ENUM get_mac_config(void);
    void set_con_res_id(uint64 con_res_id);
    uint64 get_con_res_id(void);
    void set_send_con_res_id(bool send_con_res_id);
    bool get_send_con_res_id(void);

    // DRB
    void set_eps_bearer_id(uint32 ebi);
    uint32 get_eps_bearer_id(void);
    void set_lc_id(uint32 _lc_id);
    uint32 get_lc_id(void);
    void set_drb_id(uint8 _drb_id);
    uint8 get_drb_id(void);
    void set_log_chan_group(uint8 lcg);
    uint8 get_log_chan_group(void);

private:
    // Identity
    LTE_FDD_ENB_RB_ENUM  rb;
    LTE_fdd_enb_user    *user;

    // GW
    sem_t                               gw_data_msg_queue_sem;
    std::list gw_data_msg_queue;

    // MME
    sem_t                               mme_nas_msg_queue_sem;
    std::list mme_nas_msg_queue;
    LTE_FDD_ENB_MME_PROC_ENUM           mme_procedure;
    LTE_FDD_ENB_MME_STATE_ENUM          mme_state;

    // RRC
    sem_t                               rrc_pdu_queue_sem;
    sem_t                               rrc_nas_msg_queue_sem;
    std::list  rrc_pdu_queue;
    std::list rrc_nas_msg_queue;
    LTE_FDD_ENB_RRC_PROC_ENUM           rrc_procedure;
    LTE_FDD_ENB_RRC_STATE_ENUM          rrc_state;
    uint8                               rrc_transaction_id;

    // PDCP
    sem_t                               pdcp_pdu_queue_sem;
    sem_t                               pdcp_sdu_queue_sem;
    sem_t                               pdcp_data_sdu_queue_sem;
    std::list pdcp_pdu_queue;
    std::list  pdcp_sdu_queue;
    std::list pdcp_data_sdu_queue;
    LTE_FDD_ENB_PDCP_CONFIG_ENUM        pdcp_config;
    uint32                              pdcp_rx_count;
    uint32                              pdcp_tx_count;

    // RLC
    sem_t                                                rlc_pdu_queue_sem;
    sem_t                                                rlc_sdu_queue_sem;
    std::list                  rlc_pdu_queue;
    std::list                  rlc_sdu_queue;
    std::map rlc_am_reception_buffer;
    std::map rlc_am_transmission_buffer;
    std::map           rlc_um_reception_buffer;
    LTE_FDD_ENB_RLC_CONFIG_ENUM                          rlc_config;
    uint32                                               t_poll_retransmit_timer_id;
    uint16                                               rlc_vrr;
    uint16                                               rlc_vrmr;
    uint16                                               rlc_vrh;
    uint16                                               rlc_vta;
    uint16                                               rlc_vtms;
    uint16                                               rlc_vts;
    uint16                                               rlc_vruh;
    uint16                                               rlc_vrur;
    uint16                                               rlc_um_window_size;
    uint16                                               rlc_first_um_segment_sn;
    uint16                                               rlc_last_um_segment_sn;
    uint16                                               rlc_vtus;

    // MAC
    sem_t                               mac_sdu_queue_sem;
    std::list mac_sdu_queue;
    LTE_FDD_ENB_MAC_CONFIG_ENUM         mac_config;
    uint64                              mac_con_res_id;
    bool                                mac_send_con_res_id;

    // DRB
    uint32 eps_bearer_id;
    uint32 lc_id;
    uint8  drb_id;
    uint8  log_chan_group;

    // Generic
    void queue_msg(LIBLTE_BIT_MSG_STRUCT *msg, sem_t *sem, std::list *queue);
    void queue_msg(LIBLTE_BYTE_MSG_STRUCT *msg, sem_t *sem, std::list *queue);
    LTE_FDD_ENB_ERROR_ENUM get_next_msg(sem_t *sem, std::list *queue, LIBLTE_BIT_MSG_STRUCT **msg);
    LTE_FDD_ENB_ERROR_ENUM get_next_msg(sem_t *sem, std::list *queue, LIBLTE_BYTE_MSG_STRUCT **msg);
    LTE_FDD_ENB_ERROR_ENUM delete_next_msg(sem_t *sem, std::list *queue);
    LTE_FDD_ENB_ERROR_ENUM delete_next_msg(sem_t *sem, std::list *queue);
};

#endif /* __LTE_FDD_ENB_RB_H__ */

移动管理实体层:LTE_fdd_enb_mme.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_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__ */

数据库服务:LTE_fdd_enb_hss.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__ */

网关:LTE_fdd_enb_gw.h (S-GW, P-GW)

/*******************************************************************************

    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

 

你可能感兴趣的:(无线通信)