15. The (Revised) Addressing Structure in NS

This chapter describes the internals of the revised addressing format implemented in ns. The chapter consists of five sections. We describe the APIs that can be used for allocating bits to the ns addressing structure. The address space can be thought of a contiguous field of n bits, where n may vary as per the address requirement of the simulation. Typically, however, n is not varied and is held at 31 bits. The default value of n is 31 (as defined by DEFADDRSIZE_). The maximum value of n is set to 31 (defined as MAXADDRSIZE_). These default and maximum address sizes are defined in ~ns//tcl/lib/ns-default.tcl.

ns addresses exist in both OTcl and C++ realms. In Tcl, everything is a string, while C++ has strongly typed integers. Tcl handling of integers, especially 32 bit and larger integers, is inconsistent across versions, and behavior of 32 bit addresses is inconsistent across 32- and 64-bit machine architectures. When addresses cross the boundary between OTcl and C++, they are cast to a signed integer. Therefore, we avoid these incompatibilities by fixing the maximum address size at 31 bits. Prior to ns-2.35 (when this maximum was established), the maximum was 32 bits, but users are now advised to avoid changing the default and maximum from 31 bits.

The address space consists of 2 parts, the node-id and the port-id. 31 bits are allocated for the node-id, and 31 bits are allocated for the port-id or the identification of the agent attached to the node. Of the node-id bits, 1 bit (the most-significant-bit) is assigned for multicast. Additionally, the address space may also be set in hierarchical format, consisting of multiple levels of addressing hierarchy. We shall be describing the APIs for setting address structure in different formats as described above as well as expanding the address space. The procedures and functions described in this chapter can be found in ~ns/tcl/lib/ns-address.tcl, address.cc and address.h.



Subsections
Tom Henderson 2011-11-05