I have been working on a distribution for CPAN that handles TL1 messages, as used in many types of telecom equipment.
I am hoping to get some feedback on the design of this distribution including constructive criticism on the quality of the code. I'm particularly interested in whether or not my fellow Monks find this code clear, understandable, and maintainable.
Unfortunately, neither the existing Net::TL1 CPAN module nor the Non-CPAN TL1 module fit my needs, so I've written this in hopes of producing something that will work with a broader set of devices, and perhaps useful to other engineers in my profession.
If anyone wants to try it out, I've also written a simplistic TL1 'simulator' along with a demo that shows how to use this module. Run the simulator in one terminal window and the demo in another.
#!/usr/bin/perl
use IO::Socket;
#$| = 1;
my $sock = new IO::Socket::INET (
LocalHost => '127.0.0.1',
LocalPort => '12345',
Proto => 'tcp',
Listen => 1,
Reuse => 1,
) || die "Could not create socket: $!\n";
print "Socket created, listening for client connection...\n";
my $client = $sock->accept();
$client->autoflush(1);
print "Client connected, sending data...\n\n";
print "\n";
while(<DATA>) {
chomp;
/^$/ ? print $client "$_\n" : print $client "$_\015\012";
while (<DATA>) {
chomp;
if (/^$/) { print $client "$_\n"; last }
print $client "$_\015\012";
}
# select can simulate sleeping for fractions of a second.
my $yfact = int(rand() * 1000)/1000;
my $xfact = int(rand() * 1000)/1000;
my $sleep = int($xfact * $yfact * 100 - 10)/100;
select(undef, undef, undef, abs $sleep);
}
print "All data sent. Quitting.\n\n";
__DATA__
ALBNYN51 2007-07-27 17:33:40
A 4164.4164 REPT EVT T1
"FAC-1-2:T-ESL,TC,,,FEND,,65,65,15-MIN:\"Performance Monitor Thresh
+old Crossing Alert\","
;
LAWMAN01 2007-07-27 17:33:40
A 618.616 REPT ALM T1
"FAC-14-9:CL,AIS,NSA,,,,:\"Alarm Indication Signal\",DS1-14"
;
BOSMAN51 2007-07-27 17:33:40
A 8964.8963 REPT ALM VT1
"VT1-6-1-29-1-1:CL,RFI-V,NSA,,,,:\"Remote Failure Indication - VT\"
+,OC48"
;
LAWMAN01 2007-07-27 17:33:40
** 619.619 REPT ALM T1
"FAC-14-9:MJ,LOF,SA,,,,:\"Loss Of Frame\",DS1-14"
;
BOSMAN51 2007-07-27 17:33:40
A 8965.8962 REPT ALM VT1
"VT1-6-1-29-3-2:CL,RFI-V,NSA,,,,:\"Remote Failure Indication - VT\"
+,OC48"
;
BANMEN01 2007-07-27 17:33:40
A 7623.7623 REPT EVT T1
"FAC-4-2:T-SEFS,TC,,,FEND,,25,25,15-MIN:\"Performance Monitor Thres
+hold Crossing Alert\","
;
SYRNYN51 2007-07-27 17:33:42
A 6443.6443 REPT EVT T1
"FAC-1-8:T-ESL,TC,,,FEND,,65,65,15-MIN:\"Performance Monitor Thresh
+old Crossing Alert\","
;
LAWMAN01 2007-07-27 17:33:43
A 620.619 REPT ALM T1
"FAC-14-9:CL,LOF,SA,,,,:\"Loss Of Frame\",DS1-14"
;
LAWMAN01 2007-07-27 17:33:43
A 621.621 REPT EVT T1
"FAC-14-9:T-UASP,TC,,,FEND,,10,10,15-MIN:\"Performance Monitor Thre
+shold Crossing Alert\","
;
LAWMAN01 2007-07-27 17:34:30
A 632.632 REPT EVT T1
"FAC-4-2:T-ESL,TC,,,FEND,,65,65,15-MIN:\"Performance Monitor Thresh
+old Crossing Alert\","
;
LAWMAN01 2007-07-27 17:34:30
A 633.627 REPT ALM T1
"FAC-14-9:CL,RAI,NSA,,,,:\"Remote Alarm Indication\",DS1-14"
;
bosman62 2007-07-27 18:00:54
A 6962.6960 REPT ALM VT1
"VT1-6-1-30-7-2:CL,RFI-V,NSA,,,,:\"Remote Failure Indication - VT\"
+,OC48"
;