2016-08-02 7 views
1

このns-3の例(first.cc)udp接続のスループットを計算するために、チェックされ、新しく追加された変数を定義し、実行した後、私はこのエラーを取得:ns-3でudpスループットを取得中に宣言エラーが発生しました

'serverAppは' このスコープ のuint32_t totalPacketsThrough =は、DynamicCast(serverApp.Get(1))で宣言されていなかった - > GetReceived();

#include "ns3/core-module.h" 
#include "ns3/network-module.h" 
#include "ns3/internet-module.h" 
#include "ns3/point-to-point-module.h" 
#include "ns3/applications-module.h" 

using namespace ns3; 

NS_LOG_COMPONENT_DEFINE ("FirstScriptExample"); 

int 
main (int argc, char *argv[]) 
{ 
    Time::SetResolution (Time::NS); 
    LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); 
    LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); 

    NodeContainer nodes; 
    nodes.Create (2); 

    PointToPointHelper pointToPoint; 
    pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("1000Mbps")); 
    pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); 

    NetDeviceContainer devices; 
    devices = pointToPoint.Install (nodes); 

    InternetStackHelper stack; 
    stack.Install (nodes); 

    Ipv4AddressHelper address; 
    address.SetBase ("10.1.1.0", "255.255.255.0"); 

    Ipv4InterfaceContainer interfaces = address.Assign (devices); 

    UdpEchoServerHelper echoServer (9); 

    ApplicationContainer serverApps = echoServer.Install (nodes.Get (1)); 
    serverApps.Start (Seconds (1.0)); 
    serverApps.Stop (Seconds (10.0)); 

    UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9); 
    echoClient.SetAttribute ("MaxPackets", UintegerValue (1)); 
    echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0))); 
    echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); 

    ApplicationContainer clientApps = echoClient.Install (nodes.Get (0)); 
    clientApps.Start (Seconds (2.0)); 
    clientApps.Stop (Seconds (10.0)); 
    ////////////////////////////////////////////////////////////////////////// 

    uint32_t payloadSize = 1472; //1500 byte IP packet 
    double simulationTime = 10; //seconds 
    double throughput = 0; 
    uint32_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get  (1))->GetReceived(); 
    throughput = totalPacketsThrough * payloadSize * 8/(simulationTime *  1000000.0); //Mbit/s 
    std::cout << " *throughput = " << throughput ;      

///////////////////////////////////////////////////////////////////// 
    Simulator::Run(); 
    Simulator::Destroy(); 
    return 0; 
} 

答えて

1

私はあなたのエラーを考えているあなたはserverAppsないserverAppを宣言しているということです。

+0

lol ...これは間違いありませんでしたが、結果は出ません: –

+0

Waf:ディレクトリ/home/hamid/workspace/ns-allinone-3.25/ns-3.25/buildを入力してください Waf: '/home/hamid/workspace/ns-allinone-3.25/ns-3.25/build 'ディレクトリから出る ビルドコマンドはbuild/compile_commands.jsonに格納されます ' build 'が正常に終了しました(1.496s) コマンド['/home /hamid/workspace/ns-allinone-3.25/ns-3.25/build/scratch/first ']はシグナルSIGSEGVで終了しました。デバッガの下で実行して、詳細情報を取得します(./waf-run --command-template = "gdb -args%s ")。 –

+0

plz回答を受け入れて、新しいSOを作成します。 – baddger964

関連する問題