|
|
| 17 |
*/ |
17 |
*/ |
| 18 |
#include "ns3/node.h" |
18 |
#include "ns3/node.h" |
| 19 |
#include "ns3/packet.h" |
19 |
#include "ns3/packet.h" |
|
|
20 |
#include "ns3/log.h" |
| 20 |
#include "ns3/simulator.h" |
21 |
#include "ns3/simulator.h" |
| 21 |
#include "ns3/node-container.h" |
22 |
#include "ns3/node-container.h" |
| 22 |
#include "ns3/net-device-container.h" |
23 |
#include "ns3/net-device-container.h" |
|
|
| 93 |
{ |
94 |
{ |
| 94 |
SeqTsHeader seqTs; |
95 |
SeqTsHeader seqTs; |
| 95 |
pkt->PeekHeader (seqTs); |
96 |
pkt->PeekHeader (seqTs); |
| 96 |
std::cout << "receive a packet: " << std::endl |
97 |
NS_LOG_UNCOND (" receive a packet: "); |
| 97 |
<< " sequence = " << seqTs.GetSeq () << "," << std::endl |
98 |
NS_LOG_UNCOND (" sequence = " << seqTs.GetSeq () << ","); |
| 98 |
<< " sendTime = " << seqTs.GetTs ().GetSeconds () << "s," << std::endl |
99 |
NS_LOG_UNCOND (" sendTime = " << seqTs.GetTs ().GetSeconds () << "s,"); |
| 99 |
<< " recvTime = " << Now ().GetSeconds () << "s," << std::endl |
100 |
NS_LOG_UNCOND (" recvTime = " << Now ().GetSeconds () << "s,"); |
| 100 |
<< " protocol = 0x" << std::hex << mode << std::dec << std::endl; |
101 |
NS_LOG_UNCOND (" protocol = 0x" << std::hex << mode << std::dec);; |
| 101 |
return true; |
102 |
return true; |
| 102 |
} |
103 |
} |
| 103 |
|
104 |
|
|
|
| 115 |
seqTs.SetSeq (seq); |
116 |
seqTs.SetSeq (seq); |
| 116 |
p->AddHeader (seqTs); |
117 |
p->AddHeader (seqTs); |
| 117 |
sender->SendX (p, bssWildcard, WSMP_PROT_NUMBER, txInfo); |
118 |
sender->SendX (p, bssWildcard, WSMP_PROT_NUMBER, txInfo); |
| 118 |
|
|
|
| 119 |
Ptr<Packet> p2 = Create<Packet> (100); |
| 120 |
SeqTsHeader seqTs2; |
| 121 |
seqTs2.SetSeq (seq + 1); |
| 122 |
p2->AddHeader (seqTs2); |
| 123 |
receiver->SendX (p2, bssWildcard, WSMP_PROT_NUMBER, txInfo); |
| 124 |
|
| 125 |
} |
119 |
} |
| 126 |
|
120 |
|
| 127 |
void |
121 |
void |
|
|
| 140 |
|
134 |
|
| 141 |
// send WSMP packets |
135 |
// send WSMP packets |
| 142 |
// the first packet will be queued currently and be transmitted in next SCH interval |
136 |
// the first packet will be queued currently and be transmitted in next SCH interval |
| 143 |
//Simulator::Schedule (Seconds (1.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, SCH1, 1); |
137 |
Simulator::Schedule (Seconds (1.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, SCH1, 1); |
| 144 |
// the second packet will be queued currently and then be transmitted , because of in the CCH interval. |
138 |
// the second packet will be queued currently and then be transmitted , because of in the CCH interval. |
| 145 |
Simulator::Schedule (Seconds (1.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, CCH, 2); |
139 |
Simulator::Schedule (Seconds (1.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, CCH, 2); |
| 146 |
// the third packet will be dropped because of no channel access for SCH2. |
140 |
// the third packet will be dropped because of no channel access for SCH2. |
| 147 |
//Simulator::Schedule (Seconds (1.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, SCH2, 3); |
141 |
Simulator::Schedule (Seconds (1.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, SCH2, 3); |
| 148 |
|
142 |
|
| 149 |
// release SCH access |
143 |
// release SCH access |
| 150 |
//Simulator::Schedule (Seconds (2.0), &WaveNetDevice::StopSch, sender, SCH1); |
144 |
Simulator::Schedule (Seconds (2.0), &WaveNetDevice::StopSch, sender, SCH1); |
| 151 |
//Simulator::Schedule (Seconds (2.0), &WaveNetDevice::StopSch, receiver, SCH1); |
145 |
Simulator::Schedule (Seconds (2.0), &WaveNetDevice::StopSch, receiver, SCH1); |
| 152 |
// the fourth packet will be queued and be transmitted because of default CCH access assigned automatically. |
146 |
// the fourth packet will be queued and be transmitted because of default CCH access assigned automatically. |
| 153 |
//Simulator::Schedule (Seconds (3.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, CCH, 4); |
147 |
Simulator::Schedule (Seconds (3.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, CCH, 4); |
| 154 |
// the fifth packet will be dropped because of no SCH1 access assigned |
148 |
// the fifth packet will be dropped because of no SCH1 access assigned |
| 155 |
//Simulator::Schedule (Seconds (3.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, SCH1, 5); |
149 |
Simulator::Schedule (Seconds (3.0), &WaveNetDeviceExample::SendOneWsmpPacket, this, SCH1, 5); |
| 156 |
|
150 |
|
| 157 |
Simulator::Stop (Seconds (5.0)); |
151 |
Simulator::Stop (Seconds (5.0)); |
| 158 |
Simulator::Run (); |
152 |
Simulator::Run (); |
|
|
| 216 |
bool |
210 |
bool |
| 217 |
WaveNetDeviceExample::ReceiveVsa (Ptr<const Packet> pkt,const Address & address, uint32_t, uint32_t) |
211 |
WaveNetDeviceExample::ReceiveVsa (Ptr<const Packet> pkt,const Address & address, uint32_t, uint32_t) |
| 218 |
{ |
212 |
{ |
| 219 |
std::cout << "receive a VSA management frame: recvTime = " << Now ().GetSeconds () << "s." << std::endl; |
213 |
NS_LOG_UNCOND ( " receive a VSA management frame: recvTime = " << Now ().GetSeconds () << "s."); |
| 220 |
return true; |
214 |
return true; |
| 221 |
} |
215 |
} |
| 222 |
|
216 |
|
|
|
| 257 |
main (int argc, char *argv[]) |
251 |
main (int argc, char *argv[]) |
| 258 |
{ |
252 |
{ |
| 259 |
WaveNetDeviceExample example; |
253 |
WaveNetDeviceExample example; |
| 260 |
std::cout << "run WAVE WSMP routing service case:" << std::endl; |
254 |
NS_LOG_UNCOND ("run WAVE WSMP routing service case:"); |
| 261 |
example.SendWsmpExample (); |
255 |
example.SendWsmpExample (); |
| 262 |
std::cout << "run WAVE IP routing service case:" << std::endl; |
256 |
NS_LOG_UNCOND ("run WAVE IP routing service case:"); |
| 263 |
//example.SendIpExample (); |
257 |
example.SendIpExample (); |
| 264 |
std::cout << "run WAVE WSA routing service case:" << std::endl; |
258 |
NS_LOG_UNCOND ("run WAVE WSA routing service case:"); |
| 265 |
//example.SendWsaExample (); |
259 |
example.SendWsaExample (); |
| 266 |
return 0; |
260 |
return 0; |
| 267 |
} |
261 |
} |