doc/tutorial/building-topologies.texi
changeset 3382 d5f8e5fae1c6
parent 3355 ea06eff669b3
child 3700 fa1c7b813873
equal deleted inserted replaced
3381:3cdd9d60f7c7 3382:d5f8e5fae1c6
   147 we create a five megabit per second transmitter on devices created using the
   147 we create a five megabit per second transmitter on devices created using the
   148 helper and a two millisecond delay on channels created by the helper.
   148 helper and a two millisecond delay on channels created by the helper.
   149 
   149 
   150 @verbatim
   150 @verbatim
   151   PointToPointHelper pointToPoint;
   151   PointToPointHelper pointToPoint;
   152   pointToPoint.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
   152   pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
   153   pointToPoint.SetChannelParameter ("Delay", StringValue ("2ms"));
   153   pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
   154 
   154 
   155   NetDeviceContainer p2pDevices;
   155   NetDeviceContainer p2pDevices;
   156   p2pDevices = pointToPoint.Install (p2pNodes);
   156   p2pDevices = pointToPoint.Install (p2pNodes);
   157 @end verbatim
   157 @end verbatim
   158 
   158 
   225 going to be fundamentally similar to the applications section of 
   225 going to be fundamentally similar to the applications section of 
   226 @code{first.cc} but we are going to instantiate the server on one of the 
   226 @code{first.cc} but we are going to instantiate the server on one of the 
   227 nodes that has a CSMA node and the client on the node having only a 
   227 nodes that has a CSMA node and the client on the node having only a 
   228 point-to-point device.
   228 point-to-point device.
   229 
   229 
   230 First, we set up the echo server.
   230 First, we set up the echo server.  We create a @code{UdpEchoServerHelper} and
   231 
   231 provide a required attribute value to the constructor which is the server port
   232 @verbatim
   232 number.  Recall that this port can be changed later using the 
       
   233 @code{SetAttribute} method if desired, but we require it to be provided to
       
   234 the constructor.
       
   235 
       
   236 @verbatim
       
   237   UdpEchoServerHelper echoServer (9);
       
   238 
   233   ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
   239   ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
   234   serverApps.Start (Seconds (1.0));
   240   serverApps.Start (Seconds (1.0));
   235   serverApps.Stop (Seconds (10.0));
   241   serverApps.Stop (Seconds (10.0));
   236 @end verbatim
   242 @end verbatim
   237 
   243 
   244 if we create @code{nCsma} ``extra'' nodes the last one will be at index 
   250 if we create @code{nCsma} ``extra'' nodes the last one will be at index 
   245 @code{nCsma}.  You see this exhibited in the @code{Get} of the first line of 
   251 @code{nCsma}.  You see this exhibited in the @code{Get} of the first line of 
   246 code.
   252 code.
   247 
   253 
   248 The client application is set up exactly as we did in the @code{first.cc}
   254 The client application is set up exactly as we did in the @code{first.cc}
   249 example script.  We tell the client to send packets to the server we just
   255 example script.  Again, we provide required attributes to the 
   250 installed on the last of the ``extra'' CSMA nodes.  We install the client on
   256 @code{UdpEchoClientHelper} in the constructor (in this case the remote address
   251 the leftmost point-to-point node seen in the topology illustration.
   257 and port).  We tell the client to send packets to the server we just installed
   252 
   258 on the last of the ``extra'' CSMA nodes.  We install the client on the 
   253 @verbatim
   259 leftmost point-to-point node seen in the topology illustration.
   254   UdpEchoClientHelper echoClient;
   260 
   255   echoClient.SetRemote (csmaInterfaces.GetAddress (nCsma), 9);
   261 @verbatim
   256   echoClient.SetAppAttribute ("MaxPackets", UintegerValue (1));
   262   UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
   257   echoClient.SetAppAttribute ("Interval", TimeValue (Seconds (1.)));
   263   echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
   258   echoClient.SetAppAttribute ("PacketSize", UintegerValue (1024));
   264   echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
       
   265   echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
   259 
   266 
   260   ApplicationContainer clientApps = echoClient.Install (p2pNodes.Get (0));
   267   ApplicationContainer clientApps = echoClient.Install (p2pNodes.Get (0));
   261   clientApps.Start (Seconds (2.0));
   268   clientApps.Start (Seconds (2.0));
   262   clientApps.Stop (Seconds (10.0));
   269   clientApps.Stop (Seconds (10.0));
   263 @end verbatim
   270 @end verbatim
   667 delay on channels created by the helper.  We then @code{Intall} the devices
   674 delay on channels created by the helper.  We then @code{Intall} the devices
   668 on the nodes and the channel between them.
   675 on the nodes and the channel between them.
   669 
   676 
   670 @verbatim
   677 @verbatim
   671   PointToPointHelper pointToPoint;
   678   PointToPointHelper pointToPoint;
   672   pointToPoint.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
   679   pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
   673   pointToPoint.SetChannelParameter ("Delay", StringValue ("2ms"));
   680   pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
   674 
   681 
   675   NetDeviceContainer p2pDevices;
   682   NetDeviceContainer p2pDevices;
   676   p2pDevices = pointToPoint.Install (p2pNodes);
   683   p2pDevices = pointToPoint.Install (p2pNodes);
   677 @end verbatim
   684 @end verbatim
   678 
   685 
   962 
   969 
   963 We put the echo server on the ``rightmost'' node in the illustration at the
   970 We put the echo server on the ``rightmost'' node in the illustration at the
   964 start of the file.  We have done this before.
   971 start of the file.  We have done this before.
   965 
   972 
   966 @verbatim
   973 @verbatim
   967   UdpEchoServerHelper echoServer;
   974   UdpEchoServerHelper echoServer (9);
   968   echoServer.SetPort (9);
       
   969 
   975 
   970   ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
   976   ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
   971   serverApps.Start (Seconds (1.0));
   977   serverApps.Start (Seconds (1.0));
   972   serverApps.Stop (Seconds (10.0));
   978   serverApps.Stop (Seconds (10.0));
   973 @end verbatim
   979 @end verbatim
   974 
   980 
   975 And we put the echo client on the last STA node we created, pointing it to
   981 And we put the echo client on the last STA node we created, pointing it to
   976 the server on the CSMA network.  We have also seen similar operations before.
   982 the server on the CSMA network.  We have also seen similar operations before.
   977 
   983 
   978 @verbatim
   984 @verbatim
   979   UdpEchoClientHelper echoClient;
   985   UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
   980   echoClient.SetRemote (csmaInterfaces.GetAddress (nCsma), 9);
   986   echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
   981   echoClient.SetAppAttribute ("MaxPackets", UintegerValue (1));
   987   echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
   982   echoClient.SetAppAttribute ("Interval", TimeValue (Seconds (1.)));
   988   echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
   983   echoClient.SetAppAttribute ("PacketSize", UintegerValue (1024));
       
   984 
   989 
   985   ApplicationContainer clientApps =
   990   ApplicationContainer clientApps =
   986     echoClient.Install (wifiStaNodes.Get (nWifi - 1));
   991     echoClient.Install (wifiStaNodes.Get (nWifi - 1));
   987   clientApps.Start (Seconds (2.0));
   992   clientApps.Start (Seconds (2.0));
   988   clientApps.Stop (Seconds (10.0));
   993   clientApps.Stop (Seconds (10.0));