Skip to content
Daniel Zappala edited this page Jan 11, 2014 · 8 revisions

A node represents a host or a router in the network simulation. It contains a list of links, a set of protocol handlers, and a forwarding table. The main functions of the node are to (a) receive packets that are addressed to it and (b) forward packets that are destined for other nodes.

Links

add_link(link)
delete_link(link)

Adds or delete link for the node.

Protocols

add_protocol(protocol,handler)
delete_protocol(protocol):

Add or delete a protocol handler. A protocol is a string identifier and a handler is an object. When a packet arrives at its destination, the protocol field in the packet specifies which handler object should be called. The node calls the handle_packet() method on this object.

Forwarding Table

add_forwarding_entry(address,link)
delete_forwarding_entry(address,link)

Add or delete a forwarding entry for the node. The forwarding entry is given by an integer address, and specifies which link object should be used to reach that address.

Handling packets

By convention, any object can be given a packet to handle using its handle_packet() method. When the handle_packet() method is called on a node, it compares the packet's destination address to the address for each of its links. If a match is found, the packet belongs to this node, so the corresponding packet handler is called, based on the protocol field in the packet. If no match is found, the node uses the forwarding table to send the packet on the link that leads toward the packet's destination.

Clone this wiki locally