Mehic.info

Category Archives: ns3

Add and read content to Packet payload in NS3

To add content to packet payload you can use following commands: std::ostringstream msg; msg << “Hello World!” << ‘\0’; Ptr<Packet> packet = Create<Packet> ((uint8_t*) msg.str().c_str(), msg.str().length()); To read content from packet payload: uint8_t *buffer = new uint8_t[packet->GetSize ()]; packet->CopyData(buffer, packet->GetSize ()); std::string s = std::string((char*)buffer);

Read more

NS3 – undefined reference to..

I received following bug when I tried to install new module and build NS3 : ./libns3.22-network-debug.so: undefined reference to `ns3::Queue::IsFull() const’ collect2: error: ld returned 1 exit status The problem was that my point-to-point-net-device.cc was calling function return !(m_queue->IsFull ()); which was not implemented in src/networking/utils/queue.cc. The function was declared in queue.h as virtual but […]

Read more

How to print routing tables of DSDV in NS3?

Open “src/dsdv/model/dsdv-routing-protocol.h” and add  “Ptr routingStream;” in public attributes: class RoutingProtocol : public Ipv4RoutingProtocol { public: …. virtual void DoDispose (); Ptr routingStream; … Then in “src/dsdv/model/dsdv-routing-protocol.cc” at line 250 add the new function: void RoutingProtocol::PrintRoutingTable (Ptr stream) const { *stream->GetStream () GetId ()

Read more

How to install Netanim in NS3

For this tutorial, I assume that you already have installed NS3 on your ubuntu machine. If you installed NS3 withe examples and other components, than you should see in your root NS3 folder netanim directory: /home/mickey/ns3_git/qkd-routing/ns-allinone-3.22# ls bake build.py constants.py constants.pyc netanim-3.105 ns-3.22 pybindgen-0.17.0.886 README util.py util.pyc Now, go to your netanim directory and execute: […]

Read more