public abstract class Router
extends java.lang.Object
initialize()
and
process_routing_message(RoutingMessage,int)
methods.Network
Constructor | Description |
---|---|
Router() |
Modifier and Type | Method | Description |
---|---|---|
void |
clear_forwarding_entry(int address) |
removes a forwarding-table mapping.
|
void |
clear_forwarding_table() |
clears the forwarding-table completely.
|
protected double |
current_time() |
current time in the network.
|
abstract void |
initialize() |
router initialization method.
|
protected int |
interfaces() |
number of interfaces of this router.
|
protected double |
link_cost(int i) |
cost of the link connected to the i-th interface.
|
protected int |
my_address() |
address of this node.
|
protected void |
print_debug(java.lang.String msg) |
prints a debugging message.
|
protected void |
print_error(java.lang.String msg) |
prints an error message.
|
void |
process_event(simplenet.Event e) |
|
abstract void |
process_routing_message(RoutingMessage m,
int incoming_interface) |
entry method for the routing protocol.
|
protected void |
send_message(Message m,
int i) |
send a message to the i-th interface (neighbor).
|
void |
set_forwarding_entry(int address,
int ifx) |
defines a forwarding-table mapping.
|
protected final int interfaces()
protected final int my_address()
protected final double link_cost(int i)
Notice that the index of the first
interface is 0, and that of the last interface is
interfaces() - 1
.
interfaces()
protected final double current_time()
protected final void send_message(Message m, int i)
For example,
class MyMessage implements {
String msg;
public MyMessage(String m) {
msg = m;
}
}
// ...
MyMessage
for(int i = 0; i < interfaces(); ++i) {
send_message(neighbor_address() " is my neighbor.");
}
m
- message to be sent.i
- number of the outgoing interface (starting from 0).link_cost(int)
public final void process_event(simplenet.Event e)
public abstract void process_routing_message(RoutingMessage m, int incoming_interface)
public abstract void initialize()
public final void set_forwarding_entry(int address, int ifx)
address
, it must set the
appropriate mapping in its forwarding table. If, for example,
the best path to address
goes through interface
i
, then the router must execute:
set_forwarding_entry(address, i);
address
- destinationifx
- next-hop interface on the best path to
address
public final void clear_forwarding_entry(int address)
address
- destinationpublic final void clear_forwarding_table()
protected final void print_debug(java.lang.String msg)
print_debug("ciao");
might produce the following output:
102.5: n7: ciao
These debugging messages are visible only if the simulation is
started with the -d
option.Network
,
print_error(String)
protected final void print_error(java.lang.String msg)
-d
option.Network
,
print_debug(String)