📄 address.tex
字号:
\chapter{The (Revised) Addressing Structure in NS}\label{chap:Address}This chapter describes the internals of the revised addressing formatimplemented in \ns. The chapter consists of five sections. Wedescribe the APIs that can be used for allocating bits to the ns addressingstructure. The address space as described in chapter 3, can be thoughtof a contiguous field of {\em n} bits, where n may vary as per theaddress requirement of the simulation. The default value of {\em n} is16 (as defined by {\em MAXADDRSIZE\_}). The maximum value of {\em n} isset to 32 (defined as {\em MAXADDRSIZE\_}). These default and maximum address sizes are defined in \nsf{/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'saddress or id\_ and remaining lower bits are assigned to form port-id orthe identification of the agent attached to the node. Of the higherbits, 1 bit is assigned for multicast. The default settings allow 7higher bits for node-id, the MSB for multicast and the lower remaining 8bits for port-id. Naturally this limits the simulation to 128nodes. This address space may be expanded to accomodatelarger number of nodes in the simulation. The port-id may also beexpanded to suppprt higher number of agents. Additionally, the address space mayalso be set in hierarchical format, consisting of multiple levels ofaddressing hierarchy. We shall be describing the APIs for setting address structure indifferent formats as described above as well as expanding the addressspace. The procedures and functions described in this chapter can be found in\nsf{tcl/lib/ns-address.tcl, address.cc and address.h}.\section{The Default Address Format}\label{sec:defaultFormat}The default settings allocates 8 lower bits for port-id, 1 higher bitfor mcast and the rest 7 higher bits for node-id. The procedure to setthe address format in default mode is called during initialisation ofthe simulator as:\begin{program}{\cf # The preamble}set ns [new Simulator] \; initialise the simulation;\end{program}It can also be called explicitly set as:\begin{program}\$ns set-address-format def\end{program}\section{The Hierarchical Address Format}\label{sec:hierFormat}There are two options for setting an address to hierarchical format, thedefault and the specified.\subsection{Default Hierarchical Setting}\label{sec:def-hier}The default hierarchical node-id consists of 3 levels with 8 bitsassigned to each level. The hierarchical configuration may be invoked asfollows: \$ns set-address-format hierarchical\begin{quote}This sets :* 8 bits for port-id, * 24 bits for node-id assigned in - 3 levels of hierarchy - 8 bits for each level - looks like 8 8 8 - or 7 8 8, if multicast is enabled. \end{quote}\subsection{Specific Hierarchical Setting}\label{sec:sp-hier}The second option allows a hierarchical address to be set with specifiednumber of levels with number of bits assigned for each level. The APIwould be as the following:\$ns set-address-format hierarchical <\#n hierarchy levels> <\#bits forlevel1> <\#bits for level 2> ....<\#bits for nth level> An example configuration would be:\$ns set-address-format hierarchical 2 8 15 where 2 levels of hierarchy is specified, assigning 8 bits for the 1stlevel and 15 bits for the second.\section{The Expanded Node-Address Format}\label{sec:expandFormat}On the event of requirement of more bits to the address space, theexpanded address API may be used as:\$ns set-address-format expanded This expands the address space to 30 bits, allocating 22 higher bits tonode-id and lower 8 bits to port-id. \section{Expanding port-id field} \label{sec:expandportFormat}This primitive may be used in case of need to expand portid in the eventof requirement to attach a large number of agents to the nodes. This maybe used in conjunction with set-addres-format command (with differentoptions) explained above. Synopsis for this command shall be:expand-port-field-bits <\#bits for portid> expand-port-field-bits checks and raises error in the following if therequested portsize cannot be accomodated (i.e if sufficient num.of freebits are not available) or if requested portsize is less than or equalto the existing portsize. \section{Errors in setting address format}\label{sec:err-add}Errors are returned for both {\em set-address-format} and{\em expand-port-field-bits} primitives in the following cases:\begin{quote}* if number of bits specified is less than 0.* if bit positions clash (contiguous number of requested free bits not* found). * if total number of bits exceed MAXADDRSIZE\_.* if expand-port-field-bits is attempted with portbits less than or* equal to the existing portsize.* if number of hierarchy levels donot match with number of bits* specified (for each level). \end{quote}\section{Commands at a glance}\label{sec:addresscommand}The following is a list of address-format related commands used in simulationscripts:\begin{flushleft}\code{$ns_ set-address-format def}\\This command is used internally to set the address format to its default valueof 8 lower bits for port-id, 1 higher bit for mcast and the rest 7 higher bitsfor port-id. However this API has been replaced by the new node API\\\code{$ns_ node-config -addressType flat}.\code{$ns_ set-address-format hierarchical}\\This command is used to set the address format to the hierarchical configurationthat consists of 3 levels with 8bits assigned to each level and 8 lower bitsfor port-id. However this API has been replaced by the new node API\\\code{$ns_ node-config -addressType hierarchical}.\code{$ns_ set-address-format hierarchical <levels> <args>}\\This command is used to set the address format to a specific hierarchicalsetting. The <levels> indicate the number of levels of hierarchy in the addressingstructure, while the args define number of bits for each level. An examplewould be \code{$ns_ set-address-format hierachical 3 4 4 16} , where 4, 4 and16 defines the number of bits to be used for the address space in level 1 , 2and 3 respectively.\code{$ns_ set-address-format expanded}\\This command was used to expand the address space to 30 bits, allocating22 higher bits for node-id and lower 8 bits for port-id. However this commandis obsoleted now by 32 bit addressing, i.e node-id field is 32 bit wide.\code{expand-port-field-bits <bits-for-portid>}\\Similar to the command above, this was used to expand the address space forthe port-id field to <bits-for-portid> number of bits. However this commandis obsolete now that the ports are 32 bit wide.\end{flushleft}\endinput
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -