我是Castalia的新手,并尝试通过多路径环路由(在Casting 3.2中使用oment 4.6)进行以下操作
据我了解,环形路由总是将数据广播到所有节点,并且任何级别<发送方节点级别的节点都将接受该消息并进行处理。我想做的是
1-要有一个路由表,以便我可以根据来自发送方的下一级节点的剩余能量来决定将数据发送到哪个节点
在哪里可以添加这段代码?通过修改dst变量?在此功能中
void MyRouting::fromApplicationLayer(cPacket * pkt, const char *destination)
{
string dst(destination);
............////Remaining PART Of CODE
}
或fromMacLayer方法中的BROADCAST_MAC_ADDRESS
void MyRouting::fromMacLayer(cPacket * pkt, int macAddress, double rssi, double lqi)
{
.....////STARTING PART Of CODE
case MPRINGS_DATA_PACKET:{
string dst(netPacket->getDestination());
string src(netPacket->getSource());
int senderLevel = netPacket->getSenderLevel();
int sinkID = netPacket->getSinkID();
if (dst.compare(BROADCAST_NETWORK_ADDRESS) == 0 ||
dst.compare(SELF_NETWORK_ADDRESS) == 0) {
// We are not filtering packets that are sent to this node directly or to
// broadcast network address, making application layer responsible for them
toApplicationLayer(pkt->decapsulate());
} else if (dst.compare(SINK_NETWORK_ADDRESS) == 0) {
if (senderLevel == currentLevel + 1) {
if (self == sinkID) {
// Packet is for this node, if filter passes, forward it to application
if (isNotDuplicatePacket(pkt))
toApplicationLayer(decapsulatePacket(pkt));
else
trace() << "Discarding duplicate packet from node " << src;
} else if (sinkID == currentSinkID) {
// We want to rebroadcast this packet since we are not its destination
// For this, a copy of the packet is created and sender level field is
// updated before calling toMacLayer() function
MyRoutingPacket *dupPacket = netPacket->dup();
dupPacket->setSenderLevel(currentLevel);
//****to call find the best destination to send to it
toMacLayer(dupPacket, BROADCAST_MAC_ADDRESS);
}
}
.....////Renaming PART Of CODE
}
2-我想以某种方式搜索并知道所有级别= mycurrent level -1的节点,因此我可以循环搜索以找到具有最大重命名能量的节点以将数据发送给它。我如何知道其他级别的节点?
注意: 我正在根据以下配置运行
[General]
include ../Parameters/Castalia.ini
sim-time-limit = 100s
include ../Parameters/SensorDevice/Accelerometer.ini
SN.physicalProcessName = "CarsPhysicalProcess"
SN.physicalProcess[*].car_interarrival = 5
SN.node[0].Application.isSink = true
SN.node[*].Application.reportDestination = "SINK"
[Config m100Bridge]
SN.field_x = 100
SN.field_y = 20
SN.deployment = "[0]->center;[1..18]->6x3"
SN.numNodes = 19
SN.physicalProcess[0].point1_x_coord = 0
SN.physicalProcess[0].point1_y_coord = 10
SN.physicalProcess[0].point2_x_coord = 100
SN.physicalProcess[0].point2_y_coord = 10
[Config myMAC]
SN.node[*].Communication.MACProtocolName = "BaselineBANMac"
SN.node[*].Communication.MAC.phyDataRate = 1024
SN.node[0].Communication.MAC.isHub = true
SN.node[*].Communication.MAC.macBufferSize = 48
[Config myWirelessChannel]
SN.wirelessChannel.pathLossMapFile = "../Parameters/WirelessChannel/BANmodels/pathLossMap.txt"
SN.wirelessChannel.temporalModelParametersFile = "../Parameters/WirelessChannel/BANmodels/TemporalModel.txt"
[Config myRadioChannel]
SN.node[*].Communication.Radio.RadioParametersFile = "../Parameters/Radio/BANRadio.txt"
SN.node[*].Communication.Radio.symbolsForRSSI = 16
SN.node[*].Communication.Radio.TxOutputPower = "-15dBm"
[Config myApp]
#***************** to calculate the delay in MyApplication
SN.node[*].ApplicationName = "BridgeTest"
SN.node[*].Application.startupDelay = 1 #wait for 1sec before starting sending packets
SN.node[0].Application.latencyHistogramMax = 600 # Max delay(Bounded delay in msec)
SN.node[0].Application.latencyHistogramBuckets = 30 # number of histograms
SN.node[*].Application.packet_rate = 5
SN.node[*].Application.collectTraceInfo = true
#*******************************************************
[Config myRouting]
SN.node[*].Communication.RoutingProtocolName = "MultipathRingsRouting"
SN.node[*].Communication.Routing.collectTraceInfo = true