mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 10:03:58 +02:00
Use more accurate delay measurement with UdpServer
This commit is contained in:
parent
c1218039da
commit
b4eb471eb1
1 changed files with 14 additions and 20 deletions
|
@ -5,28 +5,20 @@
|
||||||
#include "ns3/leo-module.h"
|
#include "ns3/leo-module.h"
|
||||||
#include "ns3/network-module.h"
|
#include "ns3/network-module.h"
|
||||||
#include "ns3/aodv-module.h"
|
#include "ns3/aodv-module.h"
|
||||||
|
#include "ns3/udp-server.h"
|
||||||
|
|
||||||
using namespace ns3;
|
using namespace ns3;
|
||||||
|
|
||||||
NS_LOG_COMPONENT_DEFINE ("LeoDelayTracingExample");
|
NS_LOG_COMPONENT_DEFINE ("LeoDelayTracingExample");
|
||||||
|
|
||||||
Time t_start;
|
|
||||||
uint64_t send = 0;;
|
|
||||||
uint64_t received = 0;
|
|
||||||
|
|
||||||
static void
|
|
||||||
EchoTx (std::string context, Ptr<const Packet> packet)
|
|
||||||
{
|
|
||||||
send ++;
|
|
||||||
t_start = Simulator::Now ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
EchoRx (std::string context, Ptr<const Packet> packet)
|
EchoRx (std::string context, Ptr<const Packet> packet)
|
||||||
{
|
{
|
||||||
received ++;
|
SeqTsHeader seqTs;
|
||||||
Time now = Simulator::Now ();
|
Ptr<Packet> p = packet->Copy ();
|
||||||
std::cout << context << "," << (now - t_start) << std::endl;
|
p->RemoveHeader (seqTs);
|
||||||
|
// seqnr, timestamp, delay
|
||||||
|
std::cout << context << "," << seqTs.GetSeq () << "," << seqTs.GetTs () << "," << Simulator::Now () - seqTs.GetTs () << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
|
@ -91,22 +83,22 @@ int main (int argc, char *argv[])
|
||||||
Ipv4InterfaceContainer utIp = ipv4.Assign (utNet);
|
Ipv4InterfaceContainer utIp = ipv4.Assign (utNet);
|
||||||
|
|
||||||
// we want to ping terminals
|
// we want to ping terminals
|
||||||
UdpEchoServerHelper echoServer (9);
|
UdpServerHelper echoServer (9);
|
||||||
ApplicationContainer serverApps = echoServer.Install (stations.Get (1));
|
ApplicationContainer serverApps = echoServer.Install (stations.Get (1));
|
||||||
|
|
||||||
// install a client on one of the terminals
|
// install a client on one of the terminals
|
||||||
ApplicationContainer clientApps;
|
ApplicationContainer clientApps;
|
||||||
Address remote = stations.Get (1)->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();//utIp.GetAddress (1, 0);
|
Address remote = stations.Get (1)->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();//utIp.GetAddress (1, 0);
|
||||||
UdpEchoClientHelper echoClient (remote, 9);
|
UdpClientHelper echoClient (remote, 9);
|
||||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (360));
|
echoClient.SetAttribute ("MaxPackets", UintegerValue (360));
|
||||||
echoClient.SetAttribute ("Interval", TimeValue (Minutes (1.0)));
|
echoClient.SetAttribute ("Interval", TimeValue (Minutes (1.0)));
|
||||||
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
||||||
clientApps.Add (echoClient.Install (stations.Get (3)));
|
clientApps.Add (echoClient.Install (stations.Get (3)));
|
||||||
|
|
||||||
Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::UdpEchoClient/Rx",
|
Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::UdpServer/Rx",
|
||||||
MakeCallback (&EchoRx));
|
MakeCallback (&EchoRx));
|
||||||
Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::UdpEchoClient/Tx",
|
|
||||||
MakeCallback (&EchoTx));
|
std::cout << "Context,Sequence Number,Timestamp,Delay" << std::endl;
|
||||||
|
|
||||||
serverApps.Start (Seconds (1));
|
serverApps.Start (Seconds (1));
|
||||||
clientApps.Start (Seconds (2));
|
clientApps.Start (Seconds (2));
|
||||||
|
@ -115,7 +107,9 @@ int main (int argc, char *argv[])
|
||||||
Simulator::Run ();
|
Simulator::Run ();
|
||||||
Simulator::Destroy ();
|
Simulator::Destroy ();
|
||||||
|
|
||||||
std::cout << std::endl << received << "," << send << std::endl;
|
Ptr<UdpServer> server = StaticCast<UdpServer> (serverApps.Get (0));
|
||||||
|
std::cout << "Received,Lost" << std::endl
|
||||||
|
<< server->GetReceived () << "," << server->GetLost () << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue