Defining rules in NS2?
by coder.acc from LinuxQuestions.org on (#5F119)
I want to define some protocols (communication rules) between nodes in NS2 and generate warnings in cases that exceed these rules. But I need help writing the following rules in TCL for NS2.
# Interval Rule:Sets the time limit between two consecutive messages. Its algoritm:
Determine the time limit between two consecutive packets (threshold)
If the consecutive packets sent by node A exceed the time limit, increase the counter corresponding to node A.
Generate a warning if Node A exceeds the threshold.
#Retransmission Rule: Determines whether a message to be transmitted is being transmitted by a node. Its algorithm:
Temporarily back up every packet that node A sends to node B.
If node B does not send the packet, increment the counter corresponding to node B; wipe the package from the buffer if it sends.
Generate an alert if node B drops more than %n of packets.
#Integrity rule:Indicates whether the original message has changed along the path between source and target nodes. Its algoritm:
Generate / use a verification (CRC) code for each packet sent from the source node.
Perform a CRC check on the packet arriving at the destination node.
If the CRC code does not match, increment the counter.
Generate a warning if the value of the counter exceeds the threshold.
#Repetition rule: The same message can be retransmitte dby the same neighbor only a limited number of times. Rule determines whether the retransmission number of a message by the neighboring node exceeds the limit. Its algoritm:
Set a threshold for the number of retransmissions of packets.
After a node transmits a packet, increase the number of retransmissions by one.
Generate a warning if the node retransmits the same packet exceeds the threshold.
#Radio transmission range rule:It detects whether the incoming packets come from the neighbor node. Its algoritm:
Node A must be in the same cluster to send packets to node B.
If the packet sent by the node is not to the next hop (next hop), increment the counter by one.
Generate a warning if the value of the counter exceeds a certain threshold value.
#Jamming rule: Determines whether the collision number of messages sent by the monitoring node exceeds the expected limit. Its algoritm:
Set an upper limit for the expected number of collisions in the network.
Generate a warning if the number of collisions in the transmission channel exceeds the upper limit.
Thanks...


# Interval Rule:Sets the time limit between two consecutive messages. Its algoritm:
Determine the time limit between two consecutive packets (threshold)
If the consecutive packets sent by node A exceed the time limit, increase the counter corresponding to node A.
Generate a warning if Node A exceeds the threshold.
#Retransmission Rule: Determines whether a message to be transmitted is being transmitted by a node. Its algorithm:
Temporarily back up every packet that node A sends to node B.
If node B does not send the packet, increment the counter corresponding to node B; wipe the package from the buffer if it sends.
Generate an alert if node B drops more than %n of packets.
#Integrity rule:Indicates whether the original message has changed along the path between source and target nodes. Its algoritm:
Generate / use a verification (CRC) code for each packet sent from the source node.
Perform a CRC check on the packet arriving at the destination node.
If the CRC code does not match, increment the counter.
Generate a warning if the value of the counter exceeds the threshold.
#Repetition rule: The same message can be retransmitte dby the same neighbor only a limited number of times. Rule determines whether the retransmission number of a message by the neighboring node exceeds the limit. Its algoritm:
Set a threshold for the number of retransmissions of packets.
After a node transmits a packet, increase the number of retransmissions by one.
Generate a warning if the node retransmits the same packet exceeds the threshold.
#Radio transmission range rule:It detects whether the incoming packets come from the neighbor node. Its algoritm:
Node A must be in the same cluster to send packets to node B.
If the packet sent by the node is not to the next hop (next hop), increment the counter by one.
Generate a warning if the value of the counter exceeds a certain threshold value.
#Jamming rule: Determines whether the collision number of messages sent by the monitoring node exceeds the expected limit. Its algoritm:
Set an upper limit for the expected number of collisions in the network.
Generate a warning if the number of collisions in the transmission channel exceeds the upper limit.
Thanks...