-
Notifications
You must be signed in to change notification settings - Fork 18
Links
A link represents a unidirectional connection between two nodes in the network simulation. It contains an address, a starting node, and an ending node. In addition, the link specifies a maximum queue length, bandwidth, and propagation delay.
To create a link, call:
Link(address,startpoint,endpoint,queue_size,bandwidth,propagation,loss)
The address is an integer, and the startpoint and endpoint are node objects. The queue size is given in terms of packets, the bandwidth in terms of bits per second, and the propagation delay in terms of seconds. The loss rate is a floating point number between 0 and 1, representing the percent of random packet loss.
The link includes methods to bring the link down (it has failed) or up (it has recovered). To use these methods, schedule an event:
Sim.scheduler.add(delay=1, event=None, handler=n1.links[0].down)
Sim.scheduler.add(delay=2, event=None, handler=n1.links[0].up)
When the send_packet() method is called on a link, it checks if there is room in the link queue. If the queue is full, the packet is dropped. The link also simulates any random loss, if specified. Otherwise, the link checks if it is busy transmitting a packet, and if so it adds the packet to its queue. Finally, if the link is idle, it transmits the packet on the link. It does this by computing the time the packet will arrive at the other end of the link and scheduling an event for this arrival time. It also schedules an event when the link will no longer be empty, so that it can transmit the next packet.