Oded Itzhaky
Oded Itzhaky

Reputation: 445

SCTP multi-homing not working as expected

I'm facing a problem in implementing multi-homing in SCTP as the server side. The server has 2 IPs it is listening to. I'm almost there, but there are 2 problems:

  1. First IP returns the INIT-ACK with 2 different IPs inside the header as it should but the other IP return twice the same IP in the INIT-ACK header.
  2. Seems like I’m not supporting 100 % in multi-homing, for example, if one of the links is down I don’t see a fail over.

So I don’t know if except the setsockopt with the option SCTP_SOCKOPT_BINDX_ADD I need anything else (maybe SCTP_PRIMARY_ADDR?) or what is wrong in my implementation.

Following is the code, I enter this code twice, first time I do bind and then save the socket and the first address, second time again bind (for the second IP) and then running setsockopt for both of the addresses and sockets.

  bind(socket, &sock_addr.addr.sock_addr,  sock_addr_len);
  if(SHARED.num_used_entries_in_sockaddr_array  == 0)
  {
      SHARED.saved_socket = socket;
      SHARED.sockaddr_array[1] = sock_addr.addr.sock_addr;
  }
  else
  {
      SHARED.sockaddr_array[0] = sock_addr.addr.sock_addr;
  }

  if(SHARED.num_used_entries_in_sockaddr_array > 0)
  {

  sock_rc = setsockopt(SHARED.saved_socket,
                                  IPPROTO_SCTP,
                                  SCTP_SOCKOPT_BINDX_ADD,
                                  (char*)SHARED.sockaddr_array,
                                  sizeof(SCKOS_SOCK_ADDR));

  sock_rc = setsockopt(socket,
                                  IPPROTO_SCTP,
                                  SCTP_SOCKOPT_BINDX_ADD,
                                  (char*)SHARED.sockaddr_array,
                                  sizeof(SCKOS_SOCK_ADDR));

  }
  SHARED.num_used_entries_in_sockaddr_array++;

Thanks!!!

Upvotes: 1

Views: 1220

Answers (2)

Oded Itzhaky
Oded Itzhaky

Reputation: 445

thanks for the answer, in the end I used sctp_bindx which is much easier to implement

Upvotes: 0

cathrine
cathrine

Reputation: 49

SCTP_SOCKOPT_BINDX_ADD is ok for multi-homing. your codes have some unused lines.

  if(SHARED.num_used_entries_in_sockaddr_array  == 0)
  {
    bind(socket, &sock_addr.addr.sock_addr,  sock_addr_len);
  }
  else
  {
    sock_rc = setsockopt(socket,
                              IPPROTO_SCTP,
                              SCTP_SOCKOPT_BINDX_ADD,
                              (char*)sock_addr.addr.sock_addr,
                              sizeof(SCKOS_SOCK_ADDR));
    }enter code here

You can refer to linux sctp implemantation. Did you see heartbeat on all paths? Which box you test on?

Upvotes: 1

Related Questions