Hello Everyone,
I'm a newbie to NS3. I'm trying to create multiple clients and a single server, where the multiple clients are created in node0 and a server is established at node1. For this, I've created two UDP packet sink at differtn ports and two UDP sockets to generate traffic at node0. I'm starting both the clients at 1.0 second (I also tried startin at 1.0 and 1.1 second). But the packets of client1 and client 2 are enqueued at 1.00 and 2.00 seconds, where I'm expecting one followed by other in 1.00 seconds itself. I'm doing this inorder to create once socket with high priority and another socket with low priority to schedule using prio queue scheduler. Following is my code snippet, can someone let me know where I'm doing wrong. Thanks in Advance!
uint32_t ipTos = 0;
uint32_t ipTos_1 = 0;
uint32_t payloadSize = 100;
uint32_t maxBytes = 100*2;
Address localAddress (InetSocketAddress ("10.1.1.2", 4477));
PacketSinkHelper packetSinkHelper ("ns3::UdpSocketFactory", localAddress);
ApplicationContainer sinkApp = packetSinkHelper.Install (p2pNodes.Get (1));
sinkApp.Start (Seconds (0.0));
sinkApp.Stop (Seconds (10 + 0.1));
Address localAddress_1 (InetSocketAddress ("10.1.1.2", 4478));
PacketSinkHelper packetSinkHelper_1 ("ns3::UdpSocketFactory", localAddress_1);
sinkApp = packetSinkHelper_1.Install (p2pNodes.Get (1));
sinkApp.Start (Seconds (0.1));
sinkApp.Stop (Seconds (10 + 0.1));
Config::Connect ("/NodeList/1/ApplicationList/*/$ns3::PacketSink/Rx",MakeCallback (&RxCallback));
InetSocketAddress destAddress ("10.1.1.2", 4477);
//destAddress.SetTos (ipTos);
OnOffHelper onoff ("ns3::UdpSocketFactory", destAddress);
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
onoff.SetAttribute ("DataRate", StringValue ("1Mbps")); //bit/s
onoff.SetAttribute ("MaxBytes", UintegerValue (maxBytes));
TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
Ptr<Socket> source = Socket::CreateSocket (p2pNodes.Get (0), tid);
source->Bind (destAddress);
source->SetIpTos (ipTos);
source->Connect(destAddress);
sinkApp.Add (onoff.Install (p2pNodes.Get (0)));
sinkApp.Start (Seconds (1.0));
sinkApp.Stop (Seconds (10 + 0.1));
InetSocketAddress destAddress_1 ("10.1.1.2", 4478);
//destAddress_1.SetTos (ipTos_1);
OnOffHelper onoff_1 ("ns3::UdpSocketFactory", destAddress_1);
onoff_1.SetAttribute ("PacketSize", UintegerValue (payloadSize));
onoff_1.SetAttribute ("DataRate", StringValue ("1Mbps")); //bit/s
onoff_1.SetAttribute ("MaxBytes", UintegerValue (maxBytes));
TypeId tid_1 = TypeId::LookupByName ("ns3::UdpSocketFactory");
Ptr<Socket> source_1 = Socket::CreateSocket (p2pNodes.Get (0), tid_1);
source_1->Bind (destAddress_1);
source_1->SetIpTos (ipTos_1);
source_1->Connect(destAddress_1);
sinkApp.Add (onoff_1.Install (p2pNodes.Get (0)));
sinkApp.Start (Seconds (1.1));
sinkApp.Stop (Seconds (10 + 0.1));
OUTPUT:
/NodeList/0/DeviceList/1/TxQueue/EnqueueEnqueueTrace Time: +1.1008e+09ns
/NodeList/0/DeviceList/1/TxQueue/DequeueDequeueTrace Time: +1.1008e+09ns
/NodeList/0/DeviceList/1/TxQueue/EnqueueEnqueueTrace Time: +1.1016e+09ns
/NodeList/0/DeviceList/1/TxQueue/DequeueDequeueTrace Time: +1.1016e+09ns
/NodeList/1/ApplicationList/0/$ns3::PacketSink/RxPacket Received at: Time: +1.10332e+09ns
/NodeList/1/ApplicationList/0/$ns3::PacketSink/RxPacket Received at: Time: +1.10412e+09ns
/NodeList/0/DeviceList/1/TxQueue/EnqueueEnqueueTrace Time: +2.1008e+09ns
/NodeList/0/DeviceList/1/TxQueue/DequeueDequeueTrace Time: +2.1008e+09ns
/NodeList/0/DeviceList/1/TxQueue/EnqueueEnqueueTrace Time: +2.1016e+09ns
/NodeList/0/DeviceList/1/TxQueue/DequeueDequeueTrace Time: +2.1016e+09ns
/NodeList/1/ApplicationList/1/$ns3::PacketSink/RxPacket Received at: Time: +2.10332e+09ns
/NodeList/1/ApplicationList/1/$ns3::PacketSink/RxPacket Received at: Time: +2.10412e+09ns