Discussion:
How to send multiple packets on aodv.
non
2018-12-08 01:08:27 UTC
Permalink
Dear. ns3-Users.

I use aodv protocol on ns3.
And I would like to send multiple packets at the same time.
But it can be only *one* packet.
Why...

Would you help me?

------------------Code------------------
void
NetSim::ConfigureL4withDUPApp(uint32_t src, uint32_t dst)
{
NS_LOG_FUNCTION(this);

TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");

// set sender(10.1.1.25)'s socket
Ptr<Socket> destination = Socket::CreateSocket (n[dst], tid);
InetSocketAddress dstSocketAddr = setSocketAddress (n[dst], 8888);
destination->Bind (dstSocketAddr);
destination->SetRecvCallback (MakeCallback (&NetSim::ReceivePacket, this));

// set sender(10.1.1.1)'s socket
Ptr<Socket> source = Socket::CreateSocket (n[src], tid);
InetSocketAddress srcSocketAddr = setSocketAddress (n[src], 8888);
source->Bind (srcSocketAddr);
source->SetAllowBroadcast (true);
source->Connect (dstSocketAddr);

// set sender(10.1.1.14)'s socket
Ptr<Socket> source2 = Socket::CreateSocket (n[13], tid);
InetSocketAddress srcSocketAddr2 = setSocketAddress (n[13], 8888);
source2->Bind (srcSocketAddr2);
source2->SetAllowBroadcast (true);
source2->Connect (dstSocketAddr);


Time interPacketInterval = Seconds (interval);
// Give Proactive algorithms some time to converge -- 20 seconds perhaps
Simulator::Schedule (Seconds (20.0), &NetSim::GenerateTraffic, this,
source, interPacketInterval);
Simulator::Schedule (Seconds (20.0), &NetSim::GenerateTraffic,
this, source2, interPacketInterval);
}
....

void
NetSim::GenerateTraffic (Ptr<Socket> socket, Time pktInterval)
{
NS_LOG_FUNCTION(this);
std::string message = "Temperature:30degree";
std::string message2 = "Information:other";

if (numPackets > 0) {
std::ostringstream msg;
msg << message << '\0';
uint16_t packetSize = msg.str().length()+1;
Ptr<Packet> p0 = Create<Packet>((uint8_t*) msg.str().c_str(),
packetSize);

socket->Send (p0);

Simulator::Schedule (pktInterval, &NetSim::GenerateTraffic, this, socket,
pktInterval);
totalSent ++;
numPackets --;
} else {
socket->Close ();
}
}


-----------------------Output----------------------------

node:10.1.1.25; received 22 bytes from: (10.1.1.1, 8888)

↑why is it only one packet?

Thank you.
--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+***@googlegroups.com.
To post to this group, send email to ns-3-***@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
Loading...