CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Location
    Canada
    Posts
    277

    send network data at specific data rate

    Hello,

    as part of a school project I need to be able to send network data at a user specified data rate (ie. 9600bps for example). I need to write this in C, preferebly just with standard libraries and/or UNIX standard libraries if needed. I am somewhat familiar with UNIX socket programming, but as far as I can tell I can't accomplish this with sockets. sockets seems too high level for this kind of thing. I am not sure even how to begin this or where to start. This isn't even really the main part of the project, so it's not something covered in the course. If anyone could point me to some articles/tutorials/documentation and/or tell me how to go about doing this and what functions and system calls to use that would be much appreciated. Google wasn't much help, although maybe I didn't search all the right words.

    Thanks,

    Latem
    Last edited by Latem; April 1st, 2006 at 11:48 AM.
    Being a pessimist is wonderful; you are either proven right, or pleasantly surprised.

  2. #2
    Join Date
    Jun 2001
    Location
    Switzerland
    Posts
    4,443

    Re: send network data at specific data rate

    Maybe I don' understand your question right, but networks don't work that way. If you want to "tunnel" a serial connection through a network, then you write a "server" program taht reads from the serial port at the given baud and writes to the network. The "client" on the other side will read from the network socket and write to the "user" at a given baud rate.

    Assuming that your network is much faster than the baud rate you need (this is in most cases a safe assumption), it is just an exercise in buffering.

    Does this help a bit, or did I misundertand you completely?
    Gabriel, CodeGuru moderator

    Forever trusting who we are
    And nothing else matters
    - Metallica

    Learn about the advantages of std::vector.

  3. #3
    Join Date
    Feb 2004
    Location
    Canada
    Posts
    277

    Re: send network data at specific data rate

    Sorry, I should have explained in greater detail. I'll simplify the project to just the networking aspect so it's easier to understand hopefully. So lets say there are 2 programs: a client and a server program. They are suppose to communicate. So the client sends data to the server program, and the server just reads it. They are connected on the local network. When a user starts the programs they need to specify a data rate that the two will communicate at. The network transmission data rate between the two programs needs to be as constant as possible to what the user indicated, which is also smaller than the network capabilities. I guess, another way of wording it is that basically I need to limit the network data rate the programs will transmit at to the constant data rate that the user specifies. If I just use the standard sockets API, AFAIK the data will be sent at variable speeds, and at whatever rate the network will allow based on network usage and other things. It can be assumed that the data to be sent is already in the memory, so it just needs to be sent. Like I am not reading anything from serial port or anything like that. This is just a requirement of the project, so I a have to try and implement it. Hopefully that makes more sense.

    Latem
    Being a pessimist is wonderful; you are either proven right, or pleasantly surprised.

  4. #4
    Join Date
    Jun 2001
    Location
    Switzerland
    Posts
    4,443

    Re: send network data at specific data rate

    Well, that is a strange requirement you have. I think you won't be able to limit the physical transport rate ovet the network, because of obvious reasons. The only thing I can think of is an abstraction lyer, that "surrounds" the network (that is the socket api) both on the server and the client side and simulates a data transmission at a given baud. Think of it as a pseudo-socket implementation, that uses the real sockets on the lower side and exposes a "constant speed socket" to the client.

    Is this a way to go for you?
    Gabriel, CodeGuru moderator

    Forever trusting who we are
    And nothing else matters
    - Metallica

    Learn about the advantages of std::vector.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured