Inheritance diagram for Node::

Public Methods | |
| Node () | |
| Node (String name) | |
| void | receive (Object packet) |
| void | updateRoutingTable () |
| void | transmitAll () |
| void | attach (LineEnd line_end, Node other_node) |
| void | detach (LineEnd line_end) |
| void | delete () |
| void | detach (Node other_node) |
| RIPTable | getRIPTable () |
| void | setCoordinates (int x, int y) |
| String | getName () |
| int | getXCoordinate () |
| int | getYCoordinate () |
| void | setXCoordinate (int x) |
| void | getYCoordinate (int y) |
| void | paint (Graphics g, FontMetrics metrics, Color fill_color) |
Public Attributes | |
| RIPTable | routing_table |
Protected Attributes | |
| String | name |
| int | x_position = 20 |
| int | y_position = 20 |
| NodeQueue | receive_buffer = new NodeQueue() |
| Vector | connecting_lines = new Vector() |
| Vector | connecting_nodes = new Vector() |
Definition at line 18 of file Node.java.
|
|
Empty constructor. Creates completly isolated node. Definition at line 47 of file Node.java. 00048 {
00049 name = "Izolirani cvor";
00050 x_position = (int)(50 + 200 * Math.random());
00051 y_position = (int)(50 + 200 * Math.random());
00052 this.routing_table = new RIPTable(this);
00053 }
|
|
|
Normal constructor. Creates named node. All nodes should have differen names.
Definition at line 61 of file Node.java. 00062 {
00063 x_position = (int)(50 + 200 * Math.random());
00064 y_position = (int)(50 + 200 * Math.random());
00065 this.name = name;
00066 this.routing_table = new RIPTable(this);
00067 }
|
|
|
Attach line end.
Definition at line 150 of file Node.java. Referenced by Line::Line().
00151 {
00152 connecting_lines.addElement(line_end);
00153 connecting_nodes.addElement(other_node);
00154 routing_table.addElement(other_node, other_node, 1);
00155 }
|
|
|
Deletes node. Definition at line 181 of file Node.java. Referenced by CyclopsSimulator::deleteNode().
|
|
|
Detach node.
Definition at line 197 of file Node.java. 00198 {
00199 int index;
00200
00201 index = connecting_nodes.indexOf(other_node);
00202 if (0 <= index)
00203 {
00204 connecting_lines.removeElementAt(index);
00205 connecting_nodes.removeElementAt(index);
00206 routing_table.setCostToInfinity(other_node);
00207 }
00208 }
|
|
|
Detach line end.
Definition at line 162 of file Node.java. Referenced by Line::delete().
00163 {
00164 int index;
00165 Node node;
00166
00167 index = connecting_lines.indexOf(line_end);
00168 if (0 <= index)
00169 {
00170 connecting_lines.removeElementAt(index);
00171 node = (Node)connecting_nodes.elementAt(index);
00172 connecting_nodes.removeElementAt(index);
00173 routing_table.setCostToInfinity(node);
00174 }
00175 }
|
|
|
Gets node name.
Definition at line 237 of file Node.java. Referenced by CyclopsSimulator::deleteNode(), and CyclopsSimulator::findNode().
00238 {
00239 return this.name;
00240 }
|
|
|
Gets RIP table.
Definition at line 215 of file Node.java. Referenced by RIPTable::updateTable().
00216 {
00217 return routing_table;
00218 }
|
|
|
Gets x cooridnate.
Definition at line 247 of file Node.java. Referenced by NetworkSpacePanel::mousePressed(), and Line::paint().
00248 {
00249 return x_position;
00250 }
|
|
|
Sets y cooridnate.
Definition at line 277 of file Node.java. 00278 {
00279 y_position = y;
00280 }
|
|
|
Gets y cooridnate.
Definition at line 257 of file Node.java. Referenced by NetworkSpacePanel::mousePressed(), and Line::paint().
00258 {
00259 return y_position;
00260 }
|
|
|
Draws node on screen.
Definition at line 289 of file Node.java. Referenced by CyclopsSimulator::paint().
00290 {
00291 int w = metrics.stringWidth(this.name) + 10;
00292 int h = metrics.getHeight() + 4;
00293 g.setColor(fill_color);
00294 g.fillRect(x_position - w/2, y_position - h/2, w, h);
00295 g.setColor(Color.black);
00296 g.drawRect(x_position - w/2, y_position - h/2, w - 1, h - 1);
00297 g.drawString(this.name,
00298 x_position - (w - 10) / 2,
00299 y_position - (h - 4) / 2 + metrics.getAscent()
00300 );
00301 }
|
|
|
Receives one packet and stores it into a buffer.
Definition at line 74 of file Node.java. Referenced by CyclopsSimulator::addDummyPackets(), CyclopsSimulator::sendPacket(), and Line::transmitAll().
00075 {
00076 receive_buffer.put(packet);
00077 }
|
|
|
Sets screen coordinates.
Definition at line 226 of file Node.java. Referenced by NetworkSpacePanel::mouseDragged(), NetworkSpacePanel::mousePressed(), and NetworkSpacePanel::mouseReleased().
00227 {
00228 x_position = x;
00229 y_position = y;
00230 }
|
|
|
Sets x cooridnate.
Definition at line 267 of file Node.java. 00268 {
00269 x_position = x;
00270 }
|
|
|
Transmits all packages currently stored in output buffer. Definition at line 100 of file Node.java. Referenced by CyclopsSimulator::simulate().
00101 {
00102 int i;
00103 Packet packet;
00104 Node destination;
00105 Node next_node;
00106 LineEnd line;
00107
00108 while ( !receive_buffer.isEmpty() )
00109 {
00110 packet = (Packet)receive_buffer.get();
00111 destination = packet.getDestinationNode();
00112 if (destination == this)
00113 {
00114 /* Discard packet. */
00115 }
00116 else if (packet.hop() != 0)
00117 {
00118 next_node = routing_table.findNextNodeForRouteTo(destination);
00119 if (next_node == null)
00120 {
00121 i = (int)(Math.random()*connecting_lines.size());
00122 if (!connecting_lines.isEmpty())
00123 {
00124 line = (LineEnd)connecting_lines.elementAt(i);
00125 line.receive(packet);
00126 }
00127 }
00128 else
00129 {
00130 i = connecting_nodes.indexOf(next_node);
00131 if (i >= 0)
00132 {
00133 line = (LineEnd)connecting_lines.elementAt(i);
00134 line.receive(packet);
00135 }
00136 }
00137 /* else */
00138 }
00139 /* else if */
00140 }
00141 /* while */
00142 }
|
|
|
Updates routing table. Definition at line 83 of file Node.java. Referenced by CyclopsSimulator::simulate(), and CyclopsSimulator::topologyUpdate().
00084 {
00085 int i;
00086 Node other_node;
00087
00088 for (i=0; i<connecting_nodes.size(); i++)
00089 {
00090 other_node = (Node)connecting_nodes.elementAt(i);
00091 routing_table.updateTable(other_node);
00092 }
00093 routing_table.garbageCollect();
00094 }
|
|
|
List of all conecting lines. |
|
|
List of all connecting nodes. |
|
|
Node name. Every node should have one. |
|
|
Queue for all incoming packages. |
|
|
RIP table. |
|
|
x screen coordinate. |
|
|
y screen coordinate. |
1.2.7 written by Dimitri van Heesch,
© 1997-2001