network-programmingipv4packet-capturesctp

How to remove "IPv4 address parameter" field (optional) in a SCTP packet in Ubuntu


I want to send a SCTP packet to a server using L2TP VPN in Ubuntu 20.04. For this purpose, I have set up my L2TP VPN and I can successfully test the connection using ping command. Now my ifconfig output is as follows:

enp0s31f6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet x.x.x.x  netmask 255.255.255.248  broadcast p.p.p.p
    ...

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
    ...

ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1400
        inet y.y.y.y  netmask 255.255.255.255  destination q.q.q.q
    ...

In this output, x.x.x.x is my LAN IP and y.y.y.y is my VPN IP.

But when I send my INIT SCTP packet, two optional fields, i.e. IPv4 address parameter, is appeared in INIT chunk subtree in Wireshark log as follows. These parameters contain my IPs.

Stream Control Transmission Protocol, Src Port: a (a), Dst Port: b (b)
    Source port: a
    Destination port: b
    Verification tag: 0x00000000
    [Association index: 65535]
    Checksum: 0x06cf8029 [unverified]
    [Checksum Status: Unverified]
    INIT chunk (Outbound streams: 3, inbound streams: 3)
        Chunk type: INIT (1)
            0... .... = Bit: Stop processing of the packet
            .0.. .... = Bit: Do not report
        Chunk flags: 0x00
        Chunk length: 52
        Initiate tag: 0xd1d6f19b
        Advertised receiver window credit (a_rwnd): 106496
        Number of outbound streams: 3
        Number of inbound streams: 3
        Initial TSN: 1216798565
        IPv4 address parameter (Address: x.x.x.x)
        IPv4 address parameter (Address: y.y.y.y)
        Supported address types parameter (Supported types: IPv4)
        ECN parameter
        Forward TSN supported parameter

and finally, here is the sent and received packets:

enter image description here

I think that IPv4 address parameter (Address: x.x.x.x) (my LAN IP) in my INIT packet, has caused to receive the ABORT packet from server. When I turn off my VPN, these two optional fields do not appear.

How can I remove these two optional fields in Ubuntu after turning up my VPN?


Solution

  • Manual client IP assignment is required to remove "IPv4 address parameter" fields in a SCTP packet. So, the following codes is required in C++:

    int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
    if(sock < 0)
    {
        //handle error
    }
    struct sockaddr_in clientAddr;
    memset(&clientAddr,0, sizeof(struct sockaddr_in));
    clientAddr.sin_family = AF_INET;
    clientAddr.sin_addr.s_addr = inet_addr("y.y.y.y"); 
    clientAddr.sin_port = htons(a);
    if( ::bind(sock, (struct sockaddr*)&clientAddr, sizeof(struct sockaddr)) < 0 )
    {
        //handle error
    }