Skip to content
Daniel Zappala edited this page Mar 19, 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.

To create a Node, call:

Node(hostname='n1')

The hostname argument provides a name to identify the node. There is currently no functionality similar to DNS that provides mapping of host names to addresses.

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 receive_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

When the send_packet() method is called on a node, it forwards the packet based on the packet's destination address and the node's forwarding table. When the node's receive_packet() method is called, it first uses the destination address to determine if the packet belongs to this node, and if so, the receive_packet() method is called on upper layer protocol, based on the protocol field in the packet. If the packet is being sent toward some other destination, the node decrements the TTL of the packet and drops the packet if the TTL has reached zero. Finally, the node forwards the packet toward its destination.

Clone this wiki locally