以下の投稿を参照して、クロスレイヤ設計をしており、コーディングでわからない点があるので投稿させていただきます。
http://simweb.kke.co.jp/qualnet/forum/modules/newbb/viewtopic.php?topic_id=360&forum=29まず、現状のコーディングについて
1.Message構造体にNetworkレイヤのヘッダポインタを格納するフィールドを追加
struct message_str
{
Message* next; // For kernel use only.
...
// Users should not modify anything above this line.
void *network_hdr // Newly added
};
2.AODVのHELLOパケットのヘッダポインタを格納(routing_aodv.cpp)
static void AodvBroadcastHelloMessage(Node* node, AodvData* aodv, Address* destAddr)
{
IPv6Data *ipv6 = (IPv6Data *) node->networkData.networkVar->ipv6;
…
int pktSize = sizeof(AodvRrepPacket)+sizeof(他の型)*listsize;(sizeof(他の型)*listsizeは、可変長のリスト)// Newly added
…
pktPtr += sizeof(AodvRrepPacket);// Newly added
{
rrepPkt = (AodvRrepPacket *) pktPtr;
rrepPkt->typeBitsPrefixSizeHop = typeBitsPrefixSizeHop;
rrepPkt->sourceAddr = ANY_IP;
rrepPkt->destination.seqNum = aodv->seqNumber;
rrepPkt->lifetime = lifetime;
他の型 plus_info;// Newly added
memcpy(pktPtr, &plus_info, sizeof(他の型));// Newly added
pktPtr += sizeof(他の型);// Newly added
}
…
clocktype delay =
(clocktype) AODV_PC_ERAND(aodv->aodvJitterSeed);
…
newMsg->network_hdr = (char*) MESSAGE_ReturnPacket(newMsg);// Newly added
…
MESSAGE_Free(node, newMsg);// Newly added 箇所?
…
}
*HELLOの受信側でもplus_info情報をテーブルに利用しています。
3.受信したノードのMAC層で情報を利用(mac_802_11.cpp)
void Mac802_11ReceivePacketFromPhy(
Node* node,
MacData802_11* M802,
Message* msg)
{
…
else if (hdr->destAddr == ANY_DEST) {
switch (hdr->frameType) {
case M802_11_DATA:
case M802_11_CF_DATA_ACK: {
AodvRrepPacket* helloPkt = (AodvRrepPacket*)msg->network_hdr;; // Newly added
printf("MAC : hello packet source %d|%d received %d\n",helloPkt->helloSource.address,sourceNodeAddress,node->nodeId);// Newly added 箇所?
printf("current msg = %d\n",M802->currentMessage->network_hdr);// Newly added 箇所?
*Mac802_11UpdateDirectionCacheWithCurrentSignal()関数でソースノード以外のノードもplus_info情報を用いて更新しています。
以上のような感じでコーディングをしており、箇所?で出力内容を確認すると、ソースノードのアドレスが一致しませんでした。
そのため、箇所?の出力を確認することで、現在処理されているメッセージと比較を試みましたが、
セグメンテーション違反になってしまいました。
どのようにすれば、箇所?でのソースノードアドレスの一致ができるようになるのでしょうか?
箇所?のFREEによる問題でしょうか?
ご指導お願いします。
実行の出力では、シミュレーション時間が戻ってしまうこともありました。
Current Sim Time[s] = 2.428660435 Real Time[s] = 0 Completed 21%
Current Sim Time[s] = 2.428704603 Real Time[s] = 0 Completed 22%
Current Sim Time[s] = 2.429144603 Real Time[s] = 0 Completed 23%
Current Sim Time[s] = 0.720000000 Real Time[s] = 0 Completed 24%
Current Sim Time[s] = 0.750000000 Real Time[s] = 0 Completed 25%
Current Sim Time[s] = 0.780000000 Real Time[s] = 0 Completed 26%
Current Sim Time[s] = 0.810000000 Real Time[s] = 0 Completed 27%
Current Sim Time[s] = 0.840000000 Real Time[s] = 0 Completed 28%
Current Sim Time[s] = 0.870000000 Real Time[s] = 0 Completed 29%
Current Sim Time[s] = 0.900000000 Real Time[s] = 0 Completed 30%
Current Sim Time[s] = 0.930000000 Real Time[s] = 0 Completed 31%
Current Sim Time[s] = 0.960000000 Real Time[s] = 0 Completed 32%
Current Sim Time[s] = 0.990000000 Real Time[s] = 0 Completed 33%
Current Sim Time[s] = 1.020000000 Real Time[s] = 0 Completed 34%
Current Sim Time[s] = 1.050000000 Real Time[s] = 0 Completed 35%
Current Sim Time[s] = 1.080000000 Real Time[s] = 0 Completed 36%