FreeRTOS Win32 simulator C++

I have bumped your privilege level on the forum. You should be able to attach a file now.

Thank you Richard,

here is the file
WireSharkLog.zip (258.2 KB)
Best Regards

Hi @Fortunato ,
In pcap file, every packet is captured twice. I guess youā€™re running server/client in same laptop. Then wireshark captures every packet twice (First by sender, second by receiver). But thatā€™s not the cause of long transmission.

By your description:

The pcap file shows lots of packet are transmitted. A lot more than 16320 bytes. (>150 packets with 1460 bytes payload) In my opinion, the device sent a lot of packets to the server in 10 seconds. How do you know the packet isnā€™t sent successfully in server side? Please help to check the it in application layer.

1726 36.896668 192.168.0.251 192.168.10.161 20102 51016 TCP 1514 20102 ā†’ 51016 [PSH, ACK] Seq=9 Ack=17 Win=2920 Len=1460
1727 36.896680 192.168.0.251 192.168.10.161 20102 51016 TCP 1514 [TCP Retransmission] 20102 ā†’ 51016 [PSH, ACK] Seq=9 Ack=17 Win=2920 Len=1460
1728 36.896729 192.168.0.251 192.168.10.161 20102 51016 TCP 1514 20102 ā†’ 51016 [PSH, ACK] Seq=1469 Ack=17 Win=2920 Len=1460
1729 36.896735 192.168.0.251 192.168.10.161 20102 51016 TCP 1514 [TCP Retransmission] 20102 ā†’ 51016 [PSH, ACK] Seq=1469 Ack=17 Win=2920 Len=1460
ā€¦
2309 37.465803 192.168.0.251 192.168.10.161 20102 51016 TCP 1514 20102 ā†’ 51016 [PSH, ACK] Seq=257733 Ack=17 Win=2920 Len=1460
2310 37.465806 192.168.0.251 192.168.10.161 20102 51016 TCP 1514 [TCP Retransmission] 20102 ā†’ 51016 [PSH, ACK] Seq=257733 Ack=17 Win=2920 Len=1460
2313 37.465847 192.168.0.251 192.168.10.161 20102 51016 TCP 1514 20102 ā†’ 51016 [PSH, ACK] Seq=259193 Ack=17 Win=2920 Len=1460
2314 37.465851 192.168.0.251 192.168.10.161 20102 51016 TCP 1514 [TCP Retransmission] 20102 ā†’ 51016 [PSH, ACK] Seq=259193 Ack=17 Win=2920 Len=1460

Thanks!
BR,
Actory

Hi ActoryOu,

Yes, You are correct. I am running the server/client in the same laptop.

Yes, There are a lot of data. I have to send and image of 480x272 size (two bytes for each pixel).

I experienced a bit slow, so I used Wireshark to see the communication. The sender is

192.168.0.251, the receiver is 192.168.10.161.

So you are suggesting that [TCP Retrasmission] it does not mean that the sender did not receive the ack in time but it is only a Wireshark double capture.
Improvement is speed I have seen when I mdofied ipconfigTCP_TX_BUFFER_LENGTH.

Thank you very much

In my earlier post I pressed ā€œSendā€ too early.

I experienced a bit slow, so I used Wireshark to see the communication

The Win32 simulation is quiet slow. On thing that may help is lowering the clock frequency from 1000 to 100:

#define configTICK_RATE_HZ   100U

The main purpose of the WinSim project is learning and creating demos. It is not really useful for real-life or commercial applications.

Unlike a ā€œnativeā€ port, the WinSim port simulates everything: semaphores, tasks, clock-ticks. But it does so in a very correct way.

Have you already tried to increase the TCP WIN size?

You can set all TCP stream parameters by using FREERTOS_SO_WIN_PROPERTIES.
Have a try with these settings:

xWinProps.lTxBufSize = 8 * ipconfigTCP_MSS; /* Unit: bytes */
xWinProps.lTxWinSize = 4;                   /* Unit: MSS */
xWinProps.lRxBufSize = 8 * ipconfigTCP_MSS; /* Unit: bytes */
xWinProps.lRxWinSize = 4;                   /* Unit: MSS */

FreeRTOS_setsockopt( xSocket,
                     0,
                     FREERTOS_SO_WIN_PROPERTIES,
                     ( void * ) &xWinProps,
                     sizeof( xWinProps ) );

Please set these settings right after creating a socket. You can apply it to a listening socket. Child sockets will automatically inherit all properties from the listening socket.

When using connect(), make the sockopt settings before calling connect().

If you can, please show a new PCAP file. You can use a filter ip.addr==192.168.0.251 and store with File->Store specified packets->Selected packets only. Thank you

Hi Fortunato,

I would like to align the development environment with you.

The MSVC FreeRTOS_Plus_TCP_Minimal_Windows_Simulator demo can be compiled without problem.

It looks like you converts the MSVC FreeRTOS_Plus_TCP_Minimal_Windows_Simulator demo to a eclipse project and having the problem ā€œxLogStreamBuffer->LENGTH could not be resolvedā€ in Logging_WinSim.c.

Can you share your eclipse project or reproduce steps?

Hello, I will be glad to share it.
I used Eclipse to export project. But the size exeed maximum.
Please allow me temporary 10M

Hi, The size of the project is 7.5M, I can not upload.

Allow me to temporary upload bigger file.

Can you put your project in a git repo and share the link?

Could you provide email to which send invite?

I do not know any other way to share the project.

Thanks

Hi Fortunato,

Not sure if I observed the problem you are having.

I download this project at FreeRTOS/FreeRTOS-Plus/Demo/RtosWin32. After fixing some include path and configuration problems, I can see the semantic error reported by eclipse code analyzer.

Field ā€˜LENGTHā€™ could not be resolved

The semantic error doesnā€™t stop the eclipse from compilation and can be configured according to userā€™s preference.

Besides the include path problem, there are still other compilation problems in this project:

  • Multiple definition :
    1. The same source file is included in the project multiple times
    2. Only WinPcap network interface is required for windows simulator project
  • Missing config :
    It looks like your eclipse project is created from WIN32-Mingw and integrate the FreeRTOS_Plus_TCP_Minimal_Windows_Simulator project. The TCP minimal demo uses this config file. You might compare and merge the differences.
  • Undefined reference :
    Source file is not included in this project.

My suggestion is to put the focus on fixing the compilation error type C/C++ problem first which I mentioned above and feedback further problem.

Ok, thank you very much

I will try your indication.

I think the WinSim is a great project.

I see it is able to use RS232, in polling way but it is enough, and read from file.

Also TCP despite speed is perfect. I wonder why it canā€™t be very very fast since every

device on PC, clock, time to access HDdisk, RAM and so on are getting faster.

Best

Hi,
Yes the semantic error does not stop the eclipse. I am working.
But It is not clear how to make that eclipse check this one.

  • Multiple definition
    I cannot find which file has been included multiple time. Is there an option, a tool, in eclipse that show me?
    Only winPCap network interface is required. Do you mean I have to remove from source\portable\NetworkInterface all except WinPCap?
  • Missing Config
    I did a merge, with fear because I wanted that the win simulator still works.
  • Undefined Reference
    Are these in winmm or wpcap libraries? I have added these libraries in paths and symbol.
    Best Regards

Hi Fortunato,

Only winPCap network interface is required. Do you mean I have to remove from source\portable\NetworkInterface all except WinPCap?

Yes. We only need the winpcap network interface in windows simulator project.

I did a merge, with fear because I wanted that the win simulator still works.

Some of the configurations are used in the demo and network interface. There will be undefine errors if not defined.

Are these in winmm or wpcap libraries? I have added these libraries in paths and symbol.

Yes. Besides wpcap, I also see other undefined reference in the project you share. Probably there are still some missing files or main.c also need to be merged.

 undefined reference to `ulApplicationGetNextSequenceNumber'
 undefined reference to `vApplicationIPNetworkEventHook'
 undefined reference to `vLoggingPrintf'
 undefined reference to `xApplicationGetRandomNumber'

I havenā€™t successfully compile your project and run. There may be more problems than I mentioned.

Hi,
I will clone myself the project in a fresh machine, to replicate your problem. But I need more time.
Best

Hi Fortunado,

Also TCP despite speed is perfect. I wonder why it canā€™t be very very fast since every device on PC, clock, time to access HDdisk, RAM and so on are getting faster

You may have missed it, but I answered the question about speed already a while ago in this post. Please have a look at it.

Why a SimSim application is not so fast:

The WinSim project is realistic but indeed quite slow, that has to do with the fact that tasks and interrupts must be simulated.
A FreeRTOS task is implemented with an ā€œencapsulatedā€ Windows thread.
A WinSim application also has real threads: for logging to stdout, and to access the WinPCAP library.

The synchronisation between a task and a thread is a difficult one:

  • tasks may only use FreeRTOS APIā€™s, especial when blocking is needed, while a task may never call normal windows APIā€™s like STDIO or WINSOCK.

  • threads may only use regular Windows APIā€™s, while they may never call FreeRTOS or FreeRTOS+TCP APIs.

The above two rules make cooperation very difficult: a task can not unblock a thread, and a thread can not unblock (notify) a task.
When the rules are not strictly obeyed, the application will crash sooner or later.


Also, Iā€™d like to hear about the status of you project, are all issues solved?

1 Like

Hi Hein Tibosh,

I followed your indication to speed up the system, only increasing size of buffer

had some advantage.

About my project, well I set up a TCP/IP connection with a C# program. And I build a kind of

remote desktop with the C# program. So in the C# program I have a 480x272 display, touch with mouse and in the FreeRTOS program side I change form and handle click events (i have the memory map of the display)
Despite I send compressed data (zip) of the display, it is a little bit slow. But working.
Thanks very much