本篇解决的问题,怎么在ns3的仿真实验中,给不同的socket配置不同的拥塞控制算法。
Someone may want to compare the throughput of different congestion control algorithms in ns3 as what I do with ns2[1]. But the command to configure socket type globally may not saturate such need.
Config::SetDefault("ns3::TcpL4Protocol::SocketType", StringValue("ns3::TcpReno"));
There is another way to get such problem solved.
SetCongestionControlAlgorithm (algo);
Of cource, other congestion control algorithms can add here:
void TcpClient::SetCongestionAlgo(std::string &algo){
m_algo=algo;
}
void TcpClient::ConfigureCongstionAlgo(){
TypeId id;
if(0==m_algo.compare("reno")){
id=TcpNewReno::GetTypeId ();
}else if(0==m_algo.compare("linux-reno")){
id=TcpLinuxReno::GetTypeId();
}else if(0==m_algo.compare("vegas")){
id=TcpVegas::GetTypeId ();
}else if(0==m_algo.compare("bic")){
id=TcpBic::GetTypeId ();
}else if(0==m_algo.compare("cubic")){
id=TcpCubic::GetTypeId();
}else if (0==m_algo.compare ("westwood")){
id=TcpWestwood::GetTypeId ();
}else{
id=TcpLinuxReno::GetTypeId();
}
ObjectFactory congestionAlgorithmFactory;
congestionAlgorithmFactory.SetTypeId (id);
Ptr<TcpCongestionOps> algo = congestionAlgorithmFactory.Create<TcpCongestionOps> ();
TcpSocketBase *base=static_cast<TcpSocketBase*>(PeekPointer(m_socket));
base->SetCongestionControlAlgorithm (algo);
}
For other algorithms, just add the specific id:
id=TcpHighSpeed::GetTypeId ();
id=TcpHtcp::GetTypeId();
id=TcpHybla::GetTypeId();
id=TcpIllinois::GetTypeId();
id=TcpLedbat::GetTypeId();
id=TcpLp::GetTypeId();
id=TcpVeno::GetTypeId();
id=TcpYeah::GetTypeId();
And the code can be downloaded at [2].
During the simulation, the values on rtt, congestion window, inflight packet, rate from sender and rate from receiver are logged out.
Some results are given here:
cwnd.png
inflight.png
rtt.png
sendrate.png
goodput.png
[1] ns2仿真学习(三)-不同tcp拥塞控制的竞争能力
[2] congetion algorithms configuration