Пример #1
0
        public int ParseTLService(LogicChannel channelData, int offset, ReceivedData result)
        {
            var length      = 4;
            var messageType = TetraUtils.BitsToInt32(channelData.Ptr, offset, length);

            offset += length;
            result.Add(GlobalNames.SDS_TL_MesaggeType, messageType);
            switch (messageType)
            {
            case 0:    //Forward
                offset = Global.ParseParams(channelData, offset, _d_Sds_TL_ForwardRules, result);
                break;

            case 1:    //Report
                offset = Global.ParseParams(channelData, offset, _d_Sds_TL_ReportRules, result);
                break;

            case 2:
            case 3:
                //
                break;
            }

            return(offset);
        }
Пример #2
0
        public void Parse(LogicChannel channelData, int offset, ReceivedData result)
        {
            var protokol = (MLEPduType)TetraUtils.BitsToInt32(channelData.Ptr, offset, 3);

            offset += 3;
            result.Add(GlobalNames.MLE_PDU_Type, (int)protokol);

            //Debug.Write(" " + protokol.ToString());

            switch (protokol)
            {
            case MLEPduType.CMCE:
                ParseCMCEPDU(channelData, offset, result);
                break;

            case MLEPduType.MLE:
                ParseMLEPDU(channelData, offset, result);
                break;

            default:
                //Debug.Write(" Unknow_PDU_Type");
                result.Add(GlobalNames.UnknowData, 1);
                break;
            }
        }
Пример #3
0
        public void MacFraqPDU(LogicChannel channelData, int offset, ReceivedData result)
        {
            var startOffset = offset - 3;

            //Debug.Write(" | Frag_PDU");

            if (FraqmentsBufferIsEmpty(channelData.TimeSlot))
            {
                Debug.Write(" Buffer_is_empty!!!");
                return;
            }

            var fill = (TetraUtils.BitsToInt32(channelData.Ptr, offset, 1) != 0);

            offset++;

            var realLength = channelData.Length - offset;

            if (fill)
            {
                realLength = CalcRealLength(channelData.Ptr, offset, realLength);
            }

            if (realLength < 0)
            {
                result.Add(GlobalNames.UnknowData, 1);
                Debug.Write(" frag_length_err");
                return;
            }

            AddFraqmentsToBuffer(channelData, offset, realLength);
        }
Пример #4
0
        public void AccessAsignPDU(LogicChannel channelData)
        {
            var offset = 0;

            var length = _aachLength[AccessAssign.Header];
            var header = TetraUtils.BitsToInt32(channelData.Ptr, offset, length);

            offset += length;

            length = _aachLength[AccessAssign.Field1];
            var field1 = TetraUtils.BitsToInt32(channelData.Ptr, offset, length);

            offset += length;

            length = _aachLength[AccessAssign.Field2];
            var field2 = TetraUtils.BitsToInt32(channelData.Ptr, offset, length);

            Field1 = field1;
            Field2 = field2;

            if (channelData.Frame == 18)
            {
                DownLinkChannelType = ChannelType.Common;
                return;
            }

            switch (header)
            {
            case 0:
                DownLinkChannelType = ChannelType.Common;
                break;

            case 1:
            case 2:
            case 3:
                switch (field1)
                {
                case 0:
                    DownLinkChannelType = ChannelType.Unalloc;
                    break;

                case 1:
                    DownLinkChannelType = ChannelType.Assigned;
                    break;

                case 2:
                    DownLinkChannelType = ChannelType.Common;
                    break;

                case 3:
                    DownLinkChannelType = ChannelType.Reserved;
                    break;

                default:
                    DownLinkChannelType = ChannelType.Traffic;
                    break;
                }
                break;
            }
        }
Пример #5
0
        public void ParseSDS(LogicChannel channelData, int offset, ReceivedData result)
        {
            var length = 8;
            var type   = (SdsProtocolIdent)TetraUtils.BitsToInt32(channelData.Ptr, offset, length);

            offset += length;
            result.Add(GlobalNames.Protocol_identifier, (int)type);

            Debug.Write(" " + type.ToString());

            if ((int)type > 127)
            {
                offset = ParseTLService(channelData, offset, result);
            }

            switch (type)
            {
            case SdsProtocolIdent.Simple_immediate_text:
            case SdsProtocolIdent.Simple_text_msg:

                offset = Global.ParseParams(channelData, offset, _sds_SimpleTextRules, result);
                ParseTextMessage(channelData, offset, result);
                break;

            case SdsProtocolIdent.Immediate_text_messaging_TL:
            case SdsProtocolIdent.Text_Messaging_TL:
                offset = Global.ParseParams(channelData, offset, _sds_SimpleTextRules, result);
                ParseTextMessage(channelData, offset, result);
                break;

            case SdsProtocolIdent.Location_System_TL:
            case SdsProtocolIdent.Simple_location_system:
                length = 8;
                var locationCodingSheme = TetraUtils.BitsToInt32(channelData.Ptr, offset, length);
                offset += length;
                result.Add(GlobalNames.Location_System_Coding, locationCodingSheme);
                if (locationCodingSheme == 0)
                {
                    result.Add(GlobalNames.Text_coding_scheme, 1);
                    ParseTextMessage(channelData, offset, result);
                }
                else
                {
                    result.Add(GlobalNames.UnknowData, 1);
                }
                break;

            case SdsProtocolIdent.Location_information_protokol:
                ParseLocationInformationProtokol(channelData, offset, result);
                break;

            default:
                offset = Global.ParseParams(channelData, offset, _sds_SimpleTextRules, result);
                ParseTextMessage(channelData, offset, result);
                result.Add(GlobalNames.UnknowData, 1);
                break;
            }
        }
Пример #6
0
        public void UsignalPDU(LogicChannel channelData, int offset, ReceivedData result)
        {
            HalfSlotStolen = (TetraUtils.BitsToInt32(channelData.Ptr, offset, 1) != 0);
            offset++;

            //Debug.Write(" Usig_PDU");

            //Possible pdu encrypted
            //_llc.Parse(channelData, offset, result);
        }
Пример #7
0
        private void ParseMLEPDU(LogicChannel channelData, int offset, ReceivedData result)
        {
            var length = 3;
            var type   = (MlePrimitivesType)TetraUtils.BitsToInt32(channelData.Ptr, offset, length);

            offset += length;
            result.Add(GlobalNames.MLE_Primitives_Type, (int)type);

            //Debug.Write(" " + type.ToString());

            switch (type)
            {
            case MlePrimitivesType.D_NWRK_BROADCAST:
                offset = Global.ParseParams(channelData, offset, _d_Nwrk_BroadcastRules, result);

                var count = 0;

                if (result.TryGetValue(GlobalNames.Number_of_Neighbour_cells_element, ref count))
                {
                    for (int i = 0; i < count; i++)
                    {
                        var neighbourData = new ReceivedData();
                        offset = Global.ParseParams(channelData, offset, _neighbour_Cell_InfoRules, neighbourData);

                        var cellID = 0;
                        if (neighbourData.TryGetValue(GlobalNames.Cell_identifier, ref cellID))
                        {
                            //////Debug.WriteLine("Neighbour " + Thread.CurrentThread.ManagedThreadId.ToString());

                            if (Global.NeighbourList.Count < 32)
                            {
                                Global.NeighbourList.Add(neighbourData);
                            }
                        }
                    }
                }

                break;

            case MlePrimitivesType.D_NEW_CELL:
            case MlePrimitivesType.D_PREPARE:
            case MlePrimitivesType.D_RESTORE_ACK:
            case MlePrimitivesType.D_RESTORE_FAIL:

            default:
                //Debug.Write(" Unknow_MLE_SDU");
                result.Add(GlobalNames.UnknowData, 1);
                break;
            }
        }
Пример #8
0
        public void DmacFraqPDU(LogicChannel channelData, int offset, ReceivedData result)
        {
            var fill = (TetraUtils.BitsToInt32(channelData.Ptr, offset, 1) != 0);

            offset++;

            var realLength = channelData.Length - offset;

            if (fill)
            {
                realLength = CalcRealLength(channelData.Ptr, offset, realLength);
            }

            AddFraqmentsToBuffer(channelData, offset, realLength);

            Debug.Write("Fragment_PDU");
        }
Пример #9
0
        public void DmoParseMacPDU(LogicChannel channelData, List <ReceivedData> result)
        {
            var offset = 0;
            var pdu    = new ReceivedData();

            pdu.Add(GlobalNames.CurrTimeSlot, channelData.TimeSlot);

            var pduType = (MAC_PDU_Type)TetraUtils.BitsToInt32(channelData.Ptr, offset, 2);

            offset += 2;
            pdu.Add(GlobalNames.MAC_PDU_Type, (int)pduType);

            switch (pduType)
            {
            case MAC_PDU_Type.MAC_resource:    //DMAC-DATA
                DmacDataPDU(channelData, offset, pdu);
                break;

            case MAC_PDU_Type.MAC_frag:

                var isTheEnd = TetraUtils.BitsToInt32(channelData.Ptr, offset, 1);
                offset++;

                if (isTheEnd == 0)
                {
                    Debug.Write(" DMAC-Frag_PDU");
                    DmacFraqPDU(channelData, offset, pdu);
                }
                else
                {
                    Debug.Write(" DMAC-End_PDU");
                    DmacEndPDU(channelData, offset, pdu);
                }
                break;

            case MAC_PDU_Type.MAC_U_Signal:
                Debug.Write(" U-signal_DMO_PDU");
                //UsignalPDU(channelData, offset, pdu);
                break;

            case MAC_PDU_Type.Broadcast:    //Not used for dmo
                Debug.Write(" Reserved_DMO_PDU");
                break;
            }
            result.Add(pdu);
        }
Пример #10
0
        public void SyncPDU(LogicChannel channelData, ReceivedData result)
        {
            var length     = 4;
            var offset     = 0;
            var systemCode = TetraUtils.BitsToInt32(channelData.Ptr, offset, length);

            offset += length;

            result.SetValue(GlobalNames.SystemCode, systemCode);

            switch (systemCode)
            {
            case 12:
            case 13:
                length = 2;
                var pduType = TetraUtils.BitsToInt32(channelData.Ptr, offset, length);
                offset += length;
                result.SetValue(GlobalNames.SYNC_PDU_type, pduType);

                switch (pduType)
                {
                case 0:
                    //Dmac-Sync
                    Debug.Write(" DMAC-Sync");
                    offset = Global.ParseParams(channelData, offset, _dmacSyncInfoRulesDMO, result);
                    break;

                case 1:
                    //DPRES-SYNC
                    Debug.Write(" Dpres-Sync");
                    offset = Global.ParseParams(channelData, offset, _dpresSyncInfoRules, result);
                    break;

                default:
                    //Reserved;
                    Debug.Write(" Unknow_DMO_SyncPdu_type");
                    result.SetValue(GlobalNames.UnknowData, 1);
                    break;
                }
                break;

            default:
                Global.ParseParams(channelData, offset, _syncInfoRulesTMO, result);
                break;
            }
        }
Пример #11
0
        private void ParseLocationInformationProtokol(LogicChannel channelData, int offset, ReceivedData result)
        {
            var length  = 2;
            var pduType = TetraUtils.BitsToInt32(channelData.Ptr, offset, length);

            offset += length;
            result.Add(GlobalNames.Location_PDU_type, pduType);

            switch (pduType)
            {
            case 0:    //Short
                Global.ParseParams(channelData, offset, _sds_LocationShortRules, result);
                break;

            case 1:    //Long
                length = 4;
                var pduSubType = (LocationTypeExtension)TetraUtils.BitsToInt32(channelData.Ptr, offset, length);
                offset += length;
                result.Add(GlobalNames.Location_PDU_type_extension, (int)pduSubType);
                switch (pduSubType)
                {
                case LocationTypeExtension.Immediate_location_report:
                    Global.ParseParams(channelData, offset, _sds_ImmediateLocRepRules, result);
                    break;

                case LocationTypeExtension.Long_location_report:
                case LocationTypeExtension.Remove_trigger:
                case LocationTypeExtension.Location_report_acknowledgement:
                case LocationTypeExtension.Add_modify_trigger:
                case LocationTypeExtension.Backlog:
                case LocationTypeExtension.Basic_location_parameters:
                case LocationTypeExtension.Location_reporting_enable_disable:
                case LocationTypeExtension.Location_reporting_temporary_control:
                case LocationTypeExtension.Report_basic_location_parameters:
                case LocationTypeExtension.Report_trigger:
                default:
                    result.Add(GlobalNames.UnknowData, 1);
                    break;
                }
                break;

            default:
                break;
            }
        }
Пример #12
0
        private void ParseCMCEPDU(LogicChannel channelData, int offset, ReceivedData result)
        {
            var length = 5;
            var type   = (CmcePrimitivesType)TetraUtils.BitsToInt32(channelData.Ptr, offset, length);

            offset += length;
            result.Add(GlobalNames.CMCE_Primitives_Type, (int)type);

            //Debug.Write(" " + type.ToString());

            switch (type)
            {
            case CmcePrimitivesType.D_Connect:
                Global.ParseParams(channelData, offset, _d_connectRules, result);
                break;

            case CmcePrimitivesType.D_Setup:
                Global.ParseParams(channelData, offset, _d_setupRules, result);
                break;

            case CmcePrimitivesType.D_TX_Granted:
                Global.ParseParams(channelData, offset, _d_TX_GrantedRules, result);
                break;

            case CmcePrimitivesType.D_TX_Ceased:
                Global.ParseParams(channelData, offset, _d_TX_CeasedRules, result);
                break;

            case CmcePrimitivesType.D_Release:
                Global.ParseParams(channelData, offset, _d_ReleaseRules, result);
                break;

            case CmcePrimitivesType.D_Disconnect:

                break;

            case CmcePrimitivesType.D_Connect_Acknowledgea:

                break;

            case CmcePrimitivesType.D_Info:
                Global.ParseParams(channelData, offset, _d_infoRules, result);
                break;

            case CmcePrimitivesType.D_SDS_Data:
                offset = Global.ParseParams(channelData, offset, _d_SdsDataRules, result);

                if (result.Contains(GlobalNames.User_Defined_Data4_Length))
                {
                    var sdsData = new LogicChannel
                    {
                        Ptr    = channelData.Ptr + offset,
                        Length = result.Value(GlobalNames.User_Defined_Data4_Length),
                    };

                    _sds.ParseSDS(sdsData, 0, result);
                }
                break;

            case CmcePrimitivesType.D_Alert:
            case CmcePrimitivesType.D_Call_Proceeding:
            case CmcePrimitivesType.D_Status:
            case CmcePrimitivesType.D_TX_Continue:
            case CmcePrimitivesType.D_TX_Wait:
            case CmcePrimitivesType.D_TX_Interrupt:
            case CmcePrimitivesType.D_Call_Restore:
            case CmcePrimitivesType.D_Facility:
            case CmcePrimitivesType.Reserved17:
            case CmcePrimitivesType.Reserved18:
            case CmcePrimitivesType.Reserved19:
            case CmcePrimitivesType.Reserved20:
            case CmcePrimitivesType.Reserved21:
            case CmcePrimitivesType.Reserved22:
            case CmcePrimitivesType.Reserved23:
            case CmcePrimitivesType.Reserved24:
            case CmcePrimitivesType.Reserved25:
            case CmcePrimitivesType.Reserved26:
            case CmcePrimitivesType.Reserved27:
            case CmcePrimitivesType.Reserved28:
            case CmcePrimitivesType.Reserved29:
            case CmcePrimitivesType.Reserved30:
            case CmcePrimitivesType.CMCE_Function_Not_Supported:

                //Debug.Write(" Unknow_CMCE_SDU");
                result.Add(GlobalNames.UnknowData, 1);

                break;
            }
        }
Пример #13
0
        public void Parse(LogicChannel channelData, int offset, ReceivedData result)
        {
            var llcType = (LLCPduType)TetraUtils.BitsToInt32(channelData.Ptr, offset, 4);

            offset += 4;
            result.Add(GlobalNames.LLC_Pdu_Type, (int)llcType);

            //Debug.WriteLine(" " + llcType.ToString());

            var fcsIsGood = true;

            switch (llcType)
            {
            case LLCPduType.BL_ADATA:
                offset += 1;     //N(R)
                offset += 1;     //N(S)
                break;

            case LLCPduType.BL_ADATA_FCS:
                offset   += 1;   //N(R)
                offset   += 1;   //N(S)
                fcsIsGood = CalculateFCS(channelData, offset);
                break;

            case LLCPduType.BL_DATA:
                offset += 1;     //N(S)
                break;

            case LLCPduType.BL_DATA_FCS:
                offset   += 1;   //N(S)
                fcsIsGood = CalculateFCS(channelData, offset);
                break;

            case LLCPduType.BL_UDATA:
                //No bits here
                break;

            case LLCPduType.BL_UDATA_FCS:
                //No bits here
                fcsIsGood = CalculateFCS(channelData, offset);
                break;

            case LLCPduType.BL_ACK:
                offset += 1;    //N(R)
                break;

            case LLCPduType.BL_ACK_FCS:
                offset   += 1;  //N(R)
                fcsIsGood = CalculateFCS(channelData, offset);
                break;

            case LLCPduType.AL_SETUP:
            case LLCPduType.AL_DATA_AR_FINAL:
            case LLCPduType.AL_UDATA_UFINAL:
            case LLCPduType.AL_ACK_RNR:
            case LLCPduType.AL_RECONNECT:
            case LLCPduType.Reserved1:
            case LLCPduType.Reserved2:
            case LLCPduType.AL_DISC:
            default:
                Debug.WriteLine(" Unknow_LLC_PDU " + llcType);
                result.Add(GlobalNames.UnknowData, 1);
                return;
            }

            if (fcsIsGood)
            {
                _mle.Parse(channelData, offset, result);
            }
            else
            {
                result.Add(GlobalNames.UnknowData, 1);
            }
        }
Пример #14
0
        public static int ParseParams(LogicChannel channelData, int offset, Rules[] rules, ReceivedData result)
        {
            var skipRules = 0;

            for (int i = 0; i < rules.Length; i++)
            {
                if (offset >= channelData.Length)
                {
                    if (!result.Contains(GlobalNames.OutOfBuffer))
                    {
                        result.SetValue(GlobalNames.OutOfBuffer, 1);
                    }
                    return(offset);
                }

                if (skipRules > 0)
                {
                    skipRules--;
                    continue;
                }

                var param = rules[i];
                var value = TetraUtils.BitsToInt32(channelData.Ptr, offset, param.Length);

                switch (param.Type)
                {
                case RulesType.Direct:
                    if (param.GlobalName != GlobalNames.Reserved)
                    {
                        result.SetValue(param.GlobalName, value);
                    }
                    offset += param.Length;
                    continue;

                case RulesType.Options_bit:
                    offset += param.Length;
                    if (value == 0)
                    {
                        return(offset);
                    }
                    break;

                case RulesType.Presence_bit:
                    if (value == 0)
                    {
                        skipRules = param.Ext1;
                    }
                    offset += param.Length;
                    break;

                case RulesType.More_bit:
                    offset += param.Length;
                    return(offset);

                case RulesType.Switch:
                    if (result.Value((GlobalNames)rules[i].Ext1) == rules[i].Ext2)
                    {
                        if (param.GlobalName != GlobalNames.Reserved)
                        {
                            result.SetValue(param.GlobalName, value);
                        }
                        offset += param.Length;
                    }
                    break;

                case RulesType.SwitchNot:
                    if (result.Value((GlobalNames)rules[i].Ext1) != rules[i].Ext2)
                    {
                        if (param.GlobalName != GlobalNames.Reserved)
                        {
                            result.SetValue(param.GlobalName, value);
                        }
                        offset += param.Length;
                    }
                    break;

                case RulesType.Jamp:
                    if (result.Value((GlobalNames)rules[i].Ext1) == rules[i].Ext2)
                    {
                        skipRules = param.Ext3;
                    }
                    break;

                case RulesType.JampNot:
                    if (result.Value((GlobalNames)rules[i].Ext1) != rules[i].Ext2)
                    {
                        skipRules = param.Ext3;
                    }
                    break;

                case RulesType.Reserved:
                {
                    offset += param.Length;
                }
                break;
                }
            }

            return(offset);
        }
Пример #15
0
        public void TmoParseMacPDU(LogicChannel channelData, List <ReceivedData> result)
        {
            var nullPduLength = 16; // only for receive pi/4 modulation ;
            var blockOffset   = 0;
            var nullPdu       = false;
            var pduEnd        = false;

            for (int i = 0; i < 5; i++)
            {
                var offset = blockOffset;
                var pdu    = new ReceivedData();

                pdu.Add(GlobalNames.CurrTimeSlot, channelData.TimeSlot);

                var resourceType = (MAC_PDU_Type)TetraUtils.BitsToInt32(channelData.Ptr, offset, 2);
                offset += 2;
                pdu.Add(GlobalNames.MAC_PDU_Type, (int)resourceType);

                switch (resourceType)
                {
                case MAC_PDU_Type.Broadcast:
                    blockOffset = SysInfoPDU(channelData, offset, pdu);
                    break;

                case MAC_PDU_Type.MAC_resource:
                    ResourcePDU(channelData, offset, pdu);
                    blockOffset += (pdu.Value(GlobalNames.Length_indication) * 8);
                    break;

                case MAC_PDU_Type.MAC_U_Signal:
                    if (channelData.Length == 124)
                    {
                        UsignalPDU(channelData, offset, pdu);
                        pduEnd = true;
                    }
                    else
                    {
                        Debug.Write(" MAC-D-BLCK_PDU");
                        pduEnd = true;
                    }
                    break;

                case MAC_PDU_Type.MAC_frag:

                    var isTheEnd = TetraUtils.BitsToInt32(channelData.Ptr, offset, 1);
                    offset++;

                    if (isTheEnd == 0)
                    {
                        MacFraqPDU(channelData, offset, pdu);
                        pduEnd = true;
                    }
                    else
                    {
                        MacEndPDU(channelData, offset, pdu);
                        blockOffset += (pdu.Value(GlobalNames.Length_indication) * 8);
                    }
                    break;
                }

                nullPdu = pdu.Contains(GlobalNames.Null_pdu) || pdu.Contains(GlobalNames.OutOfBuffer);

                if (nullPdu)
                {
                    pduEnd = true;
                }

                //if (pdu.ContainsKey(GlobalNames.UnknowData)) nullPdu = true;

                if (!nullPdu)
                {
                    result.Add(pdu);
                }

                if ((blockOffset >= (channelData.Length - nullPduLength)) || pduEnd)
                {
                    break;
                }
            }
        }