How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux? - Embedded

This is a discussion on How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux? - Embedded ; Hello Groups, I am a newbie to this groups and I am struggling with a problem and I need your help in this regard. I have lwip ( low weight ip) tcp/ip stack and tftp (client & server tftp-hpa-0.40) source ...

+ Reply to Thread
Results 1 to 19 of 19

Thread: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

  1. How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

    Hello Groups,

    I am a newbie to this groups and I am struggling with a problem and I
    need your help in this regard.

    I have lwip ( low weight ip) tcp/ip stack and tftp (client & server
    tftp-hpa-0.40) source .Both are compiling well on linux with out any
    problem. The tftp source is also working good when I installed it on my
    linux system (Redhat linux 9.0 , gcc 3.2.2) for getting and putting
    files.

    I need to get a tftp/udp/ip stack for an embedded system to upgrade the
    firmware of a chip. So the problem is I want to tell my tftp source I
    have with me to use lwip tcp/ip stack instead of the tcp/ip stack that
    comes from linux . Some how I should be able to do the getting and
    putting of files from/to a remote host using this lwip tcp/ip stack and
    not the stack that comes from linux.So for this I need to tell my tftp
    source to use lwip ..right? Please tell me how can I accomplish this ?
    The lwip user forum did not give me the information what I want...But
    one guy told me that I can make use of the LD_PRELOAD environment
    variable to do this .is this right? and I also heard that I need to
    make some modifications to the linux kernel and recompile it as tcp/ip
    stack is a part of kernel ..if this is so...? Please tell me the
    detailed procedure how can I do this , as I need this at any case for
    my work . I would be thankful for any kind of suggestions ..

    Regards
    CDP


  2. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

    If you want reprogram the low level of ip stack you must see
    man 7 packet


  3. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?


    "CDP" wrote in message
    news:1120483676.467995.136610@g49g2000cwa.googlegr oups.com...

    > I have lwip ( low weight ip) tcp/ip stack and tftp (client & server
    > tftp-hpa-0.40) source .Both are compiling well on linux with out any
    > problem. The tftp source is also working good when I installed it on my
    > linux system (Redhat linux 9.0 , gcc 3.2.2) for getting and putting
    > files.


    You haven't defined your problem precisely enough for any Linux folks to
    help you. You'll have to talk to the lwip folks.

    DS



  4. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

    David Schwartz wrote:
    > "CDP" wrote in message
    > news:1120483676.467995.136610@g49g2000cwa.googlegr oups.com...
    >
    >
    >
    > You haven't defined your problem precisely enough for any Linux folks to
    > help you.



    The problem is I want to make my tftp source I have with me to use lwip
    and not the tcp/ip stack that comes from Linux under linux . The tftp
    source is my application layer .This application layer should use
    udp/ip protocols of lwip under linux , Hope you got my problem by now .

    The tftp is a simple protocol to get and put files to/from a remote
    server.I installed my tftp source on Redhat Linux PC , and its getting
    and putting files from/to a remote host using the default tcp/ip stack
    from Linux
    without any problem.So instead of the default tcp/ip stack from linux
    it should use lwip under linux , So how can I make this under linux ???


    For this I was told that I must do some modifications in the linux
    kernel and recompile it ...is this the exact soultion to do this, if
    this is, please tell me the detailed procedure to do this..?


    > You'll have to talk to the lwip folks.
    >
    > DS


    I asked the lwip folks and I had posted my question in the lwip
    user forum , only one guy answered me that I sould use LD_PRELOAD
    environment variable of Linux to do this ...

    I am herewith giving the reply , he had given me , please see below

    First, build the library. Second set LD_PRELOAD to the path of the
    library. Third, run tftp. That's it.

    The above is the reply he had given me

    So please adivce me in this issue , I guess its a linux specific
    question , If you guys want me to post any code my tftp source I can do
    that , its nothing but tftp-hpa-0.40.I need help in this desperatley.

    Regards
    CDP


  5. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

    CDP wrote:
    ) I asked the lwip folks and I had posted my question in the lwip
    ) user forum , only one guy answered me that I sould use LD_PRELOAD
    ) environment variable of Linux to do this ...
    )
    ) I am herewith giving the reply , he had given me , please see below
    )
    ) First, build the library. Second set LD_PRELOAD to the path of the
    ) library. Third, run tftp. That's it.
    )
    ) The above is the reply he had given me

    Have you actually tried doing what this guy said ?
    If you set LD_PRELOAD to point to a library, that will be loaded
    and any functions in there replace the 'standard' functions.

    I would also assume that the lwip source has detailed instructions
    how to use it in your applications.


    SaSW, Willem
    --
    Disclaimer: I am in no way responsible for any of the statements
    made in the above text. For all I know I might be
    drugged or something..
    No I'm not paranoid. You all think I'm paranoid, don't you !
    #EOT

  6. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?



    Willem wrote:
    > CDP wrote:
    > ) I asked the lwip folks and I had posted my question in the lwip
    > ) user forum , only one guy answered me that I sould use LD_PRELOAD
    > ) environment variable of Linux to do this ...
    > )
    > ) I am herewith giving the reply , he had given me , please see below
    > )
    > ) First, build the library. Second set LD_PRELOAD to the path of the
    > ) library. Third, run tftp. That's it.
    > )
    > ) The above is the reply he had given me
    >
    > Have you actually tried doing what this guy said ?
    > If you set LD_PRELOAD to point to a library, that will be loaded
    > and any functions in there replace the 'standard' functions.


    I tried it , by setting the LD_PRELOAD environement variable to
    the path of the shared library of lwip I have with me , which I already
    compiled on my linux system. By setting it I started my tftp
    application , but I did not observe any change... its like ,its using
    the normal tcp/ip stack from linux , but not lwip. If the standard
    functions are replaced with this , I should observe some change
    ...right? But I did nt ..How can I set it actually whether the standard
    functions are replaced..?What about the idea of kernel modifications
    and recompiling ..Do you guys have any idea in my problem..?

    >
    > I would also assume that the lwip source has detailed instructions
    > how to use it in your applications.


    The guys in lwip forum , do more with a kind protocol related
    things, and if post something related to linux kernel ..or something of
    my problem,I guess they can not reply, because I tried it
    already.Regarding the documentation lwip , I had a glance at it already
    and I did not find useful information..

    >
    >
    > SaSW, Willem
    > --
    > Disclaimer: I am in no way responsible for any of the statements
    > made in the above text. For all I know I might be
    > drugged or something..
    > No I'm not paranoid. You all think I'm paranoid, don't you !
    > #EOT



  7. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

    In comp.os.linux.embedded CDP wrote:
    : Hello Groups,

    : I am a newbie to this groups and I am struggling with a problem and I
    : need your help in this regard.

    : I have lwip ( low weight ip) tcp/ip stack and tftp (client & server
    : tftp-hpa-0.40) source .Both are compiling well on linux with out any
    : problem. The tftp source is also working good when I installed it on my
    : linux system (Redhat linux 9.0 , gcc 3.2.2) for getting and putting
    : files.

    : I need to get a tftp/udp/ip stack for an embedded system to upgrade the
    : firmware of a chip.

    I'm guessing that your embedded system will not have a Linux kernel
    and that you are wanting to build a tftp server as a dedicated application
    in an embedded device? If this is a the case then this isn't a linux
    problem and you have lots of other problems.

    If you did have the Linux kernel in the embedded device you'd use it's
    tcp/ip stack, and using lwip wouldn't be an issue.

    I think maybe people are just confused by what it is you are trying to do.



    : So the problem is I want to tell my tftp source I
    : have with me to use lwip tcp/ip stack instead of the tcp/ip stack that
    : comes from linux . Some how I should be able to do the getting and
    : putting of files from/to a remote host using this lwip tcp/ip stack and
    : not the stack that comes from linux.So for this I need to tell my tftp
    : source to use lwip ..right? Please tell me how can I accomplish this ?
    : The lwip user forum did not give me the information what I want...But
    : one guy told me that I can make use of the LD_PRELOAD environment
    : variable to do this .is this right? and I also heard that I need to
    : make some modifications to the linux kernel and recompile it as tcp/ip
    : stack is a part of kernel ..if this is so...? Please tell me the
    : detailed procedure how can I do this , as I need this at any case for
    : my work . I would be thankful for any kind of suggestions ..

    : Regards
    : CDP


  8. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?



    J Jackson wrote:
    > In comp.os.linux.embedded CDP wrote:
    > : Hello Groups,
    >
    > : I am a newbie to this groups and I am struggling with a problem and I
    > : need your help in this regard.
    >
    > : I have lwip ( low weight ip) tcp/ip stack and tftp (client & server
    > : tftp-hpa-0.40) source .Both are compiling well on linux with out any
    > : problem. The tftp source is also working good when I installed it on my
    > : linux system (Redhat linux 9.0 , gcc 3.2.2) for getting and putting
    > : files.
    >
    > : I need to get a tftp/udp/ip stack for an embedded system to upgrade the
    > : firmware of a chip.
    >
    > I'm guessing that your embedded system will not have a Linux kernel
    > and that you are wanting to build a tftp server as a dedicated application
    > in an embedded device? If this is a the case then this isn't a linux
    > problem and you have lots of other problems.
    >
    > If you did have the Linux kernel in the embedded device you'd use it's
    > tcp/ip stack, and using lwip wouldn't be an issue.
    >
    > I think maybe people are just confused by what it is you are trying to do.


    Hi Jackson,


    Yes your are right , the embedded system do not have a linux kernel
    and it has a third party rtos , which is very small and it is only
    menat for scheduling.This doesn't have to do anything with what I asked
    ...?

    The reason why I am using Linux is basically , as a test environment
    to test my tftp application combined with lwip .If I can tell my tftp
    application to use lwip instead of tcp/ip stack from linux , then I can
    test my lwip stack as well as tftp application (ofcourse on linux ).
    This is what I am trying to do. I guess there is no confusion by now.
    If it works fine then the tftp/udp/ip stack is ready for actual
    implementation.

    As I am using linux now on my PC , so what do you think would be the
    way to solve my problem ..? Hope you got my problem by now ...saying
    oit in raw words again , tftp application should use lwip for all its
    transfers... on linux

    Please advice me if you have any idea..?

    Regards
    CDP


  9. Re: How to tell an application to use a custom tcp/ip stack insteadof tcp/ip stack from linux?

    CDP wrote:
    >
    >
    > I tried it , by setting the LD_PRELOAD environement variable to
    > the path of the shared library of lwip I have with me , which I already
    > compiled on my linux system. By setting it I started my tftp
    > application , but I did not observe any change... its like ,its using
    > the normal tcp/ip stack from linux , but not lwip. If the standard
    > functions are replaced with this , I should observe some change
    > ..right?


    I don't quite know what you'd expect to observe. TCP/IP stacks don't
    typically display a lot of output on screen telling you what is going
    on. What did *you* expect to see? Why did you expect that? (E.g., did
    the makers of the alternate stack tell you "expect to see X happen"?)

    It's possible that the lack of observed difference means the alternate
    stack was running just fine. There might only be observable differences
    when things go wrong, if one stack is meant to be a drop-in replacement
    for the other.

  10. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?



    John-Paul Stewart wrote:
    > CDP wrote:
    > >
    > >
    > > I tried it , by setting the LD_PRELOAD environement variable to
    > > the path of the shared library of lwip I have with me , which I already
    > > compiled on my linux system. By setting it I started my tftp
    > > application , but I did not observe any change... its like ,its using
    > > the normal tcp/ip stack from linux , but not lwip. If the standard
    > > functions are replaced with this , I should observe some change
    > > ..right?

    >
    > I don't quite know what you'd expect to observe. TCP/IP stacks don't
    > typically display a lot of output on screen telling you what is going
    > on. What did *you* expect to see? Why did you expect that? (E.g., did
    > the makers of the alternate stack tell you "expect to see X happen"?)
    >
    > It's possible that the lack of observed difference means the alternate
    > stack was running just fine. There might only be observable differences
    > when things go wrong, if one stack is meant to be a drop-in replacement
    > for the other.


    Hi John,

    The makers of alternate tcp/ip stack (lwip) did not mention
    anything to happen after the replacement.So do you think that the
    alternate stack is working fine with my tftp application? I can not
    even see a single difference b/w the linux tcp/ip stack and lwip , may
    be I might have done wrong with my LD_PRELOAD environment variable . I
    cross checked the LD_PRELOAD environment variable , its set to the path
    of shared library gen erated by means of compiling the stack. Do you
    know any other means of cross checking ? whether what I have done is
    right?

    One more thing is do you have any idea about kernel modification and
    recompilation for this problem.., I mean stack replacement problem
    under linux ..?


  11. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

    CDP wrote:
    > ..right? But I did nt ..How can I set it actually whether the standard
    > functions are replaced..?What about the idea of kernel modifications


    Perhaps by ltrace the program execution, or strace for open(2) calls?

    Yong Huang


  12. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

    >John-Paul Stewart wrote:
    >> CDP wrote:
    >> >
    >> >
    >> > I tried it , by setting the LD_PRELOAD environement variable to
    >> > the path of the shared library of lwip I have with me , which I already
    >> > compiled on my linux system. By setting it I started my tftp
    >> > application , but I did not observe any change... its like ,its using
    >> > the normal tcp/ip stack from linux , but not lwip. If the standard
    >> > functions are replaced with this , I should observe some change
    >> > ..right?

    >>
    >> I don't quite know what you'd expect to observe. TCP/IP stacks don't
    >> typically display a lot of output on screen telling you what is going
    >> on. What did *you* expect to see? Why did you expect that? (E.g., did
    >> the makers of the alternate stack tell you "expect to see X happen"?)
    >>
    >> It's possible that the lack of observed difference means the alternate
    >> stack was running just fine. There might only be observable differences
    >> when things go wrong, if one stack is meant to be a drop-in replacement
    >> for the other.

    >
    > Hi John,
    >
    > The makers of alternate tcp/ip stack (lwip) did not mention
    >anything to happen after the replacement.So do you think that the
    >alternate stack is working fine with my tftp application? I can not
    >even see a single difference b/w the linux tcp/ip stack and lwip , may
    >be I might have done wrong with my LD_PRELOAD environment variable . I
    >cross checked the LD_PRELOAD environment variable , its set to the path
    >of shared library gen erated by means of compiling the stack. Do you
    >know any other means of cross checking ? whether what I have done is
    >right?


    Just a shot in the dark ... can you do netstats or sockstats that show
    the packets that used to use the default tcp/ip stack don't use it any
    more?

    --gregbo
    gds at best dot com


  13. Re: How to tell an application to use a custom tcp/ip stack insteadof tcp/ip stack from linux?

    On 5 Jul 2005, CDP stated:
    > The makers of alternate tcp/ip stack (lwip) did not mention
    > anything to happen after the replacement.So do you think that the
    > alternate stack is working fine with my tftp application? I can not
    > even see a single difference b/w the linux tcp/ip stack and lwip , may
    > be I might have done wrong with my LD_PRELOAD environment variable . I
    > cross checked the LD_PRELOAD environment variable , its set to the path
    > of shared library gen erated by means of compiling the stack. Do you
    > know any other means of cross checking ? whether what I have done is
    > right?


    Well, you could stick some debugging fprintf()s into the library and
    see if they are printed.

    > One more thing is do you have any idea about kernel modification and
    > recompilation for this problem.., I mean stack replacement problem
    > under linux ..?


    Unless the lwip stack was written to fit into the Linux kernel
    networking layer, you'll pretty much have to rewrite it --- and the
    TCP/IP stack isn't exactly easily replaceable, except with something
    that satisfies the same internal interface contracts and locking
    rules (many of which aren't documented).

    It's *possible*, of course, but extremely difficult, and definitely not
    worth it for a test run!

    (But if you *did* replace the kernel's TCP/IP stack, it's likely that
    nothing would need to be recompiled. At least, if you did it properly.)

    --
    `But of course, GR is the very best relativity for the masses.'
    --- Wayne Throop

  14. Re: How to tell an application to use a custom tcp/ip stack insteadof tcp/ip stack from linux?

    CDP wrote:
    >
    > John-Paul Stewart wrote:
    >
    >>CDP wrote:
    >>
    >>>
    >>> I tried it , by setting the LD_PRELOAD environement variable to
    >>>the path of the shared library of lwip I have with me , which I already
    >>>compiled on my linux system. By setting it I started my tftp
    >>>application , but I did not observe any change... its like ,its using
    >>>the normal tcp/ip stack from linux , but not lwip. If the standard
    >>>functions are replaced with this , I should observe some change
    >>>..right?

    >>
    >>I don't quite know what you'd expect to observe. TCP/IP stacks don't
    >>typically display a lot of output on screen telling you what is going
    >>on. What did *you* expect to see? Why did you expect that? (E.g., did
    >>the makers of the alternate stack tell you "expect to see X happen"?)
    >>
    >>It's possible that the lack of observed difference means the alternate
    >>stack was running just fine. There might only be observable differences
    >>when things go wrong, if one stack is meant to be a drop-in replacement
    >>for the other.

    >
    >
    > Hi John,
    >
    > The makers of alternate tcp/ip stack (lwip) did not mention
    > anything to happen after the replacement.So do you think that the
    > alternate stack is working fine with my tftp application?


    The tests so far are inconclusive. You can't determine one way or the
    other at the moment. Since they don't tell you to expect certain
    differences, that *might* indicate that are no differences to observe.

    > I can not
    > even see a single difference b/w the linux tcp/ip stack and lwip , may


    If lwip is supposed to be a drop-in replacement, I would suggest that
    you *shouldn't* see any difference. Which is why I said the tests so
    far have been inconclusive. Point is, do *not* assume there is anything
    wrong when you don't see a difference.

    Another poster suggested using strace to watch to see if the library is
    being opened. That sounds like a very good idea to me. (I wish I'd
    thought to suggest it, myself!) Try (from a Bash prompt):

    export LD_PRELOAD=/path/to/lwip
    strace -eopen yourprogram

    You should see a line resembling:

    open("/path/to/lwip", O_RDONLY) = 3

    which would indicate that the library was opened successfully.

  15. Re: How to tell an application to use a custom tcp/ip stack insteadof tcp/ip stack from linux?

    > I tried it , by setting the LD_PRELOAD environement variable to
    > the path of the shared library of lwip I have with me , which I already
    > compiled on my linux system.


    Did you export LD_PRELOAD? Please give the exact commands used to set
    LD_PRELOAD. If you don't export it, the new program won't see it.

    > By setting it I started my tftp
    > application , but I did not observe any change...


    Are you supposed to?

    To see if the library is loaded, do a ps to grab the PID of the process,
    and then check in

    /proc/WHATEVERYOURPIDIS/maps

    And see if the library is listed there. If it is, it's linked in.

    However, looking on the lwip site, I don't see any indications of a
    Linux port, so I'm not sure whether or not any of this actually works.
    But give it a try.

    Also, I would include more information when making inquiries. For
    example, letting everyone know exactly what commands you are using, what
    the names of the files are, what you have tried, and what you expected
    the results to be.

    > its like ,its using
    > the normal tcp/ip stack from linux , but not lwip.


    How can you tell this? From what I can tell, there really shouldn't be
    any visible differences, except that for large loads you can handle more
    with less RAM.

    Jon
    ----
    Learn to program using Linux assembly language
    http://www.cafeshops.com/bartlettpublish.8640017

  16. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

    Hi John,

    I started my research from this morning to find out whether my
    library is actually loaded, using strace as you & some other guy (yong
    ) said , but came to know that my library is not loaded and there are
    certain undefined symbols in my library . That 's why its not getting
    loaded . I am trying to clear those errors ,and is taking a long time
    for me because I do not have much idea on libraries and run time
    linking .So I am doing a kind of fight , you know ...so it took long
    time for me to reply .

    I do not know if this whole procedure works out , and if its the
    right way to proceed.Do you guys have any other idea apart from this
    how to solve my actual problem , because I am afraid that discussion
    may take a different route .If so , please let me know

    regards
    CDP


  17. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

    Hi Jonathan ,

    Yes I exported the library using LD_PRELOAD using

    bash# export LD_PRELOAD= / path to my library
    and then started my tftp

    to your second point , yes you are right , the folks in lwip did not
    make a linux port .... thats why I am a bit more concerned you know to
    know about this and I need this desperatley to proceed further in my
    work

    Regarding quoting the files and commands , lwip stack is very big ,
    you know with a lot of files, I know I should be precise but to make it
    simple

    I do a make it generates a lot of .o files and a library is generated
    , I was told by a guy in lwip to make use of this library and set
    LD_PRELOAD to the path of this library and start my tftp , thats it
    ...nothing else.

    Any suggestions????

    regards
    CDP






    also as John said , I did strace to see if the library is opened , but
    its not because I have some undefined symbols in my library.
    Do you have any other ideas to solve my problem , apart from this
    LD_PRELOAD?


  18. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

    If I know that my lwip stack is ported then I can do the netstats ,
    ifconfigs to know this
    As I said , my basic problem is tell the linux system to use the lwip
    for all the transfers..

    Regarding the LD_PRELOAD I have some undefined symbols in my shared
    library .. trying to sort out those..

    Any other ideas???


  19. Re: How to tell an application to use a custom tcp/ip stack instead of tcp/ip stack from linux?

    Hi Nix ,


    >Unless the lwip stack was written to fit into the Linux kernel
    >networking layer, you'll pretty much have to rewrite it --- and the
    >TCP/IP stack isn't exactly easily replaceable, except with something
    >that satisfies the same internal interface contracts and locking
    >rules (many of which aren't documented).


    I do not know if lwip stack is written to fit into the linux kernel
    , but I can say it has very thing needed from memory managment to all
    oridnary protocols. I know its not so easy to replace linux tcp/ip
    stack and there are lot of things to be considered, what I mean to say
    is , I just want to say Linux kernel to use lwip for all the data
    transfers instead of the normal tcp/ip stack from Linux . Hope you got
    my question

    >It's *possible*, of course, but extremely difficult, and definitely not
    >worth it for a test run!


    Yes for test run , its not definitely worth to replace the stack
    completely with lwip ..I know it ... I don wanna replace it as I said ,
    I just want to say the kernel to use lwip for all the data transfers
    ..... and not the deafult stack

    Any ideas , please let me know...????



    (But if you *did* replace the kernel's TCP/IP stack, it's likely that
    nothing would need to be recompiled. At least, if you did it properly.)


+ Reply to Thread