Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trace2strap script

Status
Not open for further replies.

PCLOP

Technical User
Nov 11, 2004
62
NO
hi
Trace2strap script
- Used to convert ISDN traces from MX-One prinout format to MD format to be able to
decode them with the STI tool
- Syntax: perl trace2strap.pl Filename1 > Filename2

Anybody know where to find this script?

PCLOP
 
[tt]
#! /usr/bin/perl -w

# by ebctoma. December 2005 Rev 1.13

# Changes:
#
# 1.13 Removing error-messages caused by queued-messages
# (original messages still displayed)
# Also changed so that messages that has the format
# aaa::bbb::cc (or aaa:bbb::ccc::ddd etc) shows the
# last part of the signal-name.
#
# 1.12 The signal-data counter are now in decimal not in hex.
#
# 1.11 Changes made to accomodate CF-LIM in LIM-receiver, new
# to MX-II.
#
# 1.10 By request we now show the last-part of a signal that
# has the format aaaa::bbb, for instance h323StackAPI::IPLTRADAT
# becomes plain old IPLTRADAT.
#
# 1.9 Due to debug-output from the ip-stack certain messages
# would be corrupted/missed, should be fixed now.
#
# 1.8 Modified output to handle MECS2.0 trace-printouts
# signals from HW are different, also fixes the printout
# of those signals. Truncates long signal-names to 15 chars
#
# 1.7 Added dummy send and stack address bytes at the end
# of each signal, STI & OMISDN didn't like it otherwise
#
# 1.6 Ooops! Only handled 1000 signals and then screwed up.
# Relied on a space between 2 fields which isn't 100% true
#
# 1.5 Some signals aren't printed with the "standard"???
# @(#)(MDL) prefix...most notably timer-signals. Fixed now.
#
# 1.4 Unforgivable error on my part, the last signal wasn't
# printed :-(
#
# 1.3 Changes has been made in the trace-output format and
# the regex-expressions has been updated to reflect that
#
# 1.2 The output of the signal-data head wasn't lined up
# properly at all times. (Used wrong variable to determine
# filler-length at 2 occasions).
#
# 1.1 Outgoing HW-signals seems to have the signal-nbr stored
# as the first byte in the signal-data in a mecs-trace.
# That should now be fixed.
#
# 1.0 Born 2002-??-??
#

use strict;

my %signal = ();

while(<>) {
if (/^(?:(?:>>\sEnter)|(?:<<\sSending))\s+:\s*(\d+),\s+(?:\d{4}-\d{2}-\d{2})\s(\d{2}:\d{2}:\d{2}\.\d+)/) {
&print_signal(%signal) if (exists $signal{'sigtype'} and exists $signal{'timestamp'});
%signal = ();
$signal{'linenr'} = '0' x (5-length($1)) . $1;
$signal{'timestamp'} = $2;
$signal{'timestamp'} =~ s/:/\./g;
}
elsif (/^\s+Message\stype\s\dx[0-9a-f]{2}=\d{3}\s(\S+)/) {
if ($1 =~ /^COMBINED/) {
$signal{'sigtype'} = 'SWSW';
}
else {
$signal{'sigtype'} = $1;
$signal{'sigtype'} =~ s/_//;
}
}
elsif (/^\s+From\s\dx([0-9a-f]{4})=\d{5}\s+(\S+)\s+LIM\s\dx[0-9a-f]{2}=(\d{3})\slevel\s\dx[0-9a-f]{2}=\d{3}\s(\S+)/) {
$signal{'fromunitnr'} = $1;
$signal{'fromunitname'} = $2;
$signal{'fromlimnr'} = $3;
$signal{'fromlevel'} = $4;
}
elsif (/^\s+To\s+\dx([0-9a-f]{4})=\d{5}\s+(\S+)\s+LIM\s\dx[0-9a-f]{2}=(\d{3})\slevel\s\dx[0-9a-f]{2}=\d{3}\s(\S+)/) {
$signal{'tounitnr'} = $1;
$signal{'tounitname'} = $2;
$signal{'tolimnr'} = $3;
$signal{'tolevel'} = $4;
}
elsif (/^\s+To\s+\dx([0-9a-f]{4})=\d{5}\s+(\S+)\s+LIM\s\dx[0-9a-f]{2}=CF\s+level\s\dx[0-9a-f]{2}=\d{3}\s(\S+)/) {
$signal{'tounitnr'} = $1;
$signal{'tounitname'} = $2;
$signal{'tolimnr'} = 000; # Make LIM = 0 common-function LIM
$signal{'tolevel'} = $3;
}
elsif (/^\s+Trace:\dx[0-9a-f]{2},\dx[0-9a-f]{2},\d\s+Hardware\saddress:\dx([0-9a-f]{4})=\d{5}\s+=\s+(\d+-[0-9a-f]{1,2}-\d{2}-\d+)/) {
$signal{'multno'} = $1;
$signal{'equnr'} = $2;
}
elsif (/^\s+Message\s\dx([0-9a-f]{4})=\d{5}\s@\(\#\)\(MDL\)\s(\S+)/) {
$signal{'signalnr'} = $1;
$signal{'signalname'} = $2;
}
elsif (/^\s+Message\s\dx([0-9a-f]{4})=\d{5}\s(\S+)/) {
$signal{'signalnr'} = $1;
$signal{'signalname'} = $2;
}
# elsif (/^\s+\dx[0-9a-f]{3}:\s+(.*)/) {
elsif (/^\s+\d+:\s+(.*)/) {
my @data = split /\s+/, substr($1, 0, 50);
if (defined $signal{'data'}) {
push @{$signal{'data'}}, @data;
}
else {
if (exists $signal{'sigtype'} and $signal{'sigtype'} eq 'SWHW') {
$signal{'signalnr'} = '00' . shift @data;
}
$signal{'data'} = \@data;
}
}
elsif (/^\s+LinkValue:0x[0-9a-f]+=\d+/) {
; # skip this
}
elsif (/^\s+Trace:0x[0-9a-f]+,0x[0-9a-f]+,\d+/) {
; # skip this
}
else {
&print_signal(%signal) if (exists $signal{'sigtype'} and exists $signal{'timestamp'});
%signal = ();
}
}

&print_signal(%signal) if (exists $signal{'sigtype'} and exists $signal{'timestamp'}); # don't forget that all important last signal...

sub print_signal($) {
my %signal = @_;

print substr($signal{'timestamp'}, 0, 12), " ";
print $signal{'linenr'}, " ", $signal{'sigtype'}, " SIGNAL ";
if ($signal{'signalname'} =~ /^[^:]*::(.*)/) {
$signal{'signalname'} = $1;
}
while ($signal{'signalname'} =~ /^[^:]*::(.*)/) {
$signal{'signalname'} = $1;
}
#if ($signal{'signalname'} =~ /^[^:]*::(.*)/) {
# $signal{'signalname'} = $1;
#}
if (length($signal{'signalname'}) > 15) {
$signal{'signalname'} = substr($signal{'signalname'},0,15);
}
print $signal{'signalname'}, " " x (18 - length($signal{'signalname'}));
print "(H'", uc($signal{'signalnr'}), ")\n";

if ($signal{'sigtype'} =~ /^SW/) {
print " FROM ";
print $signal{'fromunitname'}, " " x (8 - length($signal{'fromunitname'})), "(H'";
print uc($signal{'fromunitnr'}), ") EXE ";
print $signal{'fromlevel'}, " IN LIM ", $signal{'fromlimnr'}, "\n";
}
elsif ($signal{'sigtype'} =~ /^HW/) {
if (substr($signal{'equnr'}, 2, 2) eq 'ff') {
print " FROM MULTNO H'";
print uc($signal{'multno'}), "\n";
}
else{
print " FROM EQU NO ";
print " " x (3 - length(int($signal{'tolimnr'})));
print $signal{'equnr'}, "\n";
}
}
if ($signal{'sigtype'} =~ /SW$/) {
print " TO ", $signal{'tounitname'};
print " " x (8 - length($signal{'tounitname'})), "(H'";
print uc($signal{'tounitnr'}), ") EXE ", $signal{'tolevel'};
print " IN LIM ", $signal{'tolimnr'}, "\n";
}
elsif ($signal{'sigtype'} =~ /HW$/) {
if (substr($signal{'equnr'}, 2, 2) eq 'ff') {
print " TO MULTNO H'";
print uc($signal{'multno'}), "\n";
}
else {
print " TO EQU NO ";
print " " x (3 - length(int($signal{'fromlimnr'})));
print $signal{'equnr'}, "\n";
}
}
print " WITH 0 1 2 3 4 5 6 7 8 9";
my $dataline = 0;
my @data = ('02', '00', '00', '00', '02', '00', '00', '00');
push @{$signal{'data'}}, @data;
foreach (@{$signal{'data'}}) {
unless ($dataline % 10) {
print "\n ";
print "0" x (3 - length($dataline)), $dataline, " ";
}
print " H'", uc($_);
$dataline++;
}
print "\n";

}
__END__
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top