NS3中可以很方便的为TCP设置默认拥塞控制算法
Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue(TypeId::LookupByName("n3::TcpCubic")));
可以使用如下方法为某个TCP Socket单独设定拥塞控制算法
ObjectFactory congestionAlgorithmFactory;
congestionAlgorithmFactory.SetTypeId("ns3::TcpCubic");
Ptr<TcpSocketBase> socketBase = StaticCast<TcpSocketBase>(localSocket); //localSocket的类型为 Ptr<Socket>
socketBase->SetCongestionControlAlgorithm(congestionAlgorithmFactory.Create<TcpCongestionOps>());