RADIUS Client API (V3)

com.theorem.radius3.radutil
Class DumpPacket

Object
  extended byDumpPacket

public class DumpPacket
extends Object

Class to analyze packet dumps.

Only one packet per text file is read. Please see Replay if you want to replay a dumped packet. The dumped contents MUST start at the top of the file. Newlines or other characters will cause various exceptions and Replay will send a zero length packet.

The dump data is expected to be raw hex values extracted from a log as follows.

02020037 1433ac12 bb030234 3437a58a
908e58db 19235342 522d434c 20444e3d
22303036 3031442d 46323135 39422220
41543d22 302200

01 02 00 3B AC 88 E9 F3 - 04 EC 4E 3E 46 88 E7 80
44 69 61 99 04 06 C0 A8 - 00 40 01 0F 30 30 30 32
32 64 2D 33 63 38 38 61 - 35 02 12 8A 58 7E A2 7E
EE 35 90 7F 59 AC 9B AC - 58 72 29

02 01 00 23 C5 1B 5D 20 - 93 61 95 A5 6A C0 26 A9
BB 55 72 50 01 0F 30 30 - 36 30 31 64 2D 66 32 31
35 39 62

01 52 00 48 F7 6E 5B 27 - 15 50 EF AC 4A 2C CC 5B   .R.H.n[' - .P..J,.[
79 AE 87 EA 05 06 00 00 - 00 01 01 09 6D 69 63 68   y....... - ....mich
61 65 6C 3C 12 15 72 7B - 05 33 12 AF FD 83 35 B6   ael<..r{ - .3....5.
BE B9 C8 38 78 03 13 71 - 42 90 D9 30 C2 88 BB DF   ...8x..q - B..0....
4C C7 39 0F 06 99 04 50 - 00 00 00 00 00 00 00 00   L.9....P - ........
Respectively results in
------------------------ Packet -----------------------
Packet Length: 55
Code: Access-Accept(2)
Identifier: 2
Length: 55
Authenticator: 14 33 AC 12 BB 3 2 34 34 37 A5 8A 90 8E 58 DB
Attributes:
Class (25), Length: 35, Data: 0x5342522D434C20444E3D223030363031442D463231353942
222041543D22302200

-------------------------------------------------------

------------------------ Packet -----------------------
Packet Length: 59
Code: Access-Request(1)
Identifier: 2
Length: 59
Authenticator: AC 88 E9 F3 4 EC 4E 3E 46 88 E7 80 44 69 61 99
Attributes:
NAS-IP-Address (4), Length: 6, Data: [# 3232235584] / [IP 192.168.0.64], 0xC0A80
040
User-Name (1), Length: 15, Data: [00022d-3c88a5], 0x3030303232642D336338386135
User-Password (2), Length: 18, Data: 0x8A587EA27EEE35907F59AC9BAC587229

-------------------------------------------------------

------------------------ Packet -----------------------
Packet Length: 35
Code: Access-Accept(2)
Identifier: 1
Length: 35
Authenticator: C5 1B 5D 20 93 61 95 A5 6A C0 26 A9 BB 55 72 50
Attributes:
User-Name (1), Length: 15, Data: [00601d-f2159b], 0x3030363031642D663231353962

-------------------------------------------------------

------------------------ Packet -----------------------
Packet Length: 80
Code: Access-Request(1)
Identifier: 82
Length: 72
Authenticator: F7 6E 5B 27 15 50 EF AC 4A 2C CC 5B 79 AE 87 EA
Attributes:
NAS-Port (5), Length: 6, Data: [# 1], 0x00000001
User-Name (1), Length: 9, Data: [michael], 0x6D69636861656C
CHAP-Challenge (60), Length: 18, Data: 0x15727B053312AFFD8335B6BEB9C83878
CHAP-Password (3), Length: 19, Data: 0x714290D930C288BBDF4CC7390F06990450
-------------------- End of Packet --------------------


Constructor Summary
DumpPacket()
          Default constructor.
DumpPacket(byte[] packetBytes)
          Constructor using a prepared packet.
 
Method Summary
 AttributeList getAttributeList()
          Get the attributes carried in this packet.
 byte[] getAuthenticator()
          Get the packet's authenticator.
 int getCode()
          Get the packet code (response or request code field), also known as message type.
 String getErrorMessage()
          Get an error message if any was generated.
 int getIdentifier()
          Get the packet identifier.
 int getLength()
          Get the packet's length field value.
 int getPhysicalLength()
          Get the packet's physical size.
static void main(String[] args)
          Main: arg is the file name to read containing the packets.
 void setData(byte[] packetBytes)
          Set the packet data.
 byte[] toByteArray(BufferedReader br)
          Convert a file consisting of hex bytes and miscellaneous data to a byte array of data.
 String toString()
          Return a string representing the decoded packet.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DumpPacket

public DumpPacket()
Default constructor.


DumpPacket

public DumpPacket(byte[] packetBytes)
Constructor using a prepared packet.

Parameters:
packetBytes - Byte array comprising the packet.
Method Detail

toByteArray

public byte[] toByteArray(BufferedReader br)
                   throws IOException
Convert a file consisting of hex bytes and miscellaneous data to a byte array of data.

The dump is expected to have 16 bytes of hexadecimal data perhaps containing spaces or dashes. Any characters following the 16 bytes (32 hex chars) is ignored. An empty line terminates the packet data.

Here are two examples:

 01 6C 00 5D 3C 79 A7 04 - B5 CE 07 62 8F A4 0F B5   .l.]<y.. - ...b....
 89 F4 DF 45 04 06 C0 A8 - 66 05 05 06 00 00 00 02   ...E.... - f.......
 1A 0E 00 00 00 09 02 08 - 41 73 79 6E 63 32 3D 06   ........ - Async2=.
 00 00 00 00 01 09 6D 69 - 63 68 61 65 6C 1E 02 02   ......mi - chael...
 12 8B A0 20 2B DD 5A AB - E5 C0 20 77 26 38 C5 49   ... +.Z. - .. w&8.I
 ED 06 06 00 00 00 02 07 - 06 00 00 00 01 00 00 00   ........ - ........
 
and
 02020037 1433ac12 bb030234 3437a58a
 908e58db 19235342 522d434c 20444e3d
 22303036 3031442d 46323135 39422220
 41543d22 302200
 

Parameters:
br - BufferedReader containing the data.
Returns:
byte array of actual data with extra information stripped off.
Throws:
IOException - if there's a problem with the file or parsing the data.

setData

public void setData(byte[] packetBytes)
Set the packet data.

Parameters:
packetBytes - Byte array comprising the packet.

toString

public String toString()
Return a string representing the decoded packet. The string looks like this:
 ------------------------ Packet -----------------------Packet Length: 61
 	* Code: Access-Request(1)
 Identifier: 108
 Length: 93
 Authenticator: 3C 79 A7 4 B5 CE 7 62 8F A4 F B5 89 F4 DF 45
 Attributes:
 NAS-IP-Address (4), Length: 6, Data: [# 3232261637] / [IP 192.168.102.5], 0xC0A86605
 NAS-Port (5), Length: 6, Data: [# 2], 0x00000002
 Vendor-Specific ID: Cisco (9), VSA Count: 1
    Cisco-NAS-port (2), Length: 8, Data: [Async2], 0x4173796E6332
 NAS-Port-Type (61), Length: 6, Data: [# 0 (Async)], 0x00000000
 User-Name (1), Length: 9, Data: [michael], 0x6D69636861656C
 35 bytes at end of dump ignored.
 -------------------------------------------------------
 

Returns:
String representing the packet.

getErrorMessage

public String getErrorMessage()
Get an error message if any was generated.

Returns:
Error message or null if none was generated.

getCode

public int getCode()
Get the packet code (response or request code field), also known as message type.

Returns:
code.

getIdentifier

public int getIdentifier()
Get the packet identifier.

Returns:
Packet identifier.

getLength

public int getLength()
Get the packet's length field value.


getPhysicalLength

public int getPhysicalLength()
Get the packet's physical size.

Returns:
Packet's physical size (may or may not match the length field).

getAuthenticator

public byte[] getAuthenticator()
Get the packet's authenticator.

Returns:
Authenticator.

getAttributeList

public AttributeList getAttributeList()
Get the attributes carried in this packet.

Returns:
Attribute list.

main

public static void main(String[] args)
Main: arg is the file name to read containing the packets.

Parameters:
args - If there is a single argument a file containing the packet data will be read. Otherwise stdin will be read.

RADIUS Client API (V3)

Submit a bug report or feature request

Copyright 1998-2008 AXL Software. PO Box 97, Viola, Delaware 19979, U.S.A. All Rights Reserved.