1 Reply Latest reply on Oct 7, 2018 11:38 PM by riya

    wiced_tcp_send_packet raw data error

    vikas.asthana_2307976

      Hi,

       

      I am trying to send tcp packet from client to server but it's sending packet of lengths longer than expected.

       

      My client code for tcp after connecting to server 192.168.0.1:50007 is:

       

      wiced_tcp_create_socket(&socket, WWD_STA_INTERFACE);

      wiced_tcp_bind(&socket,SERVER_PORT);

      wiced_tcp_connect(&socket,&serverAddress,SERVER_PORT,5000);

      wiced_packet_create_tcp(&socket, TCP_PACKET_MAX_DATA_LENGTH, &tx_packet, (uint8_t**)&tx_data, &available_txdata_length);

      sprintf(tx_data,"\xFE\x03\x02\x01\xED\x03\xE9\x6C\0");

      wiced_packet_set_data_end(tx_packet, (uint8_t*) tx_data + strlen(tx_data));

      wiced_tcp_send_packet(&socket, tx_packet);

      wiced_packet_delete(tx_packet);

       

      I am trying to send raw data packet: 0xFE 0x03 0x02 0x01 0xED 0x03 0xE9 0x6C. Is the above code correct way to send this data?

      On the server I see the following:

       

      INVALID TCP RX MSG:

      [0] fe - [1] 03 - [2] 02 - [3] 01 - [4] ed - [5] 03 - [6] e9 - [7] 6c - [8] fe - [9] 80 - [10] 00 - [11] 00 - [12] 00 - [13] 00 - [14] 00 - [15] 00 - [16] a6 - [17] 08 - [18] ea - [19] ff - [20] fe - [21] d9 - [22] cd - [23] 10 - [24] 00 - [25] 00 - [26] 00 - [27] 00 - [28] 00 - [29] 00 - [30] 00 - [31] 00 - [32] 00 - [33] 00 - [34] 00 - [35] 00 - [36] 00 - [37] 00 - [38] 00 - [39] 00 - [40] 00 - [41] 00 - [42] 00 - [43] 00 - [44] 00 - [45] 00 - [46] 00 - [47] 00 - [48] 00 - [49] 00 - [50] 00 - [51] 00 - [52] 00 - [53] 00 - [54] 00 - [55] 00 - [56] 00 - [57] 00 - [58] 00 - [59] 00 - [60] 00 - [61] 00 - [62] 00 - [63] 00 - [64] 00 - [65] 00 - [66] 00 - [67] 00 - [68] 00 - [69] 00 - [70] 00 - [71] 00 - [72] 00 - [73] 00 - [74] 00 - [75] 00 - [76] 00 - [77] 00 - [78] 00 - [79] 00 - [80] 00 - [81] 00 - [82] 00 - [83] 00 - [84] 00 - [85] 00 - [86] 00 - [87] 00 - [88] 00 - [89] 00 - [90] 00 - [91] 00 - [92] 00 - [93] 00 - [94] 00 - [95] 00 - [96] 00 - [97] 00 - [98] 00 - [99] 00 - [100] 00 -[101] 00 -[102] 00 -[103] 00 -[104] 00 -[105] 00 -[106] 00 -[107] 00 -[108] 00 -[109] 00 -[110] 00 -[111] 00 -[112] 00 -[113] 00 -[114] 00 -[115] 00 -[116] 00 -[117] 00 -[118] 00 -[119] 00 -[120] 00 -[121] 00 -[122] 00 -[123] 00 -[124] 00 -[125] 00 -[126] 00 -[127] 00 -[128] 00 -[129] 00 -[130] 00 -[131] 00 -[132] 00 -[133] 00 -[134] 00 -[135] 00 -[136] 00 -[137] 00 -[138] 00 -[139] 00 -[140] 00 -[141] 00 -[142] 00 -[143] 00 -[144] 00 -[145] 00 -[146] 00 -[147] 00 -[148] 00 -[149] 00 -[150] 00 -[151] 00 -[152] 00 -[153] 00 -[154] 00 -[155] 00 -[156] 00 -[157] 00 -[158] 00 -[159] 00 -[160] 00 -[161] 00 -[162] 00 -[163] 00 -[164] 00 -[165] 00 -[166] 00 -[167] 00 -[168] 00 -[169] 00 -[170] 00 -[171] 00 -[172] 00 -[173] 00 -[174] 00 -[175] 00 -[176] 00 -[177] 00 -[178] 00 -[179] 00 -[180] 00 -[181] 00 -[182] 00 -[183] 00 -[184] 00 -[185] 00 -[186] 00 -[187] 00 -[188] 00 -[189] 00 -[190] 00 -[191] 00 -[192] 00 -[193] 00 -[194] 00 -[195] 00 -[196] 00 -[197] 00 -[198] 00 -[199] 00 -[200] 00 -[201] 00 -[202] 00 -[203] 00 -[204] 00 -[205] 00 -[206] 00 -[207] 00 -[208] 00 -[209] 00 -[210] 00 -[211] 00 -[212] 00 -[213] 00 -[214] 00 -[215] 00 -[216] 00 -[217] 00 -[218] 00 -[219] 00 -[220] 00 -[221] 00 -[222] 00 -[223] 00 -[224] 00 -[225] 00 -[226] 00 -[227] 00 -[228] 00 -[229] 00 -[230] 00 -[231] 00 -[232] 00 -[233] 00 -[234] 00 -[235] 00 -[236] 00 -[237] 00 -[238] 00 -[239] 00 -[240] 00 -[241] 00 -[242] 00 -[243] 00 -[244] 00 -[245] 00 -[246] 00 -[247] 00 -[248] 00 -[249] 00 -[250] 00 -[251] 00 -[252] 00 -[253] 00 -[254] 00 -[255] 00 -[256] 00 -[257] 00 -[258] 00 -[259] 00 -[260] 00 -[261] 00 -[262] 00 -[263] 00 -end

       

      The packet should be 8 bytes only till [7] but I am unable to find how it is getting extra bytes. Can someone tell what may be going wrong?

      If I try same on a laptop with wifi connected to server and send this data as raw on port 192.168.0.1 using Real Term application, I get correct response.

       

      using Wiced 6.0

      Server : WPA2 Mixed PSK

       

      Client output:

      Starting WICED vWiced_006.000.001.0005

      Platform CYW943907AEVAL1F initialised

      Started FreeRTOS v9.0.0

      Initialising LwIP v2.0.2

      DHCP CLIENT hostname WICED IP

      WLAN MAC Address : A4:08:EA:D9:CD:10

      WLAN Firmware    : wl0: Oct 23 2017 03:40:42 version 7.15.168.101 (r674438) FWID 01-13cae12

      WLAN CLM         : API: 12.2 Data: 9.10.74 Compiler: 1.31.3 ClmImport: 1.36.3 Creation: 2017-10-23 03:36:41

      Looking for SSID: ABC-xxxx

      Scan complete in 2603 milliseconds

      wwd_wifi_join_specific: set_ssid result (err 0); left network

      Join status: Connected to ABC-xxxx

      Setting IPv6 link-local address

      Obtaining IPv4 address via DHCP

      IPv6 Network ready IP: FE80::A608:EAFF:FED9:CD10

      IPv4 Network ready IP: 192.168.0.2

      LED Test passed!

      Able to create socket. Error = [0]

      Able to bind socket. Error = [0]

      Gateway: 192.168.0.1

      Server Port: 50007

      Success connect. Error = [0]

       

      Does anyone know how to resolve this?

       

      Thanks.

      -Vikas.

        • 1. Re: wiced_tcp_send_packet raw data error
          riya

          Hello,

          The TCP client implementation looks correct. You can also check with tcp_client snip provided in WICED to verify your usage. The only problem I can think of is in the declaration of tx_data. Are you initializing it with some default value?

          Also kindly print the TCP packet length before sending the packet and try to debug the problem.

              printf("%d %s, %d\n", __LINE__,  __FUNCTION__,     packet->nx_packet_length    );

          Your packet length should be same as the data(strlen of data) written in the location pointed by tx_data pointer.