Hot!How should “tcpip_tcp_client_server” be modified for getting JST?

Author
yts
Super Member
  • Total Posts : 581
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
2019/03/11 21:19:52 (permalink)
0

How should “tcpip_tcp_client_server” be modified for getting JST?

My board (homemade) : PIC32MZ2048EFM064-I/PT + LAN8740Ai
Environment for developing firmware: Harmony 2.06, MPLAB X 5.15, XC32 2.15.

JST (Japanese standard time) is obtained with Firefox or Internet Explorer when you visit the website http://ntp-a1.nict.go.jp/cgi-bin/time/. The response may be plain text (for example, “Tue Mar 12 11:58:32 2019 JST”).

However, JST cannot be obtained when the firmware “tcpip_tcp_client_server” is used.
The firmware returns only the “Connection Closed” message (see an attached figure).

I wander which part of firmware “tcpip_tcp_client_server” I should modify.

Attached Image(s)

#1

9 Replies Related Threads

    rainad
    Moderator
    • Total Posts : 1119
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: How should “tcpip_tcp_client_server” be modified for getting JST? 2019/03/12 07:11:40 (permalink)
    0
    You could turn on wireshark and log the connection between the browser and this server.
    Once you know what exactly data they exchange, you can replicate with a TCP socket.
    Or use the SNTP module and point it to this server, if you just need the time.
     
    #2
    yts
    Super Member
    • Total Posts : 581
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    Re: How should “tcpip_tcp_client_server” be modified for getting JST? 2019/03/14 17:58:47 (permalink)
    0
    Thank you for your replay.

    I add the some headers to the GET command following the log data (see figure), but I cannot get any response from the server. I tried to find out the receive buffer in the firmware now.
     
    post edited by yts - 2019/03/14 18:25:25

    Attached Image(s)

    #3
    rainad
    Moderator
    • Total Posts : 1119
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: How should “tcpip_tcp_client_server” be modified for getting JST? 2019/03/15 07:01:42 (permalink)
    0
    First look with wireshark to check if the server really replies with some packet which is discarded by the stack.
     
    #4
    yts
    Super Member
    • Total Posts : 581
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    Re: How should “tcpip_tcp_client_server” be modified for getting JST? 2019/03/15 17:33:01 (permalink)
    0
    Thank you for your suggestion.

    The attached file is the log of packet exchange between my PC and NTP Server.
    Server sent back the date including strings "Sat Mar 16 09:04:11 2019 JST".

    By the way, can Wireshark monitor the data-flow between my PIC board and NTP Server?
    post edited by yts - 2019/03/19 20:07:33
    #5
    rainad
    Moderator
    • Total Posts : 1119
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: How should “tcpip_tcp_client_server” be modified for getting JST? 2019/03/18 09:04:56 (permalink)
    5 (1)
    You need to be able to capture the traffic between your board and the NTP server. For this you need a switch with a mirroring port, or a network sniffer, etc.
    The log for the communication between your PC and the NTP server could serve as a model, to see what's going on. 
    When you get that capture, please attach the wireshark capture file, I cannot see the details in a text file.
     
    #6
    yts
    Super Member
    • Total Posts : 581
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    Re: How should “tcpip_tcp_client_server” be modified for getting JST? 2019/03/18 15:45:26 (permalink)
    0
    Hi. rainad;

    Thank you for your advice.
    I ordered the switch with a mirroring port yesterday and I will get it soon.

    yts
    #7
    yts
    Super Member
    • Total Posts : 581
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    Re: How should “tcpip_tcp_client_server” be modified for getting JST? 2019/04/11 20:36:52 (permalink)
    0
    Hi. rainad;

    JST can be successfully obtained (see the attached figure).

    I monitored the dataflow by using the switch with a mirroring port (NETGEAR GS105E) and replicated the synchronize packet.

    I modified the structure TCP_OPTIONS in the “tcp.c”

    #define TCP_OPTIONS_END_OF_LIST     (0x00u)        // End of List TCP Option Flag
    #define TCP_OPTIONS_NO_OP           (0x01u)        // No Op TCP Option
    #define TCP_OPTIONS_MAX_SEG_SIZE    (0x02u)        // Maximum segment size TCP flag
    #define TCP_OPTIONS_WINDOW_SCALE    (0x03u)        // Window scale
    #define TCP_OPTIONS_SACK_PERMITTED  (0x04u)        // SACK permitted

    typedef struct
    {
        uint8_t        Kind;                        // Type of option
        uint8_t        Length;                      // Length
        TCPIP_UINT16_VAL    MaxSegSize;            // Maximum segment size
        uint8_t        nop1;
           uint8_t        Kind1;                       // Type of option
        uint8_t        Length1;                     // Length
        uint8_t        WindowScale;                // WindowScale
        uint8_t        nop2;
        uint8_t        nop3;
           uint8_t        Kind2;                       // Type of option
        uint8_t        Length2;                     // Length
           
    } TCP_OPTIONS;    


    and gave the appropriate values to the TCP_OPTIONS “option” in the in the “tcp.c”.


                    options.Kind = TCP_OPTIONS_MAX_SEG_SIZE;
                    options.Length = 0x04;
                    options.nop1=0x01;
                    options.Kind1 = TCP_OPTIONS_WINDOW_SCALE;           
                    options.Length1 = 0x03;       
                    options.WindowScale =0x02;
                    options.nop2=0x01;
                    options.nop3=0x01;         
                    options.Kind2=TCP_OPTIONS_SACK_PERMITTED;
                    options.Length2 = 0x02;       


    Thanks a lot.

    Now I wander if the option settings (shown above) can be made by using Harmony configurator.

    yts


    post edited by yts - 2019/04/12 01:31:22

    Attached Image(s)

    #8
    rainad
    Moderator
    • Total Posts : 1119
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: How should “tcpip_tcp_client_server” be modified for getting JST? 2019/04/16 11:30:23 (permalink)
    0
    Hi yts,
    Good to hear your problem is solved now.
    About the options that you introduced: scaling, sack, etc. these are indeed useful additions for the TCP state machine. They are on the TODO list and will be integrated in the near future.
     
     
     
    #9
    yts
    Super Member
    • Total Posts : 581
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    Re: How should “tcpip_tcp_client_server” be modified for getting JST? 2019/04/16 16:23:33 (permalink)
    0
    Hi. rainad;

    Thanks to you, I can study much deeply the structures of Ethernet frame, IP packet, TCP/UDP segment.
    I am looking forward to the integration.

    yts


    #10
    Jump to:
    © 2019 APG vNext Commercial Version 4.5