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 as described in chapter 3, can be thought of a contiguous field of n bits, where n may vary as per the address requirement of the simulation. The default value of n is 16 (as defined by MAXADDRSIZE_). The maximum value of n is set to 32 (defined as MAXADDRSIZE_). These default and maximum address sizes are defined in ~ns//tcl/lib/ns-default.tcl.
The address space consists of 2 parts, the node-id and the port-id. The higher bits are assigned as the node's address or id_ and remaining lower bits are assigned to form port-id or the identification of the agent attached to the node. Of the higher bits, 1 bit is assigned for multicast. The address space consists of 32 bits and port id space consists of 32 bits as well. The higher 32 bits for node-id, the MSB for multicast and the lower 32 bits for port-id. 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.