How to select another sink node if the current sink node is offline (TCP connection)?

49 views
Skip to first unread message

Ding Ding

unread,
Feb 19, 2017, 9:43:18 PM2/19/17
to ns-3-users
Hi all:

I am new to NS3 community. Currently I meet a problem, described as following:

The topology is simple

c ------ s1

Node c is a client node, and it connects to Node s1 that is a sink node who receives data from Node c (Similar to the TCP Bulk Send). At some points, s1 go offline. How can node c knows this information and connects to another node s2? I currently use NS3::Socket to connect these two nodes. I suppose changing a remote sink node is easy to do by using the function "connect()". However, I didn't find any callback function triggered by the timeout (as well as retransmission times). 

I tried several ways, but none of these are useful. For example, it is not a good idea to use the return value of function "send()", I think it returns -1 when buffer is full, not remote server is down. I don't think I can use ns3::TcpSocketBase, because it cannot trigger the "changing another server" behavior. 

Do you have any idea how to solve this problem? I think it is a simple problem, maybe I focused on the wrong Class. If you give some suggestions, could you please give something detail? thanks in advance!!!

Best,
Ding





Tommaso Pecorella

unread,
Feb 25, 2017, 7:09:40 PM2/25/17
to ns-3-users
There's no way to do that, but the problem isn't ns-3.
A TCP stream can NOT be switched to a different host once the connection is started. You need to close it and reopen it. That's TCP.

T.

Ding Ding

unread,
Feb 26, 2017, 11:51:35 AM2/26/17
to ns-3-users
Thanks Tommaso!

I know that we need to close the connection first, then establish another one to send traffic. 

What I mean here is the following: when the sink node (s1) go offline, how can the sender (c) knows? I do not find any callback function (inform sender that the sink is offline) from NS3::Socket class. 

I use two ways to turn off the sink, none of them could trick the callback function of sender.
(1) close the sink application
(2) Simulator::Schedule (Seconds (nodeDown),&Ipv4::SetDown,ipv4, ipv4ifIndex);

Best,
Ding

在 2017年2月25日星期六 UTC-5下午7:09:40,Tommaso Pecorella写道:

Tommaso Pecorella

unread,
Feb 28, 2017, 4:18:06 PM2/28/17
to ns-3-users
The socket will use callback to signal its transition in a closed state, eventually... after 4 minutes of inactivity.
You can change it by modifying the MaxSegLifetime attribute of TcpSocketBase (The callback is fired after 2*MaxSegLifetime).

T.
Reply all
Reply to author
Forward
0 new messages