This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Http over PPP problem

Hi forum users,
A few days ago I started struggling with the following problem. When opening three or more concurrent http sessions over a PPP interface my application crashes and the debugger tells me it always happens with the top of the call stack beeing in ppp_send() or ppp_receive() functions.

It seems both those functions fail when trying to allocate some memory by calling alloc_mem().
Suspecting this could have been caused by unproper resources allocation for the whole TcpNet stuff, I tryed raising the memory pool size in NetConfig.c but with no luck. Is such memory really allocated from the TcpNet memory pool or am I on the wrong way?

One more bit. No such effect is visible using concurrent modbus sessions on the same TCP / PPP stack (enabling every available modbus communications however reduces the number of concurrent http sessions I can trigger without crashing). I realize http involves more resources and I still suspect an incorrect sizing for memory. It also seems there is some relationship with the size of the file being transferred by http. Bigger files make the thing crash even with less concurrent http sessions.

A couple questions arise. Can anyone suggest a reasonable rule-of-thumb for choosing a 'safe' memory pool size? I'm using a total of 10 sockets, with max 5 http sessions. No application level protocol is enabled other then http.

And then... is an error allocating memory at the sending/receiving stage of the PPP layer supposed to be a critical error? Could this otherwise be handled by discarding the packet the way we do at MAC level? This is more a confirmation request than a true question, since I suspect some reliability is assumed at that level of the stack.

TIA
Regards,
Andrea

Parents
  • We have not found such problems with PPP examples. If a PPP fails to allocate memory, it should hang in an sys_error() error handler function. In your case it does not hang, so it seems this is not your real problem.

    Are you using an RTOS? With an RTOS you should first check the stack size for TCPnet task. In our examples, we use 800 byte stack for TCPnet RTX task. Check also the private stack declarations. If you are using several modules and:

    extern U64 tcp_stack[256];
    


    might be dangerous if in external file it is not declared with the same size as declared here and you are using sizeof (tcp_stack). If tcp_stack is not allocated correctly, you may receive sporadic application crashes when using an RTOS.

    TCPnet functions are not reentrant so it is dangerous to call them from several tasks.

    If you are using Interrupt Serial driver, check the size of the IRQ stack, set in the startup.s file. The IRQ Stack Size shall be 256 bytes or more.

    If you are using __swi functions, then also the Supervisor Stack shall be set to 128 bytes or more.

    Franc

Reply
  • We have not found such problems with PPP examples. If a PPP fails to allocate memory, it should hang in an sys_error() error handler function. In your case it does not hang, so it seems this is not your real problem.

    Are you using an RTOS? With an RTOS you should first check the stack size for TCPnet task. In our examples, we use 800 byte stack for TCPnet RTX task. Check also the private stack declarations. If you are using several modules and:

    extern U64 tcp_stack[256];
    


    might be dangerous if in external file it is not declared with the same size as declared here and you are using sizeof (tcp_stack). If tcp_stack is not allocated correctly, you may receive sporadic application crashes when using an RTOS.

    TCPnet functions are not reentrant so it is dangerous to call them from several tasks.

    If you are using Interrupt Serial driver, check the size of the IRQ stack, set in the startup.s file. The IRQ Stack Size shall be 256 bytes or more.

    If you are using __swi functions, then also the Supervisor Stack shall be set to 128 bytes or more.

    Franc

Children