tutorial/tutorial-csma-echo-ascii-trace.cc
changeset 2230 9f13ac3291e0
parent 1539 69d32521f6b8
child 2311 a7dbe3cba7de
equal deleted inserted replaced
2205:57710f066013 2230:9f13ac3291e0
    37 {
    37 {
    38   LogComponentEnable ("UdpEchoSimulation", LOG_LEVEL_INFO);
    38   LogComponentEnable ("UdpEchoSimulation", LOG_LEVEL_INFO);
    39 
    39 
    40   NS_LOG_INFO ("UDP Echo Simulation");
    40   NS_LOG_INFO ("UDP Echo Simulation");
    41 
    41 
    42   Ptr<Node> n0 = Create<InternetNode> ();
    42   Ptr<Node> n0 = CreateObject<InternetNode> ();
    43   Ptr<Node> n1 = Create<InternetNode> ();
    43   Ptr<Node> n1 = CreateObject<InternetNode> ();
    44   Ptr<Node> n2 = Create<InternetNode> ();
    44   Ptr<Node> n2 = CreateObject<InternetNode> ();
    45   Ptr<Node> n3 = Create<InternetNode> ();
    45   Ptr<Node> n3 = CreateObject<InternetNode> ();
    46 
    46 
    47   Ptr<CsmaChannel> lan = 
    47   Ptr<CsmaChannel> lan = 
    48     CsmaTopology::CreateCsmaChannel (DataRate (5000000), MilliSeconds (2));
    48     CsmaTopology::CreateCsmaChannel (DataRate (5000000), MilliSeconds (2));
    49 
    49 
    50   uint32_t nd0 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n0, lan, 
    50   uint32_t nd0 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n0, lan, 
    64   CsmaIpv4Topology::AddIpv4Address (n2, nd2, "10.1.1.3", "255.255.255.0");
    64   CsmaIpv4Topology::AddIpv4Address (n2, nd2, "10.1.1.3", "255.255.255.0");
    65   CsmaIpv4Topology::AddIpv4Address (n3, nd3, "10.1.1.4", "255.255.255.0");
    65   CsmaIpv4Topology::AddIpv4Address (n3, nd3, "10.1.1.4", "255.255.255.0");
    66 
    66 
    67   uint16_t port = 7;
    67   uint16_t port = 7;
    68 
    68 
    69   Ptr<UdpEchoClient> client = Create<UdpEchoClient> (n0, "10.1.1.2", port, 
    69   Ptr<UdpEchoClient> client = CreateObject<UdpEchoClient> (n0, "10.1.1.2", port, 
    70     1, Seconds(1.), 1024);
    70     1, Seconds(1.), 1024);
    71 
    71 
    72   Ptr<UdpEchoServer> server = Create<UdpEchoServer> (n1, port);
    72   Ptr<UdpEchoServer> server = CreateObject<UdpEchoServer> (n1, port);
    73 
    73 
    74   server->Start(Seconds(1.));
    74   server->Start(Seconds(1.));
    75   client->Start(Seconds(2.));
    75   client->Start(Seconds(2.));
    76 
    76 
    77   server->Stop (Seconds(10.));
    77   server->Stop (Seconds(10.));