CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2010
    Posts
    74

    Reason for traffic disappearence between server&client

    Hello alls!
    My problem is in traffic disappearence between server & client.
    I want determine how investigate reasons of this issue and solve,
    so I am looking for discussion and prompts more, than for mperfect solution(of course, I
    appreciate solution but...)

    So, what takes place:
    Server and client both are self written, unblockjng sockets and TCP/IP protocol.
    Transmission over internet, server and client are deeply protected by firewalls.
    More, server now installed on JVM.

    Behavior: Traffic between S&C starts perfectly, in test mode I am able regulate packets number
    and traffic accordingly. But at random moment traffic goes down practically to zero, after few seconds traffic again comes to normal. On serevr side I have state WSAWOULDBLOCK at these moments.
    Look at attached screen, where real traffic is red and expected one is blue.
    The main problem now how to find and chech reason for traffic lost, and how to solve this problem. Because quasereal time and 100% packets are critical for this apllications.
    Thanks alot for your ideas.

  2. #2
    Join Date
    Mar 2010
    Posts
    74

    Re: Reason for traffic disappearence between server&client

    Attachment is here)
    Attached Images Attached Images  

  3. #3
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Reason for traffic disappearence between server&client

    If I understand you correctly, you have an algorithm that regulates the rate of transmission, and the algorithm sometimes causes the traffic to drop to zero.

    If so, then post your algorithm. You state that the traffic goes to zero at "random moments", but the graph you show does not look very random, and actually seems somewhat periodic, such that the algorithm might not be working as expected.

    Mike

  4. #4
    Join Date
    Mar 2010
    Posts
    74

    Re: Reason for traffic disappearence between server&client

    Quote Originally Posted by MikeAThon View Post
    If I understand you correctly, you have an algorithm that regulates the rate of transmission, and the algorithm sometimes causes the traffic to drop to zero.

    If so, then post your algorithm. You state that the traffic goes to zero at "random moments", but the graph you show does not look very random, and actually seems somewhat periodic, such that the algorithm might not be working as expected.

    Mike
    No, Mike, in common, I dont requlate rate of transmission. I could do it for test, but I dont see sense for it. I set fixed rate (f.e. N packets per sec), I can change it to other value. there is nothing algorithmic. Whole algorithm is a sending of N packets , more correctly, one array of N packets, nothnig more.

    Graph is not periodic, normal graph likes constant level with deviations. I put only fragment to show radical degradation of service.

  5. #5
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Reason for traffic disappearence between server&client

    Quote Originally Posted by jitechno View Post
    ... I set fixed rate (f.e. N packets per sec), I can change it to other value. there is nothing algorithmic.
    Sorry to persist, but it seems that if you are somehow enforcing a fixed rate of N packets per sec, then indeed you have an algorithm that regulates the rate of transmission. IOW, the algorithm is "set a fixed rate of N packets per sec".

    If so, then please show the code that limits transmission to N packet per sec.

  6. #6
    Join Date
    Mar 2010
    Posts
    74

    Re: Reason for traffic disappearence between server&client

    ok

    bytes = N * record_size;

    FD_ZERO(&sock_set);
    FD_SET(sock, &sock_set);
    while( select(0, NULL, &sock_set, NULL, &timeout )<=0);

    if (bytes == send(sock, (char *)Array_1 , bytes, 0))
    {
    sent += bytes;
    }

    it works under timer.

  7. #7
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Reason for traffic disappearence between server&client

    1. The call to select() will alter the content of the fd_set's. Therefore, sock_set must be re-initialized each time before select() is called in the "while" loop.

    2. The call to send() will return the number of bytes sent, which will frequently be far less than the number of bytes you asked it to send. Your code must accommodate this possibility, and it is not apparent that it does so now. For example, typical code to ensure that a count of "cbBytesToSend" bytes in an array starting at an Array_1 of bytes are sent might look like this (without error checking -- see next point):
    Code:
    int cbBytesToSend = ... whatever;
    int cbSentSoFar = 0;
    int cbSentThisTry = 0;
    while (cbBytesToSend > 0)
    {
      cbSentThisTry = send(sock, (char*)(Array_1 + cbSentSoFar), cbBytesToSend, 0);
      cbSentSoFar += cbSentThisTry;
      cbBytesToSend -= cbSentThisTry;
    }
    3. the above code, and your code too, needs error-checking. You must check to determine if send() returns SOCKET_ERROR, and then call WSAGetLastError() and determine what to do next if it does.

    Mike
    Last edited by MikeAThon; April 16th, 2010 at 05:21 PM. Reason: To fix error in sample code

  8. #8
    Join Date
    Mar 2010
    Posts
    74

    Re: Reason for traffic disappearence between server&client

    Ok.
    I will implement 1 and 2,
    I have 3 , it is not shown here.

  9. #9
    Join Date
    Mar 2010
    Posts
    74

    Re: Reason for traffic disappearence between server&client

    After long time I am again here.
    problen still exists, but I want reformulate it:

    My server generates stable traffic. It means appr. stable (+- few percents) number of packets per time unit, per second f.e.
    What I have expect on client side? Approximately stable ingoing traffic, I think?
    What are possible reasons for traffic unstablity and how find in a precise way , what happens...?

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