如何使用ns3中的属性设置值?我有一个在文件中定义的类的属性,我尝试在我的main函数中设置。我无法改变它们。
我的问题:
这是定义:
TypeId MpTcpSocketBase::GetTypeId(void)
{
static TypeId tid = TypeId("ns3::MpTcpSocketBase")
.SetParent<TcpSocketBase>()
.AddConstructor<MpTcpSocketBase>()
.AddAttribute("CongestionControl",
"Congestion control algorithm",
EnumValue(Linked_Increases),
MakeEnumAccessor(&MpTcpSocketBase::SetCongestionCtrlAlgo),
MakeEnumChecker(Uncoupled_TCPs, "Uncoupled_TCPs",
Fully_Coupled, "Fully_Coupled",
RTT_Compensator, "RTT_Compensator",
Linked_Increases, "Linked_Increases",
COUPLED_INC, "COUPLED_INC",
COUPLED_EPSILON, "COUPLED_EPSILON",
COUPLED_SCALABLE_TCP, "COUPLED_SCALABLE_TCP",
COUPLED_FULLY, "COUPLED_FULLY",
UNCOUPLED, "UNCOUPLED"))
.AddAttribute("SchedulingAlgorithm",
"Algorithm for data distribution between sub-flows",
EnumValue(Round_Robin),
MakeEnumAccessor(&MpTcpSocketBase::SetDataDistribAlgo),
MakeEnumChecker(Round_Robin, "Round_Robin"))
.AddAttribute("PathManagement",
"Mechanism for establishing new sub-flows",
EnumValue(FullMesh),
MakeEnumAccessor(&MpTcpSocketBase::SetPathManager),
MakeEnumChecker(Default,"Default",
FullMesh, "FullMesh",
NdiffPorts, "NdiffPorts"))
.AddAttribute("MaxSubflows",
"Maximum number of sub-flows per each mptcp connection",
UintegerValue(8),
MakeUintegerAccessor(&MpTcpSocketBase::maxSubflows),
MakeUintegerChecker<uint8_t>())
.AddAttribute("RandomGap",
"Random gap between subflows setup",
UintegerValue(50),
MakeUintegerAccessor(&MpTcpSocketBase::m_rGap),
MakeUintegerChecker<uint32_t>())
.AddAttribute("Subflows",
"The list of sub-flows associated to this protocol.",
ObjectVectorValue(),
MakeObjectVectorAccessor(&MpTcpSocketBase::subflows),
MakeObjectVectorChecker<MpTcpSocketBase>())
.AddAttribute ("ShortFlowTCP", "Use TCP for short flows",
BooleanValue (false),
MakeBooleanAccessor (&MpTcpSocketBase::m_shortFlowTCP),
MakeBooleanChecker())
.AddAttribute ("AlphaPerAck", " Update alpha per ACK ",
BooleanValue (false),
MakeBooleanAccessor (&MpTcpSocketBase::m_alphaPerAck),
MakeBooleanChecker())
.AddAttribute ("ShortPlotting", " Activate large flow plotting ",
BooleanValue (false),
MakeBooleanAccessor (&MpTcpSocketBase::m_shortPlotting),
MakeBooleanChecker())
.AddAttribute ("LargePlotting", " Activate short flow plotting ",
BooleanValue (false),
MakeBooleanAccessor (&MpTcpSocketBase::m_largePlotting),
MakeBooleanChecker());
return tid;
}
这是用法:
Config::SetDefault("ns3::Ipv4GlobalRouting::FlowEcmpRouting", BooleanValue(true));
Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(1400));
Config::SetDefault("ns3::TcpSocket::DelAckCount", UintegerValue(0));
Config::SetDefault("ns3::DropTailQueue::Mode", StringValue("QUEUE_MODE_PACKETS"));
Config::SetDefault("ns3::DropTailQueue::MaxPackets", UintegerValue(100));
Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue(MpTcpSocketBase::GetTypeId()));
Config::SetDefault("ns3::MpTcpSocketBase::MaxSubflows", UintegerValue(8)); // Sink
Config::SetDefault("ns3::MpTcpSocketBase::CongestionControl", StringValue("Uncoupled_TCPs"));
//Config::SetDefault("ns3::MpTcpSocketBase::PathManagement", StringValue("NdiffPorts"));
但是这里没有任何变化,我有什么方法可以在我的主函数中设置这个值。