Transfer time estimate

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christophe F. [MS]

    Transfer time estimate

    Hello,
    I'm looking for sample code in C# that will estimate the transfer time for a
    file between two machines (taking into account bandwidth and latency).
    --
    Regards,
    CF


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Transfer time estimate

    Christophe,

    You can't really do that unless you are in the process of sending the
    file. The best you can do is make estimates on each side of the process.

    When you begin to sending/receive, store the time. As you send/receive
    each group of bytes, you take note of the elapsed time (the current time
    minus the start time). Divide that by the number of bytes sent/received to
    determine how long it takes to send one byte. Then, multiply that ratio by
    the number of bytes left, and you will have the approximate time left to
    perform the transfer.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Christophe F. [MS]" <chrisfie@onlin e.microsoft.com > wrote in message
    news:e7mlf3rZFH A.3488@tk2msftn gp13.phx.gbl...[color=blue]
    > Hello,
    > I'm looking for sample code in C# that will estimate the transfer time for
    > a file between two machines (taking into account bandwidth and latency).
    > --
    > Regards,
    > CF
    >[/color]


    Comment

    • Christophe F. [MS]

      #3
      Re: Transfer time estimate

      Thank you Nicholas, I guess I should not use the File.Copy method to
      transfer file then, but file streaming?

      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
      message news:uZlNo%23rZ FHA.1456@TK2MSF TNGP15.phx.gbl. ..[color=blue]
      > Christophe,
      >
      > You can't really do that unless you are in the process of sending the
      > file. The best you can do is make estimates on each side of the process.
      >
      > When you begin to sending/receive, store the time. As you send/receive
      > each group of bytes, you take note of the elapsed time (the current time
      > minus the start time). Divide that by the number of bytes sent/received
      > to determine how long it takes to send one byte. Then, multiply that
      > ratio by the number of bytes left, and you will have the approximate time
      > left to perform the transfer.
      >
      > Hope this helps.
      >
      >
      > --
      > - Nicholas Paldino [.NET/C# MVP]
      > - mvp@spam.guard. caspershouse.co m
      >
      > "Christophe F. [MS]" <chrisfie@onlin e.microsoft.com > wrote in message
      > news:e7mlf3rZFH A.3488@tk2msftn gp13.phx.gbl...[color=green]
      >> Hello,
      >> I'm looking for sample code in C# that will estimate the transfer time
      >> for a file between two machines (taking into account bandwidth and
      >> latency).
      >> --
      >> Regards,
      >> CF
      >>[/color]
      >
      >[/color]


      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: Transfer time estimate

        Christophe,

        If you want to have the ability to perform these calculations as the
        copy takes place, then yes.

        You might also be able to do the same thing with a call to the
        SHFileOperation function through the P/Invoke layer. I believe it will
        allow you to specify a callback which is called during the operation.

        Hope this helps.


        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m

        "Christophe F. [MS]" <chrisfie@onlin e.microsoft.com > wrote in message
        news:OSWLtUsZFH A.2076@TK2MSFTN GP15.phx.gbl...[color=blue]
        > Thank you Nicholas, I guess I should not use the File.Copy method to
        > transfer file then, but file streaming?
        >
        > "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote
        > in message news:uZlNo%23rZ FHA.1456@TK2MSF TNGP15.phx.gbl. ..[color=green]
        >> Christophe,
        >>
        >> You can't really do that unless you are in the process of sending the
        >> file. The best you can do is make estimates on each side of the process.
        >>
        >> When you begin to sending/receive, store the time. As you
        >> send/receive each group of bytes, you take note of the elapsed time (the
        >> current time minus the start time). Divide that by the number of bytes
        >> sent/received to determine how long it takes to send one byte. Then,
        >> multiply that ratio by the number of bytes left, and you will have the
        >> approximate time left to perform the transfer.
        >>
        >> Hope this helps.
        >>
        >>
        >> --
        >> - Nicholas Paldino [.NET/C# MVP]
        >> - mvp@spam.guard. caspershouse.co m
        >>
        >> "Christophe F. [MS]" <chrisfie@onlin e.microsoft.com > wrote in message
        >> news:e7mlf3rZFH A.3488@tk2msftn gp13.phx.gbl...[color=darkred]
        >>> Hello,
        >>> I'm looking for sample code in C# that will estimate the transfer time
        >>> for a file between two machines (taking into account bandwidth and
        >>> latency).
        >>> --
        >>> Regards,
        >>> CF
        >>>[/color]
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Christophe F. [MS]

          #5
          Re: Transfer time estimate

          Great, I got this exemple to work:



          --
          --
          Cdt,
          CF
          "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
          message news:%23GDSwgsZ FHA.3328@TK2MSF TNGP09.phx.gbl. ..[color=blue]
          > Christophe,
          >
          > If you want to have the ability to perform these calculations as the
          > copy takes place, then yes.
          >
          > You might also be able to do the same thing with a call to the
          > SHFileOperation function through the P/Invoke layer. I believe it will
          > allow you to specify a callback which is called during the operation.
          >
          > Hope this helps.
          >
          >
          > --
          > - Nicholas Paldino [.NET/C# MVP]
          > - mvp@spam.guard. caspershouse.co m
          >
          > "Christophe F. [MS]" <chrisfie@onlin e.microsoft.com > wrote in message
          > news:OSWLtUsZFH A.2076@TK2MSFTN GP15.phx.gbl...[color=green]
          >> Thank you Nicholas, I guess I should not use the File.Copy method to
          >> transfer file then, but file streaming?
          >>
          >> "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote
          >> in message news:uZlNo%23rZ FHA.1456@TK2MSF TNGP15.phx.gbl. ..[color=darkred]
          >>> Christophe,
          >>>
          >>> You can't really do that unless you are in the process of sending the
          >>> file. The best you can do is make estimates on each side of the
          >>> process.
          >>>
          >>> When you begin to sending/receive, store the time. As you
          >>> send/receive each group of bytes, you take note of the elapsed time (the
          >>> current time minus the start time). Divide that by the number of bytes
          >>> sent/received to determine how long it takes to send one byte. Then,
          >>> multiply that ratio by the number of bytes left, and you will have the
          >>> approximate time left to perform the transfer.
          >>>
          >>> Hope this helps.
          >>>
          >>>
          >>> --
          >>> - Nicholas Paldino [.NET/C# MVP]
          >>> - mvp@spam.guard. caspershouse.co m
          >>>
          >>> "Christophe F. [MS]" <chrisfie@onlin e.microsoft.com > wrote in message
          >>> news:e7mlf3rZFH A.3488@tk2msftn gp13.phx.gbl...
          >>>> Hello,
          >>>> I'm looking for sample code in C# that will estimate the transfer time
          >>>> for a file between two machines (taking into account bandwidth and
          >>>> latency).
          >>>> --
          >>>> Regards,
          >>>> CF
          >>>>
          >>>
          >>>[/color]
          >>
          >>[/color]
          >
          >[/color]


          Comment

          Working...