This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/CC3220SF-LAUNCHXL: TCP stack problems

Part Number: CC3220SF-LAUNCHXL
Other Parts Discussed in Thread: CC3220SF

Tool/software: Code Composer Studio

Hi, everyone!
disclaimer: my board works like this algorithm:

power on -> how is wake up? -> tcp (open socket, send/recv, close sock) -> hibernate

two problems

1) when my device is power on first time (power +3.3v pluged) it connect to AP and try to do sl_Connect three times. ALWAYS, first time is returned -111 error (SL_ERROR_BSD_ECONNREFUSED)

int32_t bsdTcpClient(uint32_t ipAddr, uint16_t port, int16_t sid, uint16_t lenght, uint8_t tx)
{
    int16_t         sockId;
    int32_t         status = -1;

    PowerMeasure_CB.ipV4Addr.sin_family = SL_AF_INET;
    PowerMeasure_CB.ipV4Addr.sin_port = sl_Htons(port);
    PowerMeasure_CB.ipV4Addr.sin_addr.s_addr = sl_Htonl(ipAddr);

    if (sid < 0)
    {
        /* Need to open socket  */
        sockId = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
        ASSERT_ON_ERROR(sockId);

        /* Make connection establishment */
        status = sl_Connect(sockId, ( SlSockAddr_t *)&PowerMeasure_CB.ipV4Addr, sizeof(SlSockAddrIn_t));
        if( status < 0 ) {
            sl_Close(sockId);
            ASSERT_ON_ERROR(status);
            return status;
        }
    }
    else
    {
        /* Socket is already opened */
        sockId = sid;
    }
}

When it continue working - no problems! Everything perfect. There is no problem when device and server locate in one local net. Only when >=2 routers between device and server.

2) I don't know why but when I do sl_Close(sockId);  after send/recv data device  doesn't sent F. frame and server trys to sent F. frame many time

let me show you tcpdump:

where 192.168.20.195:2222 is server and 192.168.20.194 is cc3220sf device

you can see: no ACK to close connection correctly.

and it wakes up and do new socket connection every one minute.

after sl_Close(); a do sl_Stop(timeout); and go to hibernate.

What I have to do to open and close socket connections correctly?

  • Hi Shamil,

    For the case where you are getting the TCP connection refused error only during the first connection attempt, I'm not sure what might be the cause. Do you have a network capture showing the first unsuccessful connection attempt and a subsequent successful attempt? Any differences in the TCP packets sent out by the CC3220 could provide some clues.

    For the case where the TCP socket is not closed properly by the CC3220, what is the timeout for sl_Stop()? If the timeout expires before the TCP socket can finish handling queued packets and close gracefully, then the socket will not send the FIN ACK. Try setting a larger timeout or putting in a delay after sl_Close() but before sl_Stop() to see if that fixes things.

    Regards,
    Michael
  • Hi,

    I think reason can be very simple. Maybe he call sl_Connect() in moment when is not connected to WLAN yet.

    Jan

  • void socketClose (void){
        int32_t status = -1;
        status = sl_Close(PowerMeasure_appData.sockID);
        ASSERT_ON_ERROR(status);
    
        UART_PRINT("    Socket close \n\r");
    }
    
    #define SL_STOP_TIMEOUT             (1000)
    
    int32_t wifiStop(void){
        int32_t status = -1;
        status = sl_Stop(SL_STOP_TIMEOUT);
        return status;
    }
    
    
    void allStop(void){
                    socketClose();
                    wifiStop();
    }
    

    one second between sock close and wifi stop

  • how fix it?
  • >> Do you have a network capture showing the first unsuccessful connection attempt and a subsequent successful attempt?
    tcpdump -w will be ok?
  • first connect and cocket closing (if you ask i'll sent *.pcap file)

    dropped privs to tcpdump tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes 09:14:15.452467 IP 192.168.20.194.50384 > 192.168.20.195.2222: Flags [S], seq 402080368, win 33580, options [mss 1460,nop,nop,nop,eol], length 0 0x0000: 4500 0030 0010 0000 7f06 90e2 c0a8 14c2 0x0010: c0a8 14c3 c4d0 08ae 17f7 4270 0000 0000 0x0020: 7002 832c 3039 0000 0204 05b4 0101 0100 09:14:15.452557 IP 192.168.20.195.2222 > 192.168.20.194.50384: Flags [S.], seq 3686572925, ack 402080369, win 29200, options [mss 1460], length 0 0x0000: 4500 002c 0000 4000 4006 8ff6 c0a8 14c3 0x0010: c0a8 14c2 08ae c4d0 dbbc a37d 17f7 4271 0x0020: 6012 7210 aaf4 0000 0204 05b4 09:14:15.504719 IP 192.168.20.194.50384 > 192.168.20.195.2222: Flags [.], ack 1, win 33580, length 0 0x0000: 4500 0028 0011 0000 7f06 90e9 c0a8 14c2 0x0010: c0a8 14c3 c4d0 08ae 17f7 4271 dbbc a37e 0x0020: 5010 832c daaf 0000 0000 0000 0000 09:14:15.504767 IP 192.168.20.194.50384 > 192.168.20.195.2222: Flags [P.], seq 1:69, ack 1, win 33580, length 68 0x0000: 4500 006c 0012 0000 7f06 90a4 c0a8 14c2 0x0010: c0a8 14c3 c4d0 08ae 17f7 4271 dbbc a37e 0x0020: 5018 832c 0e1a 0000 4000 0000 0100 0000 0x0030: 8491 d5d5 0bd9 2964 f571 4832 a452 f49b 0x0040: 2f1c ed8b 32f8 3c7a 9329 1d9c e57a 561e 0x0050: e638 0ddf 724b e5fa d1b6 4f25 0c38 aaf6 0x0060: 9bbb c042 09fb d543 b92b 93c6 09:14:15.504786 IP 192.168.20.195.2222 > 192.168.20.194.50384: Flags [.], ack 69, win 29200, length 0 0x0000: 4500 0028 14e9 4000 4006 7b11 c0a8 14c3 0x0010: c0a8 14c2 08ae c4d0 dbbc a37e 17f7 42b5 0x0020: 5010 7210 aaf0 0000 09:14:15.508329 IP 192.168.20.195.2222 > 192.168.20.194.50384: Flags [P.], seq 1:5, ack 69, win 29200, length 4 0x0000: 4500 002c 14ea 4000 4006 7b0c c0a8 14c3 0x0010: c0a8 14c2 08ae c4d0 dbbc a37e 17f7 42b5 0x0020: 5018 7210 aaf4 0000 4000 0000 09:14:15.565197 IP 192.168.20.194.50384 > 192.168.20.195.2222: Flags [.], ack 5, win 33580, length 0 0x0000: 4500 0028 0013 0000 7f06 90e7 c0a8 14c2 0x0010: c0a8 14c3 c4d0 08ae 17f7 42b5 dbbc a382 0x0020: 5010 832c da67 0000 0000 0000 0000 09:14:15.565251 IP 192.168.20.195.2222 > 192.168.20.194.50384: Flags [P.], seq 5:69, ack 69, win 29200, length 64 0x0000: 4500 0068 14eb 4000 4006 7acf c0a8 14c3 0x0010: c0a8 14c2 08ae c4d0 dbbc a382 17f7 42b5 0x0020: 5018 7210 ab30 0000 bfa9 fde0 84b7 7f7e 0x0030: 1c6d 19c9 4595 69f6 aec8 b18b 99d7 3398 0x0040: 1e1c 980f 4dcf b7b5 d788 c488 d4db 2788 0x0050: 6184 3ae8 9e13 a337 e4bd b80b e3f2 0003 0x0060: c59b 930b 572a 4306 09:14:15.607353 IP 192.168.20.194.50384 > 192.168.20.195.2222: Flags [.], ack 69, win 32120, length 0 0x0000: 4500 0028 0014 0000 7f06 90e6 c0a8 14c2 0x0010: c0a8 14c3 c4d0 08ae 17f7 42b5 dbbc a3c2 0x0020: 5010 7d78 dfdb 0000 0000 0000 0000 09:14:15.612847 IP 192.168.20.194.50384 > 192.168.20.195.2222: Flags [F.], seq 69, ack 69, win 33580, length 0 0x0000: 4500 0028 0015 0000 7f06 90e5 c0a8 14c2 0x0010: c0a8 14c3 c4d0 08ae 17f7 42b5 dbbc a3c2 0x0020: 5011 832c da26 0000 0000 0000 0000 09:14:15.613779 IP 192.168.20.195.2222 > 192.168.20.194.50384: Flags [F.], seq 69, ack 70, win 29200, length 0 0x0000: 4500 0028 14ec 4000 4006 7b0e c0a8 14c3 0x0010: c0a8 14c2 08ae c4d0 dbbc a3c2 17f7 42b6 0x0020: 5011 7210 aaf0 0000 09:14:15.882365 IP 192.168.20.195.2222 > 192.168.20.194.50384: Flags [F.], seq 69, ack 70, win 29200, length 0 0x0000: 4500 0028 14ed 4000 4006 7b0d c0a8 14c3 0x0010: c0a8 14c2 08ae c4d0 dbbc a3c2 17f7 42b6 0x0020: 5011 7210 aaf0 0000 09:14:16.412332 IP 192.168.20.195.2222 > 192.168.20.194.50384: Flags [F.], seq 69, ack 70, win 29200, length 0 0x0000: 4500 0028 14ee 4000 4006 7b0c c0a8 14c3 0x0010: c0a8 14c2 08ae c4d0 dbbc a3c2 17f7 42b6 0x0020: 5011 7210 aaf0 0000 09:14:17.512357 IP 192.168.20.195.2222 > 192.168.20.194.50384: Flags [F.], seq 69, ack 70, win 29200, length 0 0x0000: 4500 0028 14ef 4000 4006 7b0b c0a8 14c3 0x0010: c0a8 14c2 08ae c4d0 dbbc a3c2 17f7 42b6 0x0020: 5011 7210 aaf0 0000 09:14:19.672391 IP 192.168.20.195.2222 > 192.168.20.194.50384: Flags [F.], seq 69, ack 70, win 29200, length 0 0x0000: 4500 0028 14f0 4000 4006 7b0a c0a8 14c3 0x0010: c0a8 14c2 08ae c4d0 dbbc a3c2 17f7 42b6 0x0020: 5011 7210 aaf0 0000 09:14:23.912369 IP 192.168.20.195.2222 > 192.168.20.194.50384: Flags [F.], seq 69, ack 70, win 29200, length 0 0x0000: 4500 0028 14f1 4000 4006 7b09 c0a8 14c3 0x0010: c0a8 14c2 08ae c4d0 dbbc a3c2 17f7 42b6 0x0020: 5011 7210 aaf0 0000 09:14:32.552352 IP 192.168.20.195.2222 > 192.168.20.194.50384: Flags [F.], seq 69, ack 70, win 29200, length 0 0x0000: 4500 0028 14f2 4000 4006 7b08 c0a8 14c3 0x0010: c0a8 14c2 08ae c4d0 dbbc a3c2 17f7 42b6 0x0020: 5011 7210 aaf0 0000 09:14:49.832356 IP 192.168.20.195.2222 > 192.168.20.194.50384: Flags [F.], seq 69, ack 70, win 29200, length 0 0x0000: 4500 0028 14f3 4000 4006 7b07 c0a8 14c3 0x0010: c0a8 14c2 08ae c4d0 dbbc a3c2 17f7 42b6 0x0020: 5011 7210 aaf0 0000

  • that was my fail. fixed.
    problem with sl_Close(sd); still actual!
  • I have still have problems with sl_Close() - it doesn't close socket correctly.

    pls help!

  • i have problems with sl_Close() still...