问题
I'm newbie with ns3. i wanted to simulate a vanet network with two nodes, in which a node send periodically (each 0.1 second) wsmp packet on the CCH channel. i used the code : wave-simple-device.cc and i did some modification in the following function:
'''
void
WaveNetDeviceExample::SendOneWsmpPacket (uint32_t channel, uint32_t seq)
{
Ptr<WaveNetDevice> sender = DynamicCast<WaveNetDevice> (devices.Get (0));
Ptr<WaveNetDevice> receiver = DynamicCast<WaveNetDevice> (devices.Get (1));
const static uint16_t WSMP_PROT_NUMBER = 0x88DC;
Mac48Address bssWildcard = Mac48Address::GetBroadcast ();
const TxInfo txInfo = TxInfo (channel);
Ptr<Packet> p = Create<Packet> (100);
SeqTsHeader seqTs;
seqTs.SetSeq (seq);
p->AddHeader (seqTs);
sender->SendX (p, bssWildcard, WSMP_PROT_NUMBER, txInfo);
}
void
WaveNetDeviceExample::SendWsmpExample ()
{
CreateWaveNodes ();
Ptr<WaveNetDevice> sender = DynamicCast<WaveNetDevice> (devices.Get (0));
Ptr<WaveNetDevice> receiver = DynamicCast<WaveNetDevice> (devices.Get (1));
// Alternating access without immediate channel switch
const SchInfo schInfo = SchInfo (SCH1, false, EXTENDED_ALTERNATING);
Simulator::Schedule (Seconds (0.0),
&WaveNetDevice::StartSch,sender,schInfo);
// An important point is that the receiver should also be assigned channel
// access for the same channel to receive packets.
Simulator::Schedule (Seconds (0.0), &WaveNetDevice::StartSch, receiver, schInfo);
// send WSMP packets
// the first packet will be queued currently and be transmitted in next SCH interval
Simulator::Schedule (Seconds (1.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, SCH1, 1);
// the second packet will be queued currently and then be transmitted , because of in the CCH interval.
Simulator::Schedule (Seconds (1.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, CCH, 2);
// the third packet will be dropped because of no channel access for SCH2.
Simulator::Schedule (Seconds (1.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, SCH2, 3);
// release SCH access
Simulator::Schedule (Seconds (2.0), &WaveNetDevice::StopSch, sender, SCH1);
Simulator::Schedule (Seconds (2.0), &WaveNetDevice::StopSch, receiver, SCH1);
// the fourth packet will be queued and be transmitted because of default CCH access assigned automatically.
Simulator::Schedule (Seconds (3.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, CCH, 4);
// the fifth packet will be dropped because of no SCH1 access assigned
Simulator::Schedule (Seconds (3.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, SCH1, 5);
Simulator::Stop (Seconds (5.0));
Simulator::Run ();
Simulator::Destroy ();
}
'''
to send the wsmp packet periodically, i tried to use a loop in here:
for(...){
sender->SendX (p, bssWildcard, WSMP_PROT_NUMBER, txInfo);
sleep(0.1s);
}
However, to many errors appear.
Second, to send this wsmp packet on the CCH channel instead of SSh .. i didn't found any clear tutoriel ? any help please ? Thanks in advance
来源:https://stackoverflow.com/questions/58792744/ns3-how-to-send-wsmp-packets-in-vanet-periodically-through-the-cch-channel-w