55 LogComponentEnable ("SimplePointToPointExample", LOG_LEVEL_INFO); |
55 LogComponentEnable ("SimplePointToPointExample", LOG_LEVEL_INFO); |
56 #endif |
56 #endif |
57 |
57 |
58 |
58 |
59 // Set a few attributes |
59 // Set a few attributes |
60 Config::SetDefault ("ns3::RateErrorModel::ErrorRate", DoubleValue (0.01)); |
60 Config::SetDefault ("ns3::RateErrorModel::ErrorRate", DoubleValue (0.001)); |
61 Config::SetDefault ("ns3::RateErrorModel::ErrorUnit", StringValue ("ERROR_UNIT_PACKET")); |
61 Config::SetDefault ("ns3::RateErrorModel::ErrorUnit", StringValue ("ERROR_UNIT_PACKET")); |
|
62 |
|
63 Config::SetDefault ("ns3::BurstErrorModel::ErrorRate", DoubleValue (0.01)); |
|
64 Config::SetDefault ("ns3::BurstErrorModel::BurstSize", StringValue ("ns3::UniformRandomVariable[Min=1|Max=3]")); |
62 |
65 |
63 Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210)); |
66 Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210)); |
64 Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRateValue (DataRate ("448kb/s"))); |
67 Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRateValue (DataRate ("448kb/s"))); |
65 |
68 |
|
69 std::string errorModelType = "ns3::RateErrorModel"; |
66 |
70 |
67 // Allow the user to override any of the defaults and the above |
71 // Allow the user to override any of the defaults and the above |
68 // Bind()s at run-time, via command-line arguments |
72 // Bind()s at run-time, via command-line arguments |
69 CommandLine cmd; |
73 CommandLine cmd; |
|
74 cmd.AddValue("errorModelType", "TypeId of the error model to use", errorModelType); |
70 cmd.Parse (argc, argv); |
75 cmd.Parse (argc, argv); |
71 |
76 |
72 // Here, we will explicitly create four nodes. In more sophisticated |
77 // Here, we will explicitly create four nodes. In more sophisticated |
73 // topologies, we could configure a node factory. |
78 // topologies, we could configure a node factory. |
74 NS_LOG_INFO ("Create nodes."); |
79 NS_LOG_INFO ("Create nodes."); |
144 |
149 |
145 // |
150 // |
146 // Error model |
151 // Error model |
147 // |
152 // |
148 // Create an ErrorModel based on the implementation (constructor) |
153 // Create an ErrorModel based on the implementation (constructor) |
149 // specified by the default classId |
154 // specified by the default TypeId |
150 Ptr<RateErrorModel> em = CreateObject<RateErrorModel> (); |
155 |
151 em->SetAttribute ("ErrorRate", DoubleValue (0.001)); |
156 ObjectFactory factory; |
|
157 factory.SetTypeId (errorModelType); |
|
158 Ptr<ErrorModel> em = factory.Create<ErrorModel> (); |
152 d3d2.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (em)); |
159 d3d2.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (em)); |
153 |
160 |
154 // Now, let's use the ListErrorModel and explicitly force a loss |
161 // Now, let's use the ListErrorModel and explicitly force a loss |
155 // of the packets with pkt-uids = 11 and 17 on node 2, device 0 |
162 // of the packets with pkt-uids = 11 and 17 on node 2, device 0 |
156 std::list<uint32_t> sampleList; |
163 std::list<uint32_t> sampleList; |