Ich habe eine Klasse ns3
und wenn Sie es halten ich den Fehler bekommen:Wiederholte Fehler trotz korrekter Namespace
../scratch/seven.cc: In function ‘int main(int, char**)’:
../scratch/seven.cc:102:3: error: ‘RandomAppHelper’ was not declared in this scope
RandomAppHelper source = RandomAppHelper ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address ("192.168.1.10"), 10));
^
../scratch/seven.cc:103:3: error: ‘source’ was not declared in this scope
source.SetAttribute ("Delay", StringValue ("Constant:2.5"));
^
Der Code dafür ist hier: https://www.nsnam.org/docs/release/3.3/doxygen/application.html
Ich kann den Fehler nicht beheben . Ich habe die korrekte namespace
ns3
im Code verwendet. Da der Fehler "nicht im Umfang deklariert" ist, bin ich mir nicht sicher, wie ich das beheben soll.
Hier ist meine Umsetzung der Hilfsklasse (die ich benutze):
#include "ns3/log.h"
#include "ns3/address.h"
#include "ns3/node.h"
#include "ns3/nstime.h"
#include "ns3/socket.h"
#include "ns3/simulator.h"
#include "ns3/socket-factory.h"
#include "ns3/packet.h"
#include "ns3/uinteger.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/tcp-socket-factory.h"
#include "random-helper.h"
namespace ns3{
RandomAppHelper::RandomAppHelper (std::string protocol, Address remote)
{
m_factory.SetTypeId ("ns3::MpTcpBulkSendApplication");
m_factory.Set ("Protocol", StringValue (protocol));
m_factory.Set ("Remote", AddressValue (remote));
}
void
RandomAppHelper::SetAttribute (std::string name, const AttributeValue &value)
{
m_factory.Set (name, value);
}
ApplicationContainer
RandomAppHelper::Install (Ptr<Node> node) const
{
return ApplicationContainer (InstallPriv (node));
}
ApplicationContainer
RandomAppHelper::Install (std::string nodeName) const
{
Ptr<Node> node = Names::Find<Node> (nodeName);
return ApplicationContainer (InstallPriv (node));
}
ApplicationContainer
RandomAppHelper::Install (NodeContainer c) const
{
ApplicationContainer apps;
for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
{
apps.Add (InstallPriv (*i));
}
return apps;
}
Ptr<Application>
RandomAppHelper::InstallPriv (Ptr<Node> node) const
{
Ptr<Application> app = m_factory.Create<Application>();
node->AddApplication (app);
return app;
}
}
Diese Klasse im Anwendungsordner von ns3 definiert, die enthalten ist, über den anwendungs module.h umfassen. Und in meinem Code habe ich es an der Stelle, wo ich den RandomAppHelper verwende.
Das scheint keine Standard-Klasse zu sein, sondern eine Hilfsklasse, die Sie selbst definieren und implementieren müssen. –
Ich habe ein bisschen mehr Erklärung hinzugefügt. Porque-Downvote? –
@JoachimPileborg natürlich habe ich es selbst definiert und umgesetzt. –