50 { |
50 { |
51 static TypeId tid = TypeId ("ns3::OnOffApplication") |
51 static TypeId tid = TypeId ("ns3::OnOffApplication") |
52 .SetParent<Application> () |
52 .SetParent<Application> () |
53 .AddConstructor<OnOffApplication> () |
53 .AddConstructor<OnOffApplication> () |
54 .AddAttribute ("DataRate", "The data rate in on state.", |
54 .AddAttribute ("DataRate", "The data rate in on state.", |
55 DataRate ("500kb/s"), |
55 DataRateValue (DataRate ("500kb/s")), |
56 MakeDataRateAccessor (&OnOffApplication::m_cbrRate), |
56 MakeDataRateAccessor (&OnOffApplication::m_cbrRate), |
57 MakeDataRateChecker ()) |
57 MakeDataRateChecker ()) |
58 .AddAttribute ("PacketSize", "The size of packets sent in on state", |
58 .AddAttribute ("PacketSize", "The size of packets sent in on state", |
59 Uinteger (512), |
59 UintegerValue (512), |
60 MakeUintegerAccessor (&OnOffApplication::m_pktSize), |
60 MakeUintegerAccessor (&OnOffApplication::m_pktSize), |
61 MakeUintegerChecker<uint32_t> (1)) |
61 MakeUintegerChecker<uint32_t> (1)) |
62 .AddAttribute ("Remote", "The address of the destination", |
62 .AddAttribute ("Remote", "The address of the destination", |
63 Address (), |
63 AddressValue (), |
64 MakeAddressAccessor (&OnOffApplication::m_peer), |
64 MakeAddressAccessor (&OnOffApplication::m_peer), |
65 MakeAddressChecker ()) |
65 MakeAddressChecker ()) |
66 .AddAttribute ("OnTime", "A RandomVariable used to pick the duration of the 'On' state.", |
66 .AddAttribute ("OnTime", "A RandomVariable used to pick the duration of the 'On' state.", |
67 ConstantVariable (1.0), |
67 RandomVariableValue (ConstantVariable (1.0)), |
68 MakeRandomVariableAccessor (&OnOffApplication::m_onTime), |
68 MakeRandomVariableAccessor (&OnOffApplication::m_onTime), |
69 MakeRandomVariableChecker ()) |
69 MakeRandomVariableChecker ()) |
70 .AddAttribute ("OffTime", "A RandomVariable used to pick the duration of the 'Off' state.", |
70 .AddAttribute ("OffTime", "A RandomVariable used to pick the duration of the 'Off' state.", |
71 ConstantVariable (1.0), |
71 RandomVariableValue (ConstantVariable (1.0)), |
72 MakeRandomVariableAccessor (&OnOffApplication::m_offTime), |
72 MakeRandomVariableAccessor (&OnOffApplication::m_offTime), |
73 MakeRandomVariableChecker ()) |
73 MakeRandomVariableChecker ()) |
74 .AddAttribute ("MaxBytes", |
74 .AddAttribute ("MaxBytes", |
75 "The total number of bytes to send. Once these bytes are sent, " |
75 "The total number of bytes to send. Once these bytes are sent, " |
76 "no packet is sent again, even in on state. The value zero means " |
76 "no packet is sent again, even in on state. The value zero means " |
77 "that there is no limit.", |
77 "that there is no limit.", |
78 Uinteger (0), |
78 UintegerValue (0), |
79 MakeUintegerAccessor (&OnOffApplication::m_maxBytes), |
79 MakeUintegerAccessor (&OnOffApplication::m_maxBytes), |
80 MakeUintegerChecker<uint32_t> ()) |
80 MakeUintegerChecker<uint32_t> ()) |
81 .AddAttribute ("Protocol", "The type of protocol to use.", |
81 .AddAttribute ("Protocol", "The type of protocol to use.", |
82 Udp::GetTypeId (), |
82 TypeIdValue (Udp::GetTypeId ()), |
83 MakeTypeIdAccessor (&OnOffApplication::m_tid), |
83 MakeTypeIdAccessor (&OnOffApplication::m_tid), |
84 MakeTypeIdChecker ()) |
84 MakeTypeIdChecker ()) |
85 .AddTraceSource ("Tx", "A new packet is created and is sent", |
85 .AddTraceSource ("Tx", "A new packet is created and is sent", |
86 MakeTraceSourceAccessor (&OnOffApplication::m_txTrace)) |
86 MakeTraceSourceAccessor (&OnOffApplication::m_txTrace)) |
87 ; |
87 ; |