How is a single RADIUS attribute-value pair encoded, and how long can its value be?
answer
- three fields, always the same three
- the length counts itself
- one octet caps the whole attribute
- 255 minus the two header octets
- no generic fragmentation in the base format
basics
~20 sA RADIUS attribute is a type-length-value triple: a one-octet Type, a one-octet Length counting the whole attribute, then the value. Length maxes out at 255, so one attribute carries at most 253 octets of value.
solid answer
~40 sEvery RADIUS attribute has the same three fields: a one-octet `Type`, a one-octet `Length`, then the value. `Length` counts all three parts, so an attribute holding a four-octet integer such as `Session-Timeout` (27) has `Length` 6. Because `Length` is one octet its maximum is 255, which leaves at most **253 octets of value**. There is no general fragmentation in the base format: whether repeating an attribute means concatenation, a list, or an error is defined attribute by attribute, and RFC 6929's long extended types were added precisely to give the protocol a generic way to carry more. The packet as a whole is capped at 4096 octets, which is the other ceiling on how much can be said in one exchange.
code
pseudocode · 17 linesattribute layout:
Type : 1 octet
Length : 1 octet # counts Type + Length + Value
Value : Length - 2 octets
Session-Timeout (27) carrying 3600 seconds:
Type = 27
Length = 6 # 2 header octets + 4 value octets
Value = 00 00 0E 10
walking the attribute list:
offset = start of attributes
while offset < end of packet:
type = octet at offset
length = octet at offset + 1
value = octets at offset + 2 .. offset + length - 1
offset = offset + lengthgo deeper
Remember the three fields and that the length includes its own two header octets. Being able to say why a four-octet integer produces a length of 6 is the check most interviewers use here.
Derive the 253-octet ceiling rather than reciting it, and explain what the encoding does not provide: no generic fragmentation, no self-describing value type, no continuation bit in the base format.
Demonstrate the failure mode: a misread length steps a parser to the wrong offset and corrupts every later attribute, and a value silently truncated at 253 octets produces a session that looks configured but behaves wrongly.
The judgment call is whether to carry long or structured values in a protocol whose value field is bounded by a one-octet length at all, versus keeping replies to short references the access device resolves locally.
## Three fields, always the same three RADIUS is an unusually plain protocol on the wire. After the header, a packet is nothing but a sequence of attributes laid end to end, and every attribute — standard, vendor-defined, one octet long or two hundred — has the same shape: 1. **`Type`** — one octet. The number that says which attribute this is. `User-Name` is 1, `Filter-Id` is 11, `Vendor-Specific` is 26, `Session-Timeout` is 27. 2. **`Length`** — one octet. The size of the **whole attribute**, including the `Type` and `Length` octets themselves. 3. **`Value`** — `Length` minus 2 octets, interpreted according to what that attribute is defined to hold. Because `Length` is self-inclusive, the arithmetic goes the other way from what people expect. An attribute carrying a four-octet integer has `Length` 6, not 4. An attribute whose value is the ten characters `tier-basic` has `Length` 12. Reading `Length` as "how much value follows" is the single most common decoding error, and it desynchronises the parse of every attribute after it, because the reader steps to the wrong offset for the next `Type`. ## Where 253 comes from A one-octet `Length` can express at most 255. Two of those octets are the header, so: | | Octets | |---|---| | Maximum `Length` value | 255 | | `Type` + `Length` overhead | 2 | | **Maximum value in one attribute** | **253** | That number is worth committing to memory, because it is the boundary every interesting encoding decision on this protocol runs into. It is also *per attribute*: the packet has its own ceiling of 4096 octets, so a reply full of long attributes meets the packet limit long before it runs out of attribute slots. The value itself is typed by the attribute's definition rather than by anything on the wire. Integers such as `Session-Timeout` (27) are four octets; an address such as `NAS-IP-Address` (4) is four octets; text such as `Filter-Id` (11) is a run of characters with no terminator, its extent given entirely by `Length`. RFC 8044 later wrote these data types down formally, but nothing in the encoding announces them — a receiver knows a value is an integer because it knows what type 27 is. ## What happens when a value does not fit Here the honest answer is narrower than the intuitive one. **The base format has no general fragmentation.** There is no continuation bit, no sequence number, and no rule that a receiver may glue two instances of an attribute together. What the specification does say is that when an attribute may appear more than once, the **order of like attributes must be preserved**; what those repeated instances *mean* is left to the attribute's own definition. Some are defined so that repeated instances concatenate; some are defined as a list of independent values; for some, a second instance is simply an error. So a value longer than 253 octets has three honest answers, and "RADIUS splits it automatically" is not one of them: - The attribute's own definition provides a multi-instance rule, and both ends implement exactly that rule. - The value is carried under `Vendor-Specific` (26) in a private shape both ends already agree on. - The deployment uses RFC 6929's **long extended types**, which add a `Flags` octet with a *More* bit and so give the protocol a generic, attribute-independent way to spread one value across several attributes. ## Why the shape is worth knowing On a ship's passenger wireless network, the reply that turns an accepted login into a usable session is a handful of these triples: an address, a filter name, a time limit. Each one is three fields, and the whole session profile is often under fifty octets. The shape only becomes visible when something outgrows it — a filter name longer than 253 characters, a vendor payload that must be chunked — and at that point the difference between "the protocol will handle it" and "the attribute definition must handle it" is the difference between a working deployment and a truncated value nobody notices until a session behaves oddly.
- A RADIUS attribute carries a four-octet integer. Why is its Length field 6 rather than 4?Because `Length` measures the whole attribute, not just the value. Two octets go on `Type` and `Length` themselves, so four octets of integer make six in total. A receiver uses that number to step to the next attribute, which is why misreading it as the value size derails the parse of everything after it.
- Two instances of the same RADIUS attribute arrive in one packet — what may a receiver assume?Only what that attribute's own definition says. RADIUS requires the order of like attributes to be preserved, but it defines no generic meaning for repetition: some attributes are defined to concatenate, some to form a list, and for others a second instance is an error. Assuming automatic reassembly is the classic mistake.
saying these in an interview costs you the question
- Says the Length field counts only the value octets.
- Claims a single attribute can carry 255 octets of value.
- Believes RADIUS reassembles any long value split across attributes.
- Confuses the 4096-octet packet cap with the per-attribute limit.
- Thinks the wire announces whether a value is text or an integer.