C D S UeLog 处理RNTI,ENBID,CELLID的方法_enb id如何获取-程序员宅基地

技术标签: Perl 沙漠之舟  

思路根据目前的导出log格式,进行补充 3个信息

 

 

#!perl -w
use strict;
use Data::Dumper;
use File::Basename;

my $BinPath =  (map{s#\n##g;$_} `cd`)[0];
$BinPath .= "\\";
my $OutPutDir = $BinPath."..\\result\\";
my $InFileHandle;
my $OutFileHandle;
my %ColName2Index;
my @SignalingArray;
my @SCELL_CArray;
my @RNTI_CArray;
my @IndexArray;
my @TimeArray;		
my @SignalingDataArray;
my @UETimeStampArray;
my $FileLineNum = 0;
#####################################
my $SignalingName = "Signaling";
my $RNTI_CName = "RNTI_C";	
my $SCELL_CName ="SCell ID";
my $IndexName ="Index";
my $TimeName ="Time";
my $SignalingDataName = "Signaling Data"; 
my $UETimeStampName = "UE Timestamp";
#####################################
&main();

sub main()
{
	&ProcessADir();
}

sub ProcessADir(){
	my @AllFiles = <..\\data\\*>;
	my @AProcessFiles = grep {m/csv$/ && !m$~$} @AllFiles;
	my $AFile;
	foreach $AFile (@AProcessFiles)
	{
		print "\nProcess $AFile \n";
		&ProcessAFile($BinPath."\\".$AFile);
	}
}

sub ProcessAFile(){
	my $InFilePath = shift @_;
	open($InFileHandle,"<",$InFilePath) or die "can't open file $InFilePath for $!\n";
	my $FirstLine = <$InFileHandle>;
	$FirstLine =~ s#\r##g;
	$FirstLine =~ s#\n##g;	
	%ColName2Index = () ;
	@SignalingArray = ();
	@SCELL_CArray =();
	@RNTI_CArray = ();
	@IndexArray = ();
	@TimeArray = ();		
	@SignalingDataArray = ();
	@UETimeStampArray = ();
	
	&GetColumnName($FirstLine);
#	print Dumper %ColName2Index;
	my $Line;
	my $SignalingIndex = $ColName2Index{$SignalingName};
	my $RNTI_CIndex = $ColName2Index{$RNTI_CName};	
	my $SCELL_CIndex = $ColName2Index{$SCELL_CName};
	my $IndexIndex = $ColName2Index{$IndexName};
	my $TimeIndex = $ColName2Index{$TimeName};	
	my $SignalingDataIndex = $ColName2Index{$SignalingDataName};
	my $UETimeStampNameIndex = $ColName2Index{$UETimeStampName};	
 
	#print "ColIndex : $IndexIndex,$TimeIndex,$SignalingDataIndex,$SignalingIndex,$RNTI_CIndex,$SCELL_CIndex \n";
 
	unless (defined ($SignalingIndex) && defined($RNTI_CIndex) && defined($SCELL_CIndex) &&
		defined ($IndexIndex) && defined($TimeIndex) && defined($SignalingDataIndex && defined($UETimeStampNameIndex))
		){
		die "cant 't find $SignalingName,$RNTI_CName,$SCELL_CName,$IndexName,$TimeName,$SignalingDataName.\n";
	}
	my $Signaling; my $RNTI_C; my $SCELL_C;my $UETimeStamp; my $Time;my $SignalingData;
	while(defined($Line = <$InFileHandle>)){
	
		$Line =~ s#\r##g;
		$Line =~ s#\n##g;	
		
		if ($Line =~ /log$/){
			next;
		}			
		unless (defined($Line) and $Line ne ""){
			next;
		}
		#print "$Line \n";
		my @AllDataCols = split /,/,$Line;
		
		($UETimeStamp,$Time,$SignalingData,$Signaling,$RNTI_C,$SCELL_C) = 
			@AllDataCols[$UETimeStampNameIndex ,$TimeIndex,$SignalingDataIndex,$SignalingIndex,$RNTI_CIndex,$SCELL_CIndex];
		

		
		$RNTI_C = ""  unless defined($RNTI_C);
		$SCELL_C = ""  unless defined($SCELL_C);		
		#print "$Signaling,$RNTI_C,$SCELL_C \n";
		
		push @SignalingArray,$Signaling;
		push @RNTI_CArray,$RNTI_C;		
		push @SCELL_CArray,$SCELL_C;	
		push @UETimeStampArray,$UETimeStamp;
		push @TimeArray,$Time;		
		push @SignalingDataArray,$SignalingData;			
		
	}
	$FileLineNum = scalar (@SignalingArray);
	print "File Line : $FileLineNum\n";
	&ProcessRNTI();
	&ProcessSCellID();	
	&OutPutFile($InFilePath);

}

sub OutPutFile(){
	my $OutFilePath = shift @_;
	$OutFilePath = $OutPutDir.basename($OutFilePath);
	#$OutFilePath =~ s#csv#txt#;
	open($OutFileHandle,">",$OutFilePath) or die "can't open file $OutFilePath for $!\n";
	my $IndexScan = 0;
	print $OutFileHandle  "Time1,Time2,MsgName,EnbId,CellId,Rnti,SignalingData\n";
	while($IndexScan < $FileLineNum) {

		print $OutFileHandle "2014-02-27 $TimeArray[$IndexScan],";	
		print $OutFileHandle "$UETimeStampArray[$IndexScan],";
		print $OutFileHandle "$SignalingArray[$IndexScan],";
		
		my $SCellValue = $SCELL_CArray[$IndexScan]; my $ENID="";my $CellID="";
	#	print "SCellValue : $SCellValue\n";
		if (defined($SCellValue) and  $SCellValue ne ""){
			if($SCellValue =~ /\((\d+)-(\d+)\)/){
			$ENID = $1;
			$CellID = $2;
			}
		}
		print $OutFileHandle "$ENID,";
		print $OutFileHandle "$CellID,";	
		my $RntiValue = $RNTI_CArray[$IndexScan];
		$RntiValue = hex($RntiValue);
		print $OutFileHandle "$RntiValue,";
		my $SSignalingData = $SignalingDataArray[$IndexScan];
		#$SSignalingData  =~ s#\s+##g;
		print $OutFileHandle "$SSignalingData";		
		print $OutFileHandle  "\n";
		$IndexScan++;
	}
}
 

sub ProcessSCellIDMessageAnalysis(){
	my ($BeginNO,$EndNO) = @_;
	my $BeginSCELLIDValue = $SCELL_CArray[$BeginNO];
	my $EndSCELLIDValue = $SCELL_CArray[$EndNO];	
	my  $Index = $BeginNO+1;
	my $LastIndex = $EndNO+2;
	if ($LastIndex >= $FileLineNum){
		$LastIndex = $FileLineNum;
	}
	my $ARangeMessageName = join ",",  (@SignalingArray)[$Index..$LastIndex];
#	print "RangeMessage: $ARangeMessageName \n";
	my $SingalName = $SignalingArray[$Index];
	if ( $ARangeMessageName =~ /RRCConnectionRequest/  || 
			 $ARangeMessageName =~ /RRCConnectionRelease/ ||
			 $ARangeMessageName =~ /RRCConnectionReestablishmentRequest/ ||
			 $ARangeMessageName =~ /RRCConnectionReestablishment/)
	{
		return;
	}
	if ( $ARangeMessageName =~ /(.*)RRCConnectionReconfigurationComplete,MasterInformationBlock/){
#		print "compare before value: $1 \n";
		my $BeforeMessageJoinInfo = $1;
		if ($BeforeMessageJoinInfo =~ /(.*)RRCConnectionReconfigurationComplete,MasterInformationBlock/){
			return;
		}
		my @BeforeMessageNames = split /,/,$1;
		my $FillBeginCount = scalar(@BeforeMessageNames);
	#	print "$FillBeginCount \n";
		my  $SmallIndex = $BeginNO+1;
		while ($SmallIndex<=$BeginNO+$FillBeginCount){
			$SCELL_CArray[$SmallIndex] = $BeginSCELLIDValue;
			$SmallIndex++;
		}
		while ($SmallIndex<$EndNO){
			$SCELL_CArray[$SmallIndex] = $EndSCELLIDValue;
			$SmallIndex++;
		}		
		
	}
	else{
		return;
	}
}
sub ProcessSCellRange(){
	my ($BeginNO,$EndNO) = @_;
	my $BeginSCELLIDValue = $SCELL_CArray[$BeginNO];
	my $EndSCELLIDValue = $SCELL_CArray[$EndNO];
	if ($BeginSCELLIDValue  eq  $EndSCELLIDValue){
		my  $Index = $BeginNO+1;
		while ($Index<$EndNO){
			$SCELL_CArray[$Index] = $BeginSCELLIDValue;
			$Index++;
		}
	}
	else{
		&ProcessSCellIDMessageAnalysis($BeginNO,$EndNO);
	}
}
sub ProcessSCellID()
{
	my $BeginNO = -1;
	my $CurSCellID = "";
	my $CurNO = 0;
	foreach $CurSCellID (@SCELL_CArray){
		if ($CurSCellID eq "" || $CurSCellID eq "0"){
			 
		}else{
			 #处理之上为空的
			unless ($BeginNO ==-1 || $BeginNO==($CurNO-1)){
	#			print "will process $BeginNO,$CurNO \n";
				&ProcessSCellRange($BeginNO,$CurNO);	
			}
			$BeginNO = $CurNO;
		}
		$CurNO++;
	}
#	print "SCellID:\n";
#	print Dumper @SCELL_CArray;
}

sub ProcessMessageAnalysis(){
	my ($BeginNO,$EndNO) = @_;
	my $BeginRNTIValue = $RNTI_CArray[$BeginNO];
	my $EndRNTIValue = $RNTI_CArray[$EndNO];
	my  $Index = $BeginNO+1;
	my $LastIndex = $EndNO+2;
	if ($LastIndex >= $FileLineNum){
		$LastIndex = $FileLineNum;
	}
	my $ARangeMessageName = join ",",  (@SignalingArray)[$Index..$LastIndex];
#	print "RangeMessage: $ARangeMessageName \n";
	my $SingalName = $SignalingArray[$Index];
	if ( $ARangeMessageName =~ /RRCConnectionRequest/  || 
			 $ARangeMessageName =~ /RRCConnectionRelease/ ||
			 $ARangeMessageName =~ /RRCConnectionReestablishmentRequest/ ||
			 $ARangeMessageName =~ /RRCConnectionReestablishment/)
	{
		return;
	}
	if ( $ARangeMessageName =~ /(.*)RRCConnectionReconfigurationComplete,MasterInformationBlock/){
	#	print "compare before value: $1 \n";
		my @BeforeMessageNames = split /,/,$1;
		my $FillBeginCount = scalar(@BeforeMessageNames);
	#	print "$FillBeginCount \n";
		my  $SmallIndex = $BeginNO+1;
		while ($SmallIndex<=$BeginNO+$FillBeginCount){
			$RNTI_CArray[$SmallIndex] = $BeginRNTIValue;
			$SmallIndex++;
		}
		while ($SmallIndex<$EndNO){
			$RNTI_CArray[$SmallIndex] = $EndRNTIValue;
			$SmallIndex++;
		}		
		
	}
	else{
		return;
	}
}
sub ProcessRNTIRange(){
	my ($BeginNO,$EndNO) = @_;
	my $BeginRNTIValue = $RNTI_CArray[$BeginNO];
	my $EndRNTIValue = $RNTI_CArray[$EndNO];
	if ($BeginRNTIValue  eq  $EndRNTIValue){
		my  $Index = $BeginNO+1;
		while ($Index<$EndNO){
			$RNTI_CArray[$Index] = $BeginRNTIValue;
			$Index++;
		}
	
	}
	else{
		&ProcessMessageAnalysis($BeginNO,$EndNO);
	}

}
sub ProcessRNTI(){
	my $BeginNO = -1;
	my $CurRNTI = "";
	my $CurNO = 0;
	foreach $CurRNTI (@RNTI_CArray){
		if ($CurRNTI eq "" || $CurRNTI eq "0"){
			 
		}else{
			 #处理之上为空的
			unless ($BeginNO ==-1 || $BeginNO==($CurNO-1)){
			#	print "will process $BeginNO,$CurNO \n";
				&ProcessRNTIRange($BeginNO,$CurNO);	
			}
			$BeginNO = $CurNO;
		}
		$CurNO++;
	}
	#print "CNTI:\n";
	#print Dumper @RNTI_CArray;
}

sub GetColumnName($){
	my $FirstLine = shift @_;
	my @ColumnName = split /,/,$FirstLine;
	my $AColName;
	my $ColIndex = 0;
	foreach $AColName (@ColumnName){
		$ColName2Index{$AColName} = $ColIndex;
		$ColIndex++;
	}
}


 

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/bruce_wang_janet/article/details/20135465

智能推荐

最新!互联网大厂各职级薪资对应关系图(2020年初)-程序员宅基地

文章浏览阅读2.9w次,点赞6次,收藏21次。来源:知乎普拉思驿站首先,还是要说一句,我当然不是猎头,但最近一段时间,我找到了业余生活的一大乐趣,就是在脉脉职言区看大家晒的 offer,然后觉得吧,光看不行,所以就顺手总结了一下,画..._快手职级多少对应p5

页面设置body高度height:100%不生效解决办法_document.body.style.height 不生效-程序员宅基地

文章浏览阅读696次。直接body{ height: 100%; }不生效的话,那就在前面加个html吧,如下:html,body { height: 100% }如果想要知道原理的可以参阅下面这篇文章,写得很好转自:https://blog.csdn.net/javaloveiphone/article/details/51098972..._document.body.style.height 不生效

Vue.js仿饿了么外卖App--(4)商品详情页实现_vue饿了么小程序商品页-程序员宅基地

文章浏览阅读1.7k次,点赞3次,收藏12次。文章目录一、内容介绍1、内容2、效果二、具体实现1、组件传值2、点击事件3、图片展示4、加入购物车5、分隔条组件一、内容介绍1、内容本篇文章主要实现的是商品详情页的展示,主要包括商品图片展示、商品信息展示和商品评价展示2、效果二、具体实现1、组件传值goods.vue <Food :food="selectedFood" ref="food"></Food>food.vue通过props属性接收 props: { food: { type: _vue饿了么小程序商品页

idea 使用JREBEL进行热部署_idea rebel-程序员宅基地

文章浏览阅读510次。IDAE热部署教程1.下载插件下载完之后,重启idea2.激活 这个插件这个插件是收费的,需要婆姐,去这个地址下载下载地址根据自己系统版本下载,我是windows ,下载的这个下载完成之后,打开打开这个页面之后,双击我们刚才下载的那个程序然后在idea 的 框中地方 第一行输入http://127.0.0.1:8888/ac3a4637-7a0d-44bc-8d83-ada70c842c62第二行输入 你的邮箱地址勾选下面的我同意 ,然后点击 change licence_idea rebel

Installation failed, deleting ./composer.json.安装phpunit报错解决方案-程序员宅基地

文章浏览阅读4.4k次。是因为你没有装全局的phpunit,安装命令composer global require phpunit/phpunit之后你输入composer require --dev phpunit/phpunit就发现你安装成功了_installation failed, deleting ./composer.json.

什么是DO / DTO / BO / VO /AO ?_bo/do/dto/vo-程序员宅基地

文章浏览阅读4.9k次,点赞8次,收藏12次。POJO 是 DO / DTO / BO / VO 的统称.DO(Data Object) :此对象与数据库表结构一一对应,通过 DAO 层向上传输数据源对象。DTO(Data Transfer Object) :数据传输对象, Service 或 Manager 向外传输的对象。BO(Business Object) :业务对象,由 Service 层输出的封装业务逻辑的对象。AO (..._bo/do/dto/vo

随便推点

如何用电脑玩石器时代M 石器时代M手游PC电脑版教程_石器时代电脑-程序员宅基地

文章浏览阅读3.8k次。《石器时代M》是一款3D角色扮演手游,以“石器时代”为背景题材,我们将在开放式的大型地图上自由探索,超多的玩法内容,经典的策略回合制战斗,将给我们带来全新的游戏乐趣!接下来,和小编一起看下石器时代M电脑版教程哈!一、石器时代M电脑版教程1、首先呢,我们要做好玩前的准备工作,在电脑上下一个模拟器。因为要想在电脑上玩手游,就必须在电脑上装个模拟器,这个是电脑玩手游的前提条件,模拟器就相当于..._石器时代电脑

java在linux下新建文件夹_setwritable-程序员宅基地

文章浏览阅读1.7w次,点赞5次,收藏11次。java在linux下新建目录需要先获取权限File f=new File("/home/hay");f.setWritable(true, false); //设置写权限,windows下不用此语句f.mkdirs();_setwritable

GPS轨迹数据集免费下载资源整理_大西洋飓风数据下载-程序员宅基地

文章浏览阅读3.8w次,点赞48次,收藏175次。本文主要是整理了GPS轨迹数据集免费资源库,从这些库中能够免费下载到GPS数据,同时还整理出了这些数据的格式,数据集的简单描述等等。如果你发现更好的相关数据资源,欢迎共享 :)1. GeoLife GPS Trajectories该GPS轨迹数据集出自微软研究GeoLift项目。从2007年四月到2012年八月收集了182个用户的轨迹数据。这些数据包含了一系列以时间为序的点,每一个点包含经纬度、海拔_大西洋飓风数据下载

ROS 教程之 vision: 摄像头标定camera calibration_ros教程之vision:攝像頭標定-程序员宅基地

文章浏览阅读5.2w次,点赞24次,收藏266次。在上一个文章中,我们使用usb_cam包读入并发布了图像消息,但是图像没有被标定,因此存在畸变。ROS官方提供了用于单目或者双目标定的camera_calibration包。这个包是使用opencv里的张正友标定法,所以如果你有使用opencv标定的经验,可以直接标定,而不使用官方的程序。 官方也给出了单目的标定教程和双目视觉的标定教程。本教程基于usb_cam package 读取图像,然后使用官方例程进行标定。_ros教程之vision:攝像頭標定

容器中使用iptables报错can't initialize iptables table Permission denied (you must be root)_can't initialize iptables table `nat': permission -程序员宅基地

文章浏览阅读2.8w次,点赞4次,收藏8次。背景  在docker容器中部署了一微服务,该服务需要docker push镜像到docker registry。因此,docker容器中需要安装docker服务。但在启动容器的时候,却报错: can't initialize iptables table `filter': Permission denied (you must be root)Perhaps iptables or your_can't initialize iptables table `nat': permission denied (you must be root)

docker-compose部署 MongoDB + mongo-express可视化界面_express+mongodb可视化-程序员宅基地

文章浏览阅读2.2k次。1. 拉取 Mongo 镜像docker pull mongo:4.1.62. 运行镜像docker run -d --name mongodb --volume /usr/local/mongodata:/data/db -p 27017:27017 mongo:4.1.6 --auth3. 创建root用户进入 mongodocker exec -it mongodb mon..._express+mongodb可视化

推荐文章

热门文章

相关标签