2014-11-22 2 views
0

라우터를 통해 연결된 서버와 클라이언트를 포함하는 매우 간단한 토폴로지를 만들려고합니다. GUI를 통해 얻은 다음 코드. 나는 그것을 실행하려고 노력하고 있지만 그것은 긴 오류를 던져 준다. 나는 ns-3에 익숙하지 않았기 때문에 친절하게도 나를 참아 준다.라우터가있는 토폴로지 만들기 ns-3

#include "ns3/simulator-module.h" 
#include "ns3/node-module.h" 
#include "ns3/core-module.h" 
#include "ns3/common-module.h" 
#include "ns3/global-route-manager.h" 
#include "ns3/helper-module.h" 
#include "ns3/bridge-module.h" 

using namespace ns3; 

int main(int argc, char *argv[]) 
{ 
CommandLine cmd; 
cmd.Parse (argc, argv); 

/* Configuration. */ 

/* Build nodes. */ 
NodeContainer term_0; 
term_0.Create (1); 
NodeContainer term_1; 
term_1.Create (1); 
NodeContainer router_0; 
router_0.Create (1); 

/* Build link. */ 
CsmaHelper csma_hub_0; 
csma_hub_0.SetChannelAttribute ("DataRate", DataRateValue (100000000)); 
csma_hub_0.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (10000))); 
CsmaHelper csma_hub_1; 
csma_hub_1.SetChannelAttribute ("DataRate", DataRateValue (100000000)); 
csma_hub_1.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (10000))); 

/* Build link net device container. */ 
NodeContainer all_hub_0; 
all_hub_0.Add (router_0); 
all_hub_0.Add (term_0); 
NetDeviceContainer ndc_hub_0 = csma_hub_0.Install (all_hub_0); 
NodeContainer all_hub_1; 
all_hub_1.Add (router_0); 
all_hub_1.Add (term_1); 
NetDeviceContainer ndc_hub_1 = csma_hub_1.Install (all_hub_1); 

/* Install the IP stack. */ 
InternetStackHelper internetStackH; 
internetStackH.Install (term_0); 
internetStackH.Install (term_1); 
internetStackH.Install (router_0); 

/* IP assign. */ 
Ipv4AddressHelper ipv4; 
ipv4.SetBase ("10.0.0.0", "255.255.255.0"); 
Ipv4InterfaceContainer iface_ndc_hub_0 = ipv4.Assign (ndc_hub_0); 
ipv4.SetBase ("10.0.1.0", "255.255.255.0"); 
Ipv4InterfaceContainer iface_ndc_hub_1 = ipv4.Assign (ndc_hub_1); 

/* Generate Route. */ 
Ipv4GlobalRoutingHelper::PopulateRoutingTables(); 

/* Generate Application. */ 
uint16_t port_udpEcho_0 = 9; 
UdpEchoServerHelper server_udpEcho_0 (port_udpEcho_0); 
ApplicationContainer apps_udpEcho_0 = server_udpEcho_0.Install (term_1.Get(0)); 
apps_udpEcho_0.Start (Seconds (0.0)); 
apps_udpEcho_0.Stop (Seconds (2.0)); 
Time interPacketInterval_udpEcho_0 = Seconds (1.0); 
UdpEchoClientHelper client_udpEcho_0 (iface_ndc_hub_1.GetAddress(1), 9); 
client_udpEcho_0.SetAttribute ("MaxPackets", UintegerValue (1)); 
client_udpEcho_0.SetAttribute ("Interval", TimeValue (interPacketInterval_udpEcho_0)); 
client_udpEcho_0.SetAttribute ("PacketSize", UintegerValue (1024)); 
apps_udpEcho_0 = client_udpEcho_0.Install (term_0.Get (0)); 
apps_udpEcho_0.Start (Seconds (0.1)); 
apps_udpEcho_0.Stop (Seconds (2.0)); 

/* Simulation. */ 
/* Pcap output. */ 
/* Stop the simulation after x seconds. */ 
uint32_t stopTime = 3; 
Simulator::Stop (Seconds (stopTime)); 
/* Start and clean simulation. */ 
Simulator::Run(); 
Simulator::Destroy(); 
} 

답변

2

새로운 사용자라면 이미 ns-3에서 제공하는 예제를 찾아 프로그램을 시작해야합니다. 이처럼 : https://www.nsnam.org/doxygen/simple-routing-ping6_8cc_source.html. 네트워크 토폴로지를 보면 원하는 것입니다.

코드를 실행하려고 할 때 많은 헤더를 컴파일하여 컴파일해야했습니다 (시간이 주어진 다른 버전 일 수도 있고 GUI가 오래된 것일 수도 있습니다). 당신을 제거하고 다음을 넣어 :

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

을 그리고 마지막으로, 당신은 아무것도 인쇄되지 거라고, 그래서 당신이 뭘하려고했는지 확실하지 않다. UdpEchoClientHelper 및 UdpEchoServerHelper를 사용하면서 로그를 사용하도록 권장합니다. 다음 두 줄을 사용하여이 작업을 수행 할 수 있습니다.

/* Configuration. */ 
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); 
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); 

나는 너무 익숙하며 무엇을 하려는지 잘 모르겠습니다. 그래서 나는 여기서 나의 대답을 멈출 것이다. 행운을 빕니다.