(PM) Re: RFE - Change PM-4 port numbering

John Storms (jstorms@livingston.com)
Wed, 17 Feb 1999 07:00:33 -0800

Actually, here's how is in 4.1 which is in alpha trials. The slot, line,
and channel information are encoded into a 32 bit number thats shown in the
detail file as an integer.

At the end of this message is a perl script that will convert the NAS
number into slot, line, channel info. Also, when 4.1 is released we'll
send out a matrix for all the values.

FYI: The session-ID will also be modified to reflect the slot number.

NAS-Port Number Format

0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Unused (zeros) | Slot | Line | Channel |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Example of NAS-Port in detail file

Mon Jan 18 09:22:37 1999
Acct-Session-Id = "012D000003"
User-Name = "tc1"
NAS-IP-Address = 192.168.111.25
NAS-Port = 1025
NAS-Port-Type = 5
Acct-Status-Type = Stop
Acct-Session-Time = 57
Acct-Authentic = RADIUS
Connect-Info = "9600 LAPM/V42BIS"
Acct-Input-Octets = 67
Acct-Output-Octets = 2285
Called-Station-Id = "4619993"
Calling-Station-Id = "9254610115"
Acct-Terminate-Cause = User-Request
LE-Terminate-Detail = "User Request - Normal LAPM Disconnect"
Service-Type = Login-User
Login-Service = Telnet
Login-IP-Host = 149.198.168.170
Acct-Delay-Time = 0
Timestamp = 916680157

#
# PERL SCRIP TO DECODE NAS-PORT
#

!/usr/local/bin/perl

#$IMP = "cgi";
$IMP = "file";

local($nasport) = "";

if($IMP eq "cgi") {
# Include Library of Perl routines
push (@INC,"/usr/local/etc/httpd/cgi-bin/");
require ("cgi-lib.pl");

# Put Arguments into $in array
&ReadParse;
print &PrintHeader;
$nasport = $in{nas};
} else {

$nasport = $ARGV[0];
if($nasport eq "") {
print "usage: parsenas.pl <integer>\n";
die;
}
}

@binary = (
"0::0000",
"1::0001",
"2::0010",
"3::0011",
"4::0100",
"5::0101",
"6::0110",
"7::0111",
"8::1000",
"9::1001",
"A::1010",
"B::1011",
"C::1100",
"D::1101",
"E::1110",
"F::1111"
);

@hex = (
"0000::0",
"0001::1",
"0010::2",
"0011::3",
"0100::4",
"0101::5",
"0110::6",
"0111::7",
"1000::8",
"1001::9",
"1010::A",
"1011::B",
"1100::C",
"1101::D",
"1110::E",
"1111::F"
);

if($IMP eq "cgi") {
print "<BODY bgcolor=\"#ffffff\" text=\"#000000\" link=\"#0000ff\"
vlink=\"#b245b0\" alink=\"#2cbfe5\">\n<h3>";
}

print "Parsed NAS-Port = $nasport\n";

if($IMP eq "cgi") {
print "</h3><br>\n";
}

&parsenasport($nasport);

# ===============================================
sub hack {
local($string) = $_[0];
local($chars) = $_[1];
local($retval) = "";

$retval = substr($string,$chars,length($string)-$chars);
return($retval);
}

sub match {
# Return a matching value in array
# We receive an array. Last element of array is the item to matched against.
# initialize variables
local(@array) = @_;
local($retval) = "";
local($count) = 0;
local($string) = "";
local($desc) = "";
# cycle thru array searching for match
for($count=0;$count<@array-1;$count++) {
($string, $desc) = split(/::/,$array[$count]);
if($string eq $array[@array-1]) {
$retval = $desc; # set description to retrun value
$count = @array; # terminate loop
}
}
# pad returned strings with a space for output formatting
if(length($retval)>0) {
$retval = $retval." ";
}
return($retval); # return description to calling function
}

sub hex2bin {
local($hexstring) = $_[0];
local($binstring) = "";
local($i) = 0;

#&clean($hexstring);
for($i=0;$i<length($hexstring);$i++) {
#print "$i,";
$t = substr($hexstring,$i,1),",";
#print "$t,",&match(@binary,$t);
#print "\n";
$binstring = $binstring.&match(@binary,$t);

chop($binstring);
}
return($binstring);
}

sub dec2hex {
return(sprintf("%x",$_[0]));
}

sub dec2bin {
local($start) = $_[0];
local($hold) = "";
local($retval) = "";

$hold = &dec2hex($start);
#print "(1)dec2bin[$hold]\n";

$retval = &hex2bin($hold);
#print "(2)dec2bin[$retval]\n";
return($retval);
}

sub bin2dec {
local($string1) = $_[0];
local($string2) = "";
$string2 = &bin2hex($string1);
$string1 = &hex2dec($string2);
return($string1);
}

sub bin2hex {
local($hexstring) = "";
local($binstring) = $_[0];
local($fourbit) = "";
local($i) = 0;
local($padlength) =
4-((length($binstring))-(int(length($binstring)/4)*4));

if($padlength == 4) {
$padlength = 0;
}
$binstring = substr("0000",0,$padlength).$binstring;

for($i=0;$i<length($binstring);$i=$i+4) {
$fourbit = substr($binstring,$i,4);
$hexstring = $hexstring.&match(@hex,substr($binstring,$i,4));
chop($hexstring);
}
return($hexstring);
}

sub hex2dec {
# Converts passed value from decimal to hex
$return=hex($_[0]);
}

sub lpad {
local($string) = $_[0];
local($char) = $_[1];
local($size) = $_[2];
local($retval) = "";
local($dif) = $size - length($string);
local($i) = 0;
for($i=0;$i<$dif;$i++) {
$retval = $retval.$char;
}
$retval = $retval.$string;
return($retval);
}

sub parsenasport {
#local($nasport) = &lpad($_[0],"0",10);
local($nasport) = $_[0];

local($bin) = &dec2bin($nasport);

# slot line port
# 000000000000000000|0001|00000|00001
# 123456789012345678|1234|12345|12345

#print "NAS-Port[$nasport]=[$bin]\n";
$bin = &lpad($bin,"0",32);

local($unused) = substr($bin,0,18);
$bin = &hack($bin,18);

local($bslot) = substr($bin,0,4);
$bin = &hack($bin,4);

local($bline) = substr($bin,0,5);
$bin = &hack($bin,5);

local($bport) = substr($bin,0,5);

#print "NAS-Port: [$nasport]; ";
#print "Unused [$unused]; ";
#print "Slot [$bslot]; ";
#print "Line [$bline]; ";
#print "Port[$bport];\n";

print "NAS-Port: [$nasport] = ";
#print "Unused [$unused]; ";
print "Slot [",&bin2dec($bslot),"]; ";
print "Line [",&bin2dec($bline),"]; ";
print "Channel[",&bin2dec($bport),"];\n";


if($IMP eq "cgi") {
print "<PRE>";
}

print " 0 1 2 3\n";
print " 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n";
print "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
print
"|",&spaced($unused),"|",&spaced($bslot),"|",&spaced($bline),"|",&spaced($bp
ort),"|\n";
print "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
print " Unused (All zeros) Slot Line Channel\n";

if($IMP eq "cgi") {
print "</pre>";
}

}

sub spaced {
local($string) = $_[0];
local($space) = " ";
local($retval) = "";
local($i) = 0;

for($i=0;$i<length($string);$i++) {
$retval = $retval.substr($string,$i,1)." ";
}
chop($retval);
return($retval);

}

At 11:15 PM 2/13/99 -0800, MegaZone wrote:
>Once upon a time Thomas Kinnen shaped the electrons to say...
>>Overall adding either an attribute for the blade number or making the
>>numbers unique across the chassie would be nice and reduce the problem but
>>it would not remove it.
>
>While I agree that, based on what was posted here, it sounds like Robert's
>system has some flaws (I hope he isn't doing simultaneous use control based
>ONLY on RADIUS Packets - that's flawed) I do think port numbers should be
>differentiated. So, let's look at the RFC:
>
>5.5. NAS-Port
>
> Description
>
> This Attribute indicates the physical port number of the NAS which
> is authenticating the user. It is only used in Access-Request
> packets. Note that this is using "port" in its sense of a
> physical connection on the NAS, not in the sense of a TCP or UDP
> port number. Either NAS-Port or NAS-Port-Type (61) or both SHOULD
> be present in an Access-Request packet, if the NAS differentiates
> among its ports.
>
> A summary of the NAS-Port Attribute format is shown below. The
> fields are transmitted from left to right.
>
> 0 1 2 3
> 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> | Type | Length | Value
> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> Value (cont) |
> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>
> Type
>
> 5 for NAS-Port.
>
> Length
>
> 6
>
> Value
>
> The Value field is four octets. Despite the size of the field,
> values range from 0 to 65535.
>
>Ok. Now, unless you plan to have more than 999 ports PER SLOT soon, I
>propose the following format:
>
>XXYYY - where XX is the slot, and YYY is the port number.
>
>Say port five on slot 4 would be 04005 - port 4005. I belive the slots
>are numbered 00-09 (I know, the ethernet, etc, have slot numbers - I'm
>taking physical slots.) One advantage to this is immediately knowing
>what slot a port is in. 9096 is port 96, slot 9. 96 is port 96, slot 0.
>
>We've already heard that phase 2 for the PM-4 is supposed to be 3 T3, or
>12 T1s per card instesd of 4. So reserving 96 ports isn't a good plan -
>it will need to be changed. Numbering based on slot and port means you
>could carry the same scheme for more than 10 slots (possibly future product
>growth - say a PM-4 with 15/16 slots and no AC power slots - which are wasted
>space in a telco rack). And up to 999 ports - so when they release a T3 card
>for ISDN/DS0 use with 672 ports on a card, it is covered. If they ever go
>to more than 999 you can double up slots - 00/01, 02/03, etc. It will keep
>the port unique.
>
>-MZ
>--
>-=*X GOT CLUE? ISPF II - SAN DIEGO, CA 3/6-10 <URL:http://www.ispf.com/> X*=-
><URL:mailto:megazone@megazone.org> Gweep, Discordian, Author, Engineer, me..
>Join ISP/C Internet Service Providers' Consortium <URL:http://www.ispc.org/>
>"A little nonsense now and then, is relished by the wisest men" 781-788-0130
><URL:http://www.megazone.org/> <URL:http://www.gweep.net/> Hail Discordia!
>
>
>

---
jstorms@lucent.com (Galactic Hero)
Diplomacy:  The art of saying good doggie
while seaching for a big rock.
-
To unsubscribe, email 'majordomo@livingston.com' with
'unsubscribe portmaster-users' in the body of the message.
Searchable list archive: <URL:http://www.livingston.com/Tech/archive/>