#!/usr/bin/perl -w # tailfin.pl - Diagnostic Utility for the 3Com Home Connect Model: 3CR29223 # # This modem is a goofy looking translucent plastic thing which looks like a shark's tail fin. # use IO::Socket; use strict; my $port="55555"; my $server="192.168.100.1"; my $LOGFILE = "tailfin.log"; # Subroutines sub get_field { my $num = shift; return $num * 3 - 1; } # Program Starts Here my $socket = IO::Socket::INET->new ( Proto => "tcp", PeerAddr=> $server, PeerPort=> $port, ) or die "Error creating socket"; $socket->autoflush(1); # Please Excuse The Ratty Code ;-) open(MYLOGFILE,">>$LOGFILE"); while(<$socket>){ my $record = $_; my @data = split(/\$/, $record); # Log the data for later plotting print MYLOGFILE $record ."\n"; # Grab some of the values my $freq = $data[get_field(1)] / 1000000; # Convert to MHz my $qam = $data[get_field(2)]; my $freq_plan = $data[get_field(3)]; my $ucd_array = $data[get_field(4)]; my $ucd_unicast = $data[get_field(5)]; my $up_mod = $data[get_field(6)]; my $datarate = $data[get_field(7)] / 1048576; # Convert to Mbits/sec my $power_tx = $data[get_field(8)]; my $down_lock = $data[get_field(18)]; my $down_interleave = $data[get_field(19)]; my $power_rx = $data[get_field(20)]; my $range_status = $data[get_field(21)]; my $freq_last = $data[get_field(28)] / 1000000; # Convert to MHz my $freq_low = $data[get_field(29)] / 1000000; # Convert to MHz my $freq_high = $data[get_field(30)] / 1000000; # Convert to MHz # Print out some values print "Frequency: ".$freq." MHz\n"; print "Expecting: ".$freq_last." MHz\n"; print "Band: ".$freq_low." MHz - ".$freq_high." MHz\n"; print "Plan: ".$freq_plan."\n"; print "Modulation: ".$up_mod." ".$qam."\n"; print "SubCarrier: ".$ucd_unicast."\n"; print "Rate: ".$datarate." Mbit/s\n"; print "TX Energy: ".$power_tx." dBmV\n"; print "RX Energy: ".$power_rx." dBmV\n"; print "Status: ".$range_status."\n"; print "Lock: ".$down_lock."\n"; print "---------------------------------------\n"; } close(MYLOGFILE); __END__ Data stream from modem port 55555 is split on every third $ symbol. This leaves you with 3 fields seperated by 2 $ symbols. Field 1: Data Position Field 2: Data Length Field 3: Data Value Example: "1$9$597000000" Field 1 has 9 Characters with value of "597000000" "$2$6$64 QAM" Field 2 has 6 Characters with value of "64 QAM" Raw Data Dump of a Good Connection: 1$9$597000000$2$6$64 QAM$3$29$US Standard Cable Frequencies$4$11$2#3#4#5#6#1$5$1$2$6$4$QPSK$7$14$2559999.000000$8$9$45.000000$9$12$DHCP SUCCESS$10$12$TFTP SUCCESS$11$11$REG SUCCESS$12$11$BPI SUCCESS$13$38$CM is ALLOWED for CPE Internet Traffic$14$7$2564478$15$8$96070389$16$2$41$17$1$4$18$17$Downstream Locked$19$1$5$20$10$-29.752012$21$15$Ranging Success$22$5$Green$23$5$Green$24$5$Green$25$5$Green$26$5$Green$27$5$Green$28$9$597000000$29$8$91000000$30$9$857000000$ Reformatted Data Dump: 1$9$ 597000000 $2$6$ 64 QAM $3$29$ US Standard Cable Frequencies $4$11$ 2#3#4#5#6#1 $5$1$ 2 $6$4$ QPSK $7$14$ 2559999.000000 $8$9$ 45.000000 $9$12$ DHCP SUCCESS $10$12$ TFTP SUCCESS $11$11$ REG SUCCESS $12$11$ BPI SUCCESS $13$38$ CM is ALLOWED for CPE Internet Traffic $14$7$ 2564478 $15$8$ 96070389 $16$2$ 41 $17$1$ 4 $18$17$ Downstream Locked $19$1$ 5 $20$10$ -29.752012 $21$15$ Ranging Success $22$5$ Green $23$5$ Green $24$5$ Green $25$5$ Green $26$5$ Green $27$5$ Green $28$9$ 597000000 $29$8$ 91000000 $30$9$ 857000000 $ Description of Fields: 1 Frequency 2 QAM Mode 3 Frequency Plan 4 Upstream Bandwidth Allocations (# seperated values) 5 Upstream Channel Descriptor 6 Upstream Modulation Type 7 Symbol rate (bits/sec?) 8 TX Power level (dBmV) 9 DHCP Status 10 TFTP Status 11 Registration Status 12 Baseline Privacy (Encryption) Status 13 Cable Modem Status (Allowed or Denied onto Internet) 14 Bytes Sent 15 Bytes Received 16 Uncorrectable Errors 17 CRC Errors 18 Downstream Lock status 19 Downstream Interleave 20 RX Power level (dBmV) 21 Upstream Ranging Status 22 Downstream lock LED 23 Ranging LED 24 DHCP Status LED 25 TFTP Status LED 26 Registration Status LED 27 Baseline Privacy (Encryption) Status LED 28 Last Registered Frequency 29 Lowest Tunable Frequency 30 Highest Tunable Frequency