How to change TcpSocket ConnTimeout?

21 views
Skip to first unread message

Sim_Monkey

unread,
Apr 16, 2015, 1:51:13 PM4/16/15
to ns-3-...@googlegroups.com
Hello,

If my understanding is correct, the ConnTimeout attribute of a TcpSocket object is the amount of time to wait before attempting a reconnection (due to lack of ACK after intial SYN).
I try to set the value of an instance of the TcpSocket object inside my custom application like so:

      TypeId tcpTid = TypeId::LookupByName ("ns3::TcpSocketFactory");
      m_tcpSocket = Socket::CreateSocket (GetNode (), tcpTid);
      m_tcpSocket->Bind ();
      TimeValue timeout;
      m_tcpSocket->GetAttribute ("ConnTimeout", timeout);
      NS_LOG_INFO ("PRE-CHANGE TIMEOUT: " << timeout.Get() << " ");
      m_tcpSocket->SetAttribute ("ConnTimeout", TimeValue (Seconds(0.1)));
      m_tcpSocket->GetAttribute ("ConnTimeout", timeout);
      NS_LOG_INFO ("POST-CHANGE TIMEOUT: " << timeout.Get() << "\n");

The NS_LOG_INFO output is to check after the script runs that the value is being changed.
The value in output is being shown as changing to the new value (+100000000.0ns which is 0.1 second)
However, in the simulation, the actual instance of the TcpSocket is still waiting +3000000000.0ns i.e. 3 seconds to attempt a reconnect.

The whole point of this is to adjust the amount of time to wait for a reconnect after a collision on the target socket occurs which is prone to happen in my simulation.
I must be doing something wrong, so any insight is welcome.

Thank you,

SM

Tommaso Pecorella

unread,
Apr 16, 2015, 2:21:42 PM4/16/15
to ns-3-...@googlegroups.com
Hi,

strange. What ns-3 version are you using ?
Can you attach a full script showing the issue ? (I'm lazy and I don't want to do a full script).

Thanks,

T.

Sim_Monkey

unread,
Apr 16, 2015, 2:35:42 PM4/16/15
to ns-3-...@googlegroups.com
Hi Tom,

I feel kind of dense now... according to the source directory it is labelled ns-3.20 which is quite old. I thought I had the latest since I downloaded in January 2015 but I must have gotten an old one by mistake. I'm going to convert it over to the latest stable release and see if that fixes the bug (probably something you addressed since 3.20).

Regards,

SM
Reply all
Reply to author
Forward
0 new messages