00001 static char code[] = "\n\ 00002 DropInterface set debug_ 0\n\ 00003 \n\ 00004 Class ConnectorList\n\ 00005 \n\ 00006 ConnectorList instproc init { } {\n\ 00007 $self next \n\ 00008 $self instvar head_ tail_ \n\ 00009 $self set head_ [new Connector]\n\ 00010 $self set tail_ [new Connector]\n\ 00011 $head_ target $tail_\n\ 00012 }\n\ 00013 \n\ 00014 ConnectorList instproc tail {} {\n\ 00015 $self instvar tail_\n\ 00016 return $tail_ \n\ 00017 }\n\ 00018 \n\ 00019 \n\ 00020 ConnectorList instproc head {} {\n\ 00021 $self instvar head_\n\ 00022 return $head_\n\ 00023 }\n\ 00024 \n\ 00025 ConnectorList instproc add-to-head { connector } {\n\ 00026 $self instvar head_\n\ 00027 $connector target [$head_ target]\n\ 00028 $head_ target $connector\n\ 00029 }\n\ 00030 \n\ 00031 \n\ 00032 \n\ 00033 \n\ 00034 set NModuleLink 0\n\ 00035 \n\ 00036 Module/Link set debug_ 0\n\ 00037 \n\ 00038 Module/Link instproc init {} {\n\ 00039 global NModuleLink\n\ 00040 eval $self next \n\ 00041 $self instvar delaylink_ queue_ link_ bin_ di_\n\ 00042 $self set link_ [new ConnectorList]\n\ 00043 \n\ 00044 $self setLinkHead [$link_ head]\n\ 00045 [$link_ tail] target $self\n\ 00046 \n\ 00047 set delaylink_ [new DelayLink]\n\ 00048 $link_ add-to-head $delaylink_\n\ 00049 \n\ 00050 set queue_ [new Queue/DropTail] \n\ 00051 $link_ add-to-head $queue_\n\ 00052 \n\ 00053 $self setLinkHead $queue_\n\ 00054 $queue_ target $delaylink_\n\ 00055 $delaylink_ target $self \n\ 00056 \n\ 00057 set bin_ [new ConnectorTrace/Bin]\n\ 00058 set fd [[Simulator instance] get-ns-traceall]\n\ 00059 $bin_ preamble \"$NModuleLink CHBIN\"\n\ 00060 $bin_ attach $fd\n\ 00061 $self addbin $bin_\n\ 00062 set di_ [new DropInterface]\n\ 00063 $di_ setChannel $self\n\ 00064 $queue_ drop-target $di_\n\ 00065 $self id_ $NModuleLink\n\ 00066 incr NModuleLink\n\ 00067 }\n\ 00068 \n\ 00069 \n\ 00070 Module/Link instproc connect {node1 mod1 verb1 node2 mod2 verb2} {\n\ 00071 $node1 addToChannel $self $mod1 $verb1\n\ 00072 $node2 addToChannel $self $mod2 $verb2\n\ 00073 }\n\ 00074 \n\ 00075 \n\ 00076 Module/Link instproc delay {del} {\n\ 00077 $self instvar delaylink_\n\ 00078 $delaylink_ set delay_ $del\n\ 00079 }\n\ 00080 \n\ 00081 Module/Link instproc bandwidth {bw} {\n\ 00082 $self instvar delaylink_\n\ 00083 $delaylink_ set bandwidth_ $bw\n\ 00084 }\n\ 00085 \n\ 00086 Module/Link instproc qsize {qs} {\n\ 00087 $self instvar queue_\n\ 00088 $queue_ set limit_ $qs\n\ 00089 }\n\ 00090 \n\ 00091 \n\ 00092 Module/Link instproc addErrorModel {em} {\n\ 00093 $self instvar delaylink_ queue_ link_ bin_ di_\n\ 00094 $delaylink_ target $em\n\ 00095 $em target [$link_ tail]\n\ 00096 $em drop-target $di_\n\ 00097 }\n\ 00098 \n\ 00099 \n\ 00100 Module/Link instproc print-params {} {\n\ 00101 $self instvar queue_ delaylink_\n\ 00102 set d [$delaylink_ set delay_]\n\ 00103 set b [$delaylink_ set bandwidth_]\n\ 00104 set q [$queue_ set limit_]\n\ 00105 puts \"delay=$d bw=$b qsize=$q\"\n\ 00106 }\n\ 00107 \n\ 00108 \n\ 00109 \n\ 00110 \n\ 00111 Class Module/DuplexLink \n\ 00112 \n\ 00113 \n\ 00114 Module/DuplexLink instproc init {} {\n\ 00115 $self instvar uplink_ downlink_\n\ 00116 set uplink_ [new Module/Link]\n\ 00117 set downlink_ [new Module/Link]\n\ 00118 }\n\ 00119 \n\ 00120 Module/DuplexLink instproc delay {del} {\n\ 00121 $self instvar uplink_ downlink_\n\ 00122 $uplink_ delay $del\n\ 00123 $downlink_ delay $del\n\ 00124 }\n\ 00125 \n\ 00126 Module/DuplexLink instproc bandwidth {bw} {\n\ 00127 $self instvar uplink_ downlink_\n\ 00128 $uplink_ bandwidth $bw\n\ 00129 $downlink_ bandwidth $bw \n\ 00130 }\n\ 00131 \n\ 00132 Module/DuplexLink instproc qsize {qs} {\n\ 00133 $self instvar uplink_ downlink_\n\ 00134 $uplink_ qsize $qs\n\ 00135 $downlink_ qsize $qs\n\ 00136 }\n\ 00137 \n\ 00138 Module/DuplexLink instproc connect {node1 mod1 verb1 node2 mod2 verb2} {\n\ 00139 $self instvar uplink_ downlink_\n\ 00140 $uplink_ connect $node1 $mod1 $verb1 $node2 $mod2 $verb2\n\ 00141 $downlink_ connect $node2 $mod2 $verb2 $node1 $mod1 $verb1\n\ 00142 }\n\ 00143 \n\ 00144 Module/DuplexLink instproc settags {tagprefix} {\n\ 00145 $self instvar downlink_ uplink_\n\ 00146 $uplink_ settag ${tagprefix}up\n\ 00147 $downlink_ settag ${tagprefix}dw\n\ 00148 }\n\ 00149 \n\ 00150 Module/DuplexLink instproc addErrorModel {em} {\n\ 00151 puts \"Currently you cannot add an error model to a Module/DuplexLink\"\n\ 00152 puts \"Please use two instances of Module/Link and add a module to each.\"\n\ 00153 exit 0\n\ 00154 }\n\ 00155 \n\ 00156 \n\ 00157 \n\ 00158 "; 00159 #include "tclcl.h" 00160 EmbeddedTcl InitTclCode(code);