418 |
418 |
419 The next three lines in the script are, |
419 The next three lines in the script are, |
420 |
420 |
421 @verbatim |
421 @verbatim |
422 PointToPointHelper pointToPoint; |
422 PointToPointHelper pointToPoint; |
423 pointToPoint.SetDeviceParameter ("DataRate", StringValue ("5Mbps")); |
423 pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); |
424 pointToPoint.SetChannelParameter ("Delay", StringValue ("2ms")); |
424 pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); |
425 @end verbatim |
425 @end verbatim |
426 |
426 |
427 The first line |
427 The first line |
428 |
428 |
429 @verbatim |
429 @verbatim |
432 |
432 |
433 instantiates a @code{PointToPointHelper} object on the stack. From a |
433 instantiates a @code{PointToPointHelper} object on the stack. From a |
434 high-level perspective the next line, |
434 high-level perspective the next line, |
435 |
435 |
436 @verbatim |
436 @verbatim |
437 pointToPoint.SetDeviceParameter ("DataRate", StringValue ("5Mbps")); |
437 pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); |
438 @end verbatim |
438 @end verbatim |
439 |
439 |
440 tells the @code{PointToPointHelper} object to use the value ``5mbps'' |
440 tells the @code{PointToPointHelper} object to use the value ``5mbps'' |
441 (five megabits per second) as the ``DataRate'' when it creates a |
441 (five megabits per second) as the ``DataRate'' when it creates a |
442 @code{PointToPointNetDevice} object. |
442 @code{PointToPointNetDevice} object. |
453 Similar to the ``DataRate'' on the @code{PointToPointNetDevice} you will find a |
453 Similar to the ``DataRate'' on the @code{PointToPointNetDevice} you will find a |
454 ``Delay'' attribute associated with the @code{PointToPointChannel}. The |
454 ``Delay'' attribute associated with the @code{PointToPointChannel}. The |
455 final line, |
455 final line, |
456 |
456 |
457 @verbatim |
457 @verbatim |
458 pointToPoint.SetChannelParameter ("Delay", StringValue ("2ms")); |
458 pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); |
459 @end verbatim |
459 @end verbatim |
460 |
460 |
461 tells the @code{PointToPointHelper} to use the value ``2ms'' (two milliseconds) |
461 tells the @code{PointToPointHelper} to use the value ``2ms'' (two milliseconds) |
462 as the value of the transmission delay of every point to point channel it |
462 as the value of the transmission delay of every point to point channel it |
463 subsequently creates. |
463 subsequently creates. |
563 The following lines of code in our example script, @code{first.cc}, are used |
563 The following lines of code in our example script, @code{first.cc}, are used |
564 to set up a UDP echo server application on one of the nodes we have previously |
564 to set up a UDP echo server application on one of the nodes we have previously |
565 created. |
565 created. |
566 |
566 |
567 @verbatim |
567 @verbatim |
568 UdpEchoServerHelper echoServer; |
568 UdpEchoServerHelper echoServer (9); |
569 echoServer.SetPort (9); |
|
570 |
569 |
571 ApplicationContainer serverApps = echoServer.Install (nodes.Get (1)); |
570 ApplicationContainer serverApps = echoServer.Install (nodes.Get (1)); |
572 serverApps.Start (Seconds (1.0)); |
571 serverApps.Start (Seconds (1.0)); |
573 serverApps.Stop (Seconds (10.0)); |
572 serverApps.Stop (Seconds (10.0)); |
574 @end verbatim |
573 @end verbatim |
575 |
574 |
576 The first line of code in the above snippet declares the |
575 The first line of code in the above snippet declares the |
577 @code{UdpEchoServerHelper}. As usual, this isn't the application itself, it |
576 @code{UdpEchoServerHelper}. As usual, this isn't the application itself, it |
578 is an object used to help us create the actual applications. The second line |
577 is an object used to help us create the actual applications. One of our |
579 that has the @code{SetPort} call, is used to tell the helper to assign the |
578 conventions is place required attributes in the helper constructor. In this |
580 value nine to the ``Port'' attribute when creating |
579 case, the helper can't do anything useful unless it is provided with a port |
581 @code{UdpEchoServerApplication} objects. |
580 number that the client also knows about. Rather than just picking one and |
|
581 hoping it all works out, we require the port number as a parameter to the |
|
582 constructor. The constructor, in turn, simply does a @code{SetAttribute} |
|
583 with the passed value. You can, if desired, set the ``Port'' attribute to |
|
584 another value later. |
582 |
585 |
583 Similar to many other helper objects, the @code{UdpEchoServerHelper} object |
586 Similar to many other helper objects, the @code{UdpEchoServerHelper} object |
584 has an @code{Install} method. It is the execution of this method that actually |
587 has an @code{Install} method. It is the execution of this method that actually |
585 causes the underlying echo server application to be instantiated and attached |
588 causes the underlying echo server application to be instantiated and attached |
586 to a node. Interestingly, the @code{Install} method takes a |
589 to a node. Interestingly, the @code{Install} method takes a |