using sockets

Discussion in 'Linux Networking' started by Bill Cunningham, Mar 19, 2014.

  1. To use SCTP instead of UDP; do I need a raw socket or just an IP socket
    with the number 132 instead of the macro SOCK_DGRAM?

    Bill
     
    Bill Cunningham, Mar 19, 2014
    #1
    1. Advertisements

  2. Bill Cunningham

    Jorgen Grahn Guest

    A raw socket /is/ an IP socket, so the question doesn't make sense.

    But I think the right answer is something else.

    As far as I can tell by googling, you're supposed to use libsctp.
    See http://www.lksctp.org/.

    I could have sworn I had seen SCTP support in the normal socket layer
    (like for UDP and TCP) but now that I look I see no sctp(7) man page
    documenting it. Some support might be there, but I wouldn't use it if
    it's not described on the detailed level that udp(7), tcp(7) and so on
    provide.

    /Jorgen
     
    Jorgen Grahn, Mar 19, 2014
    #2
    1. Advertisements

  3. Ok thanks. No there is no man page in 7 or any other intro that lists SCTP.
    This is rather a young protocol. Now SIP is mentioned in /etc at port 5060
    of TCP or UDP.

    Bill
     
    Bill Cunningham, Mar 19, 2014
    #3
  4. That package certainly works. But what is the difference in a SOCK_UDP
    and a SOCK_RAW. I looked at the protocols ASCII file in my /etc directory
    and SCTP port 132 is listed there. Could this work?

    socket(AF_INET,SOCK_RAW,132);

    ?
     
    Bill Cunningham, Mar 20, 2014
    #4
  5. Bill Cunningham

    Jorgen Grahn Guest

    Not /that/ young -- there has been support in Linux for at least 5
    years or so, and your first instinct would be "let's fit it into the
    existing sockets API". But perhaps the multihoming features of SCTP
    makes that pointless.

    Actually, now I /do/ see that manual page, on the machines at work.
    It comes from libsctp though, also known as the lksctp-tools package.

    /Jorgen
     
    Jorgen Grahn, Mar 20, 2014
    #5
  6. Bill Cunningham

    Rick Jones Guest

    Port numbers are not the same as protocol numbers and are not provided
    in the socket() call. "132" does appear to be the protocol value for
    IPPROTO_SCTP, however I'd suggest using the mnemonic rather than the
    magic constant.

    rick jones
     
    Rick Jones, Mar 20, 2014
    #6
  7. So you mean the macro you have mentioned rather than the literal decimal
    132. When would SIP be used? What I want to do is write a simple client that
    will handshake a SIP service(r). Now I think SIP uses ports 5060 or 5061
    depending on whether or not there's encryption. SIP responds to a 3 way
    hanhshake if the RFC I read I understand and can remember right.

    Bill
     
    Bill Cunningham, Mar 20, 2014
    #7
  8. What do you mean "But perhaps the multihoming features of SCTP makes that
    pointless."
    I'm no expert obviously on this but I read SCTP was very versatile. And that
    SIP, RTP, and RTCP would use SCTP as a transport layer like it uses UDP and
    can use TCP. But I would think TCP would add to the payload unnecessarily.

    Bill
     
    Bill Cunningham, Mar 21, 2014
    #8
  9. Bill Cunningham

    Jorgen Grahn Guest

    I meant maybe the multihoming features of SCTP make it impossible to
    use the BSD sockets API: binding your socket to one address,
    connecting to one address and so on. I don't know; I haven't studied
    it.
    I don't see any connection between this paragraph and the one above,
    so no comment.

    /Jorgen
     
    Jorgen Grahn, Mar 21, 2014
    #9
  10. Bill Cunningham

    Rick Jones Guest

    When one creates a socket, one provides information as to what sort of
    addressing will be used - what the manpage under linux calls the
    "domain." This is specifying the type of addressing but does not
    provide any addressing itself. The second parameter, "type" says what
    sort of socket you want and will specify or imply the semantics of
    calls like send and recv. For example, if you specify SOCK_DGRAM then
    you will be given only one message's worth of information at most even
    if there are two messages queued to the socket and you provide enough
    buffer in the recv() call. If you specify SOCK_STREAM, you will
    recieve as much data as is in the socket whether it is one message's
    worth or N. Put another way, SOCK_DGRAM means "message" semantics and
    SOCK_STREAM means "byte stream" semantics. The third parameter
    specifies which transport protocol you wish to use. You can specify
    one explicitly, or you can pass-in a value of 0 in which case the
    stack will pick one for you based on the address family (first
    parameter) and socket semantics (second parameter) you have specified.
    In somewhat geeky terms, the selection of protocol determines what the
    value of the "protocol" field of the IP (or in general "network
    layer") header will be. It will be how when IP receives a datagram it
    will know to which protocol hander it should be given.

    Port numbers come into play when you either start calling connect(),
    or sendto(). They are (part of) how the transport protocol (eg TCP,
    UDP, SCTP) further demuxes traffic it has been given by IP. You
    would, presumably connect() to or sendto() a SIP service listening on
    a given port number, with a given transport protocol, at a given IP
    address.

    rick jones
     
    Rick Jones, Mar 21, 2014
    #10
  11. It seems like 0 as the 3rd parameter of scoket() would simply specify
    what is passed to the 2nd parameter. I have read that sctp man 7 page and
    you can create a one-to-one socket or a multicast one-to-many socket. Which
    I guess is what SCTP does. I think for the sake of brevity for now I'll just
    stick with UDP for SIP. But I guess it can run on TCP too. Maybe much
    slower.

    Bill
     
    Bill Cunningham, Mar 22, 2014
    #11
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.