Search for posts tagged with: 协议栈

Avatar

国庆,旅游等等杂事让我荒废了接近3个月,现在还是要重新开始努力了,不管结局如何。

GSM0408RR部分阅读的选取部分
Two service access points are defined on signalling layer 2 which are discriminated by their Service
Access Point Identifiers (SAPI) (see GSM 04.06):
i) SAPI 0: supports the transfer of signalling information including user-user information;
ii) SAPI 3: supports the transfer of user short messages.

The general purpose of Radio Resource procedures is to establish, maintain and release RR connections
that allow a point-to-point dialogue between the network and a mobile station. This includes the cell
selection/reselection and the handover procedures. Moreover, Radio Resource management procedures
include the reception of the uni-directional BCCH and CCCH when no RR connection is established. This
permits automatic cell selection/reselection.
A RR connection is a physical connection used by the two peer entities to support the upper layers’
exchange of information flows.

In idle mode no RR connection exists.
In Idle mode, upper layers can require the establishment of an RR connection

In dedicated mode, the RR connection is a physical point-to-point bi-directional connection, and includes a
SAPI 0 data link connection operating in multiframe mode on the main DCCH. If dedicated mode is
established, RR procedures provide the following services:
- establishment/release of multiframe mode on data link layer connections other than SAPI 0, on the
main DCCH or on the SACCH associated with the channel carrying the main signalling link;
- transfer of messages on any data link layer connection;
- indication of temporary unavailability of transmission (suspension, resuming);
- indication of loss of RR connection;
- automatic cell reselection and handover to maintain the RR connection;
Page 34
Draft prETS 300 940 (GSM 04.08 Part A version 5.7.0): October 1997
- setting/change of the transmission mode on the physical channels, including change of type of
channel, change of the coding/decoding/transcoding mode and setting of ciphering;
- allocation/release of an additional channel (for the TCH/H + TCH/H configuration);
- allocation/release of additional channels for multislot operation;
- release of an RR connection.

In case a change of dedicated channels is required using a dedicated assignment and handover
procedure, respectively, the RR sublayer will request the data link layer to suspend multiple frame
operation before the mobile station leaves the old channel. When the channel change has been
completed, layer 3 will request the data link layer to resume multiple frame operation again.

For SAPIs other than 0, the data link procedures described in GSM 04.06 do not provide any guarantee
against message loss or duplication.

Tagged with: , .
Avatar

GLOBAL const void mm_rr_activate_cnf (T_RR_ACTIVATE_CNF *rr_activate_cnf)

{

mm_data->rf_power = rr_activate_cnf->power;

mm_data->reg.new_cell_ind = TRUE;

//如果mnc和mcc是请求的则复制plmn。

if (reg_plmn_equal_eqv (&rr_activate_cnf->plmn, &mm_data->reg.actual_plmn))

{

mm_data->reg.actual_plmn = rr_activate_cnf->plmn; /* Struct copy */

}

//此时MM的状态如果是MM_WAIT_FOR_RR_ACTIVE,同时(mm_data->reg.op.func EQ rr_activate_cnf->op.func)

//rr_activate_cnf->op.service中返回了当前的service类型是LIMITED_SERVICE或FULL_SERVICE。

//当时FULL_SERVICE时会进行如下的操作。

//将mm_info,lai,lac,cid,gprs_indication赋值到MM对应的变量中。

mm_copy_rr_act_cnf_data (rr_activate_cnf);

//此时会判断需不需要location updating,判读函数如下

mm_normal_upd_needed()

if (mm_data->reg.update_stat EQ MS_UPDATED AND

mm_check_lai (&mm_data->reg.lai, &mm_data->mm.lai))

return FALSE;

return TRUE;

mm_attach_upd_needed()

if (mm_data->mm.mm_info.att EQ ATT_ALLOW AND mm_data->first_attach) 

return TRUE;

return FALSE;

mm_periodic_upd_needed (void)

if (mm_data->t3212_timeout AND mm_data->mm.mm_info.t3212 NEQ 0)

return TRUE;

return FALSE;

当不需要location updating时

{

TIMERSTOP (T3213);

mm_data->t3213_restart = 0;

mm_change_t3212();

//然后向GMM发送MMGMM_REG_CNF原语

reg_mm_success (FULL_SERVICE);

//向SIM发送 SIM_MM_UPDATE_REQ 原语 其中主要需要更新的有loc_info,bcch_info,forb_plmns,kc。

reg_build_sim_update (); /* Update cell id */

//同时如果不是gsm only此时还要向GMM发送MMGMM_ACTIVATE_IND。传递的参数有plmn,lac,cid,status, gprs_indicator,同时3212timer时间如下设置

if (mm_data->t3212_cfg_counter NEQ 0 AND 

mm_data->mm.mm_info.t3212 NEQ 0)

mmgmm_activate_ind->t3212_val = mm_data->t3212_cfg_counter * 10000;

else

mmgmm_activate_ind->t3212_val = mm_data->mm.mm_info.t3212 * 360000;

mm_mmgmm_activate_ind (MMGMM_FULL_SERVICE);

/* Back to MM_IDLE_NORMAL_SERVICE */

mm_data->idle_entry = RRCS_INT_NOT_PRESENT;

/* Remember MM doesn't need any IMSI ATTACH anymore */

if (mm_lup_allowed_by_gmm() AND mm_data->first_attach )

{

mm_data->first_attach_mem = mm_data->first_attach;

mm_data->first_attach = FALSE;

}

mm_data->t3212_timeout = FALSE;

mm_data->loc_upd_type.lut = NOT_RUNNING;

SET_STATE (STATE_MM, MM_IDLE_NORMAL_SERVICE);

/* Check HPLMN timer state */

reg_check_hplmn_tim (mm_data->reg.thplmn);

USE_STORED_ENTRIES();

//当需要location updating时进行如下操作。

reg_mm_cell_selected ();//gsm only情况下

mm_data->attempt_cnt = 0;

//然后判断mm_normal_upd_needed()还是mm_attach_upd_needed()还是其他

if (mm_normal_upd_needed())

{

/*

* If updating is allowed by GMM, start procedure,

* otherwise enter state MM_IDLE_LUP_NEEDED.

*/

mm_normal_loc_upd ();

//如果GMM允许location update,此时会向RR发送RR_ESTABLISH_REQ原语,当然此时需要一个RR的连接。

mm_rr_est_req (ESTCS_SERV_REQ_BY_MM, NO_CM_SERVICE, 0);

TIMERSTOP (T3211);

TIMERSTOP (T3213);

mm_data->t3213_restart = 0;

SET_STATE (STATE_MM, MM_WAIT_FOR_RR_CONN_LUP);

}

else if (mm_attach_upd_needed())

{

/*

* If updating is allowed by GMM, start procedure,

* otherwise enter state MM_IDLE_LUP_NEEDED.

*/

mm_attach_loc_upd ();

//此时同mm_normal_upd_needed一样,只是mm_start_loc_upd的参数由NORMAL_LUP变为了IMSI_ATTACH_LUP,依然是发送RR_ESTABLISH_REQ原语

}

//除了mm_normal_upd_needed和mm_attach_upd_needed其他情况mm_start_loc_upd的参数变为了PERIODIC_LUP。

//最后也会进行如下调用

mm_mmgmm_activate_ind (MMGMM_WAIT_FOR_UPDATE);

}

总的从代码中看来,当MM接收到从RR传送过来的RR_ACTIVATE_CNF原语后,MM会存储RR传过来的一些诸如plmn,lac,mm_info等信息,同时会通知SIM更新plmn,bcch,kc等等信息,如果此时不需要location update,MM会向GMM发送MMGMM_ACTIVATE_IND,此时是MMGMM_FULL_SERVICE。当需要location update时,根据update的类型,向RR发送RR_ESTABLISH_REQ原语。

MM接收到该原语后会根据自己当前的状态进行状态的更新,MM_IDLE_NORMAL_SERVICE或MMGMM_WAIT_FOR_UPDATE,或者没有sim或sim无效的MM_IDLE_LIMITED_SERVICE,MM_IDLE_NO_IMSI。

Tagged with: , .
Avatar

Registration

因为TI的代码中是定义了GPRS的,当有GMM模块时,网络的注册是和单纯只有MM模块是不一样的,我们先只看当没有GMM时,MM是如何进行网络注册的。

MMI最后会调用GLOBAL SHORT psaMM_Registrate ( void )来进行网络注册。


GLOBAL SHORT psaMM_Registrate ( void )

{

psaMM_SetRegMode ( MODE_AUTO );

PALLOC (mmr_reg_req, MMR_REG_REQ);

//根据sim的状态来决定当前的网络服务。

if (simShrdPrm.imei_blocked EQ TRUE)

{

mmr_reg_req->service_mode = SERVICE_MODE_LIMITED;

}

else

{

mmr_reg_req->service_mode = SERVICE_MODE_FULL;

}

//以下代码实现了向MM发送了一个MMR_REG_REQ原语。

PSENDX (MM, mmr_reg_req);

}

frstFlg = FALSE;

return 0;

}

MMR_REG_REQ原语在MM的处理函数是reg_mmr_reg_req。这个函数中只有一个调用

mm_func_mmgmm_reg_req (mmr_reg_req->service_mode, 

REG_GPRS_INACTIVE,

MMGMM_CLASS_CC);

因为我们跟踪的代码是GSM only,所以现在的网络类型是MMGMM_CLASS_CC即GSM only

网络的类型定义如下:


#define VAL_MOBILE_CLASS___DEF (0x0) /* Combined GPRS attach */

#define MMGMM_CLASS_A (0x1) /* Combined GPRS */

#define MMGMM_CLASS_B (0x2) /* GPRS and GSM */

#define MMGMM_CLASS_BC (0x3) /* Combined GPRS if possible, otherwise GSM only */

#define MMGMM_CLASS_BG (0x4) /* Combined GPRS if possible, otherwise GPRS only */

#define MMGMM_CLASS_CC (0x5) /* GSM-only */

#define MMGMM_CLASS_CG (0x6) /* GPRS-only */

mm_func_mmgmm_reg_req函数中如果是GSM only则会调用 mm_reg_gsm_only_req (service_mode); Read the rest of this post »

Tagged with: , .
Avatar

Mobility Management Services
The services offered by mobility management are described in the following:

Registration
After power-on or SIM insertion the mobile station searches for a cell and tries to register on it. Selecting
a network is the sense of the registration procedure.

Normal Location Updating
If the mobile station is not registered by the network or changes a location area a normal location updating
is processed. That means the registration by the network is updated.

Periodic Location Updating
If the network uses periodic location updating this procedure is used by the mobile station to update its
registration by the network in periodic times.

IMSI Attach
If indicated by the network the mobile station updates its registration after initial cell selection althought
the SIM card shows the updated state.

IMSI Detach
If indicated by the network the mobile station de-registers itself during SIM removing or power-off.

TMSI Reallocation
The TMSI Reallocation procedure is used by the network to assign a new or changed temporary subscriber
identity to the mobile station.

Authentication
The authentication procedure is used to calculate and compare the authentication parameter.
Identification
The base station uses the identication procedure to request the various identifications from a mobile
station.

MM-Connection Management
MM handles the various connections from call control, supplementary services and short message
services.

Net Request
The net request procedure requests all available networks and presents it to the man machine interface.

Tagged with: .
Avatar

如图,MM各个状态的转换和条件。

Tagged with: .
Avatar

(1)当内核完成它自己内部由一些目标依赖部分组成的启动程序后,它将调用Application_Initialize()函数,这是实体进入内核所有应用程序的入口点。

(2)调用在Application_Initialize()函数中StartFrame()函数。这是实体对于框架来说的主要的进入点。StartFrame()主要负责内存池的创建,任务中实体任务的创建,启动作为当前应用程序一部分的任务。

(3)用于进行通信的分区内存池通过os_CreateParti tionPool()的调用而被创建。不同分区的大小和数目用户可以通过修改配置文件xxxconst.h来进行控制。

(4)如同任务的堆栈的内存分配一样,队列内存的分配是通过os_CreateMemoryPool()而得到的,它的大小也可以通过调整xxxconst.h而进行改变。

(5)在xxxcomp.c中有一张包含了所有在应用程序中的实体的pei_create()函数地址的表。实体可能以一个单独的任务运行也可能是共享一个任务。框架调用每一个pei_create函数并根据该函数的参数而创建一个实体。

(6)调用os_CreateTask()而创建一个任务。

(7)当所有任务都被创建后,框架像创建他们一样也使用相同的启动命令来启动他们。在进一步的初始化(如L1层和他的驱动)后,Application_Initialize()将会返回,内核中的调度将会被激活。

(8)任务根据他们的优先级不同而依次被调度。对于所有的任务来说,这里只有一个任务实体的函数。每个任务它都只被调用一次。每个任务都有它自己的堆栈空间和处理由所有框架函数通过pf_TaskEntry()发出的请求。

(9)在任务中每个实体函数消息队列通过os_CreateQueue()的调用而被创建。队列中实体的数量是通过pei_create()中输出的结构体而得知。

(10)pei_init()被调用。它的函数地址也是通过pei_create()中输出的结构体而得知。

(11)在pei_init()中当前被调度的实体同其他实体进行通信的通信通道被打开。这是通过调用vsi_c_open()来完成的。打开一个通信通道意味着向框架请求得到队列中的那些实体的句柄。如果一个实体的句柄因为相应的任务没有被调度而不能被请求,这时pei_init()将会返回一个错误信息,当前活动的任务将会被阻塞100ms以使内核能够调度比当前任务优先权低的任务。然后pei_init()将再次被调用。当所有被请求的句柄都被得到后,一个内部的数据库将通过pei_init()而被初始化。.

(12)如果与一个任务进行通信的所有的任务并没有都被调度,那么该任务可能被阻塞。

(13)如果一个任务在一个活动的主体中运行,pei_run将被调用。实体的主要循环也包含在pei_run()中。

(14)对于运行在被动活动主体中的任务其主要的循环已经进入了。任务将会进入os_ReceiveFromQueue()同时被阻塞直到它的消息队列接收到一个消息为止。

Tagged with: , .
Avatar

协议栈原语(primitive)与消息(message)的区别如下:

原语是上下层协议栈实体用来交换信息的,而消息是对等实体之间交换信息的。

如设备端mm与rr之间是原语,而设备与网络端rr之间则是消息。

Tagged with: .