EmbDev.net

Forum: µC & Digital Electronics http_get from ulrich radig


Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
Hi,

I want to use uli's project to send temperature values to a mysql 
database.

I've created a php file that insert var's into the db. i.e.
insert.php?Mainboard_Sensors_Id=c81e728d9d4c2f636f067f89cc14862c&Mainboard_Sensors_Log_Temperature=131

i tried to integrate this into uli's code. when i start the webserver it 
does a request to my webserver. I verified this by using wireshark. but 
the problem; it isnt working, yet. i do see packet retransmissions. i 
searched for a while and found other topics with the same problems.

does someone have this code working or maybe have an other solution to 
put data into a remote sql db? i'm looking for a 'real time put' 
solution so a bash script getting the data from the atmega is not what 
i'm looking for.

Author: sascha (Guest)
Posted on:

Rate this post
0 useful
not useful
Hello,

the problem is at Uli's data recive routine.

void test (unsigned char index)
{
  for (int a = TCP_DATA_START_VAR;a < TCP_DATA_END_VAR;a++)
  {
    HTTPC_DEBUG("%c",eth_buffer[a]);
  }
  tcp_entry[index].time = TCP_TIME_OFF;
  tcp_entry[index].status = ACK_FLAG;
  create_new_tcp_packet(0,index);
}

if your webserver close the connection (FIN) at same time with sending 
last data packet - uli's code send only an ACK and not an FIN/ACK 
thereby the connection is not close.

To test use the follow code, but i used in my webserver an ASM code


void test (unsigned char index)
{
  for (int a = TCP_DATA_START_VAR;a < TCP_DATA_END_VAR;a++)
  {
    HTTPC_DEBUG("%c",eth_buffer[a]);
  }
  tcp_entry[index].time = TCP_TIME_OFF;
        if(tcp_entry[index].status & FIN_FLAG) {
                http_get_state=20;
                return;
        }
        tcp_entry[index].status = ACK_FLAG;
        create_new_tcp_packet(0,index);
}

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
Hi Sascha,

i tried the code but without any luck.

i captured again with wireshark and i see:

1 - atmega send syn to webserver
2 - webserver send syn/ack back to atmega
3 - and again: webserver send syn/ack back to atmega ??
4 - then i get 6 retrainsmissions from the atmega to the webserver with 
http GET requests.
5 - webserver send syn/ack back to atmega
6 - 3 times, atmega send psh and ack with http data (GET)
7 - atmega sends rst, ack to webserver

end.

what to do?

Author: Sascha (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi,

please wait i will test an changed C-code at my second webserver.

Sascha

Author: Sascha (Guest)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Hello,

I testet some code, see attachement ...

changes outside of http_get, code based on version 1.2.5 from ulli:
>main.c
at startup called   httpg_init()

>cmd.c / cmd.h
add command "get" to start http-download

So the statemachine works but implement is not perfect (catch out 
errors).
A problem remains - after connection closed most stacks wait sometimes 
at new packets with same portnumber. If you within 1-2 mins, running a 
new download the connection hang. To avoid this you must change port at 
each connection.
Into my server implement this. In example:
> Start download
* get an random portnumber
* add_tcp_app with this portnumber
* running download
* after connection closed kill_tcp_app with selected portnumber

here a link with something information about my server:
Beitrag "Re: Zeigt her Eure Kunstwerke !"

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
Hi Sascha,

Thanks for your code. I'm trying but i get a little confused.

in your main.c you still got:
        #if GET_WEATHER
        http_request ();
        #endif


but in your cmd.c you are doing a request to command_httpG which 
requests run_http_request(); which requests
void run_http_request (void)
{
  if (http_get_state==-1)
  {
    http_get_state=0;
  } else {
    HTTPC_DEBUG("ERROR - HTTP Request BUSY\n\r");
  }
}

without any call to other functions?

when only calling http_request(); in the main.c doesnt work, 
http_get_state is at start -1 ?

do i need to add http_request in the run_http_request function ?

and replace http_request(); in main.c to run_http_request(); ?

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
I changed the code to this:
void run_http_request (void)
{
  if (http_get_state==-1)
  {
    http_get_state=0;
    http_request();
  } else {
    HTTPC_DEBUG("ERROR - HTTP Request BUSY\n\r");
  }
}

result:
get
HTTP Request
TCP Eintrag gefunden (HTTP_CLIENT)!
Ready




Daten Anfordern

wireshark:
atmega > webserver : SYN
webserver > atmega RST, ACK

i think handshake is going wrong?

btw, i've got 2 subnets in my lan, local lan and wlan
local lan = atmega 192.168.x.x, webserver = wlan 192.168.y.x

Author: Sascha Weber (sascha_w)
Posted on:

Rate this post
0 useful
not useful
Sj Sj wrote:
> Hi Sascha,
>
> Thanks for your code. I'm trying but i get a little confused.
>
> in your main.c you still got:
>
>
>         #if GET_WEATHER
>         http_request ();
>         #endif
> 
this code i dont changed, its runs http_get statemachine simultaneously 
into main loop

> but in your cmd.c you are doing a request to command_httpG which
> requests run_http_request(); which requests
>
>
> void run_http_request (void)
> {
>   if (http_get_state==-1)
>   {
>     http_get_state=0;
>   } else {
>     HTTPC_DEBUG("ERROR - HTTP Request BUSY\n\r");
>   }
> }
> 
>
> without any call to other functions?
yes it's ok, the http_request() check var http_get_state at every 
calling from main loop. At reset or if request complete the state is -1, 
that says the http_request() its nothing to do.

> when only calling http_request(); in the main.c doesnt work,
have you set GET_WEATHER to 1 in config.h?

> http_get_state is at start -1 ?
yes, so its wait to run with GET command

> do i need to add http_request in the run_http_request function ?
no

> and replace http_request(); in main.c to run_http_request(); ?
no

Sascha

Author: Sj Sj (sj1)
Posted on:
Attached files:

Rate this post
0 useful
not useful
I tried again,

downloaded a fresh uli file ;P

copy past your files into the directory

changed atmega32 > 644

changed some in config.h

but with the same result

i added my source, can you give it a try?

Author: Sascha Weber (sascha_w)
Posted on:

Rate this post
0 useful
not useful
hello,

i download your archive, changed ipaddresses and clockspeed, then 
programed to my server.
At serial console type "get" - and it works fine

I see that you changed the IP-Address for download but not changed 
GET-String?!

you written that used different subnet's, can test at configuration at 
same subnet?

Sascha

Author: Sj Sj (sj1)
Posted on:
Attached files:

Rate this post
0 useful
not useful
heh,

this is really strange, i tried in the same subnet and still, not 
working.

i enclosure a wireshark cap file.

line 1: broadcast after boot atmega
line 2: broadcast after boot atmega
line 3: bcast after 'get' command
line 4: reply after get
line 5: tcp start?
line 6: ??

Author: Sj Sj (sj1)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Ok found some new information.

i did install a new webserver on an other pc. lets call this one pc2. 
the setup is still in the same subnet.

i've attached 2 wireshark captures. on of pc 2 (new 
http_get_test-working-pc2-1145090810.cap) and one of pc1 (old 
http_get_test-failure-pc1-1155090810.cap)

PC2 situation:
i booted atmega and typed get. as you can see in wireshark its working! 
line 1 to 10.

then i tried again and it failure, as you said line 11..14

PC1:
i booted atmega and typed get. as you can see in wireshark line 3 is 
strange, any idea? think this is the problem? but why, its the same code 
working with pc1 :/

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
ok, shameful, the http services on pc1 was crashed :|

it's working

i read about tcp/ip handshaking and close connections.

i'm not sure but if i understand your story it is normal that tcp/ip 
ends with a time_wait state at the server side?

This means that the webserver did get a FIN from the mega to determinate 
the tcp/ip connection. it sends back to the mega a ACK packet and a FIN. 
then it get a ACK back from the mega.

after this procedure the webserver port goes into TIME-WAIT and timed 
out after 2 mins << this is what you mean by waiting 2 mins before retry 
to setup a connection..? why its waiting 2 minutes, if the mega sends 
back the LAST ack then the connection can be closed, right? why wait 2 
minutes or is this part of code missing? i cant find it back in the 
wireshark captures

beside the atmega project, does every application use this procedure? 
what if an application wants to send traffic again? it count the 
LOCAL_HTTP_PORT++ ? and setup a connection again?

is there a simple way to detect failures ? duplicate acks, no remote 
port is open, any other failures.. ? if so, what would be a simple way 
to handle this?

Author: Sascha Weber (sascha_w)
Posted on:

Rate this post
0 useful
not useful
Sj Sj wrote:
> i read about tcp/ip handshaking and close connections.
good

> i'm not sure but if i understand your story it is normal that tcp/ip
> ends with a time_wait state at the server side?
it is normal? i dont know but i see at ViewTCP also at other connections 
sometimes

> This means that the webserver did get a FIN from the mega to determinate
> the tcp/ip connection. it sends back to the mega a ACK packet and a FIN.
> then it get a ACK back from the mega.
in file "http_get_test-working-pc2-1145090810.cap"
webserver send FIN in packet 7, ATmega answer with a ACK (8) and a 
FIN,ACK (9), webserver sends ACK (10)
i can not see an error at this sequence, if i compare with other traffic 
the same sequence are used

> after this procedure the webserver port goes into TIME-WAIT and timed
> out after 2 mins << this is what you mean by waiting 2 mins before retry
> to setup a connection..? why its waiting 2 minutes, if the mega sends
> back the LAST ack then the connection can be closed, right? why wait 2
> minutes or is this part of code missing? i cant find it back in the
> wireshark captures
at TIME-WAIT state or later no more packets exchanged
you can see the state with TCPView http://tcpview.softonic.de/

> beside the atmega project, does every application use this procedure?
the http_get is the reversed function of a http server - in the server 
project is not needed, but at ulis stack (or my project) is used to show 
some infomation (from web) on display

> what if an application wants to send traffic again?
for example http connections can request more than one files with same 
connection

>it count the LOCAL_HTTP_PORT++ ? and setup a connection again?
yes this works, but you must kill the last http_get_app from application 
stack before changed port. an "kill_tcp_app" function you must implement 
in stack because yet not available.
increment PORT is a good way but limit the portrange e.g. 2200 to 2400
if you look at browser traffic then see - each connection used a new 
portnumber

> is there a simple way to detect failures ? duplicate acks, no remote
> port is open, any other failures.. ? if so, what would be a simple way
> to handle this?
oh - detect failures at tcp are very difficult but wireshark helps

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
Thanks again,


i found some code in sendmail.c starting at 241

if mail can't be send it count++ a higher port.
i tried the code below ant it seems to be working, can you verify the 
code?
/*----------------------------------------------------------------------------
 Copyright:      Radig Ulrich  mailto: mail@ulrichradig.de
 Author:         Radig Ulrich
 Remarks:        
 known Problems: none
 Version:        12.11.2007
 Description:    HTTP-Client (empfang einer Webseite)

 Dieses Programm ist freie Software. Sie können es unter den Bedingungen der 
 GNU General Public License, wie von der Free Software Foundation veröffentlicht, 
 weitergeben und/oder modifizieren, entweder gemäß Version 2 der Lizenz oder 
 (nach Ihrer Option) jeder späteren Version. 

 Die Veröffentlichung dieses Programms erfolgt in der Hoffnung, 
 daß es Ihnen von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, 
 sogar ohne die implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT 
 FÜR EINEN BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License. 

 Sie sollten eine Kopie der GNU General Public License zusammen mit diesem 
 Programm erhalten haben. 
 Falls nicht, schreiben Sie an die Free Software Foundation, 
 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 
------------------------------------------------------------------------------*/
#include "config.h"
#include "http_get.h" 
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "stack.h"
#include "usart.h"
#include "timer.h"
  
//PROGMEM char WEATHER_GET_STRING[] = {"GET /koch.htm HTTP/1.1\r\n"
PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Mainboard_Sensors_Id=c81e728d9d4c2f636f067f89cc14862c&Mainboard_Sensors_Log_Temperature=13 HTTP/1.1\r\n"
                                     //"GET / HTTP/1.1\r\n"
                                     "Host: www.webservicex.net\r\n"
                                     //"Host: www.ulrichradig.de\r\n"
                                     "Connection: close\r\n\r\n"};

volatile unsigned int http_get_state = -1;
unsigned int my_http_cp = LOCAL_HTTP_PORT;

//----------------------------------------------------------------------------
//HTTP_GET INIT
void httpg_init (void)
{
        ////unsigned int my_http_cp = LOCAL_HTTP_PORT;
        add_tcp_app (my_http_cp, (void(*)(unsigned char))test);
}
//----------------------------------------------------------------------------
//Abfrage starten
void run_http_request (void)
{
  if (http_get_state==-1)
  {
    http_get_state=0;
  } else {
    HTTPC_DEBUG("ERROR - HTTP Request BUSY\n\r");
  }
}
//----------------------------------------------------------------------------
//Daten kommen von einem Webserver an!!
void test (unsigned char index)
{
  for (int a = TCP_DATA_START_VAR;a < TCP_DATA_END_VAR;a++)
  {
    HTTPC_DEBUG("%c",eth_buffer[a]);
  }
  tcp_entry[index].time = TCP_TIME_OFF;
    if(tcp_entry[index].status & FIN_FLAG)
  {
        http_get_state=-1;
    HTTPC_DEBUG("HTTP Request - EOF\n\r");  
    //tcp_Port_close(index);
    }
    else ////changed to else
  { 
    tcp_entry[index].status = ACK_FLAG;
    create_new_tcp_packet(0,index);
  }
}

//----------------------------------------------------------------------------
//HTTP Request an einen Webserver stelle
void http_request (void)
{
    unsigned long index = MAX_TCP_ENTRY;
    
    if (http_get_state > 1 && http_get_state < 20) http_get_state++;

    if (http_get_state == 0)
    {

        //offnet eine Verbindung zu meinem Webserver
        HTTPC_DEBUG("HTTP Request\n\r");
        //unsigned int my_http_cp = LOCAL_HTTP_PORT;        

  /*new code*/
    unsigned int my_httpget_cp_new = my_http_cp + time;
    if (my_httpget_cp_new < 1000) my_httpget_cp_new +=1000;
    
    change_port_tcp_app (my_http_cp, my_httpget_cp_new);
    my_http_cp = my_httpget_cp_new;  

  /*eo new code*/
  



        //ARP Request senden
        if(arp_request (WEATHER_SERVER_IP))
        {
            for(unsigned long a=0;a<2000000;a++){asm("nop");};
            
            tcp_port_open (WEATHER_SERVER_IP,HTONS(80),HTONS(my_http_cp));
               
            unsigned char tmp_counter = 0;
            while((index >= MAX_ARP_ENTRY) && (tcp_entry[index].app_status != 1))
            {
                index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
                if (tmp_counter++ > 30)
                {
                    HTTPC_DEBUG("TCP Eintrag nicht gefunden (HTTP_CLIENT)!\r\n");
          http_get_state = -1;
                    return;
                }
            }
             
            HTTPC_DEBUG("TCP Eintrag gefunden (HTTP_CLIENT)!\r\n");
            tcp_entry[index].first_ack = 1;
            http_get_state = 2;
        }
        else
        {
            http_get_state = -1;
        }
    }
    
    //if (http_get_state == 10)  
    if (http_get_state > 10 && http_get_state < 20)
    {
        HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
        index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
        memcpy_P(&eth_buffer[TCP_DATA_START],WEATHER_GET_STRING,(sizeof(WEATHER_GET_STRING)-1));
        tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
        create_new_tcp_packet((sizeof(WEATHER_GET_STRING)-1),index);
    http_get_state=21;
    }
}


i changed:
define global:
unsigned int my_http_cp = LOCAL_HTTP_PORT;
void httpg_init (void)
{
        ////unsigned int my_http_cp = LOCAL_HTTP_PORT;
        add_tcp_app (my_http_cp, (void(*)(unsigned char))test);
}
added the else statement, else when FIN the connection you get an extra ACK, the extra ACK is not needed i think?

void test (unsigned char index)
{
  for (int a = TCP_DATA_START_VAR;a < TCP_DATA_END_VAR;a++)
  {
    HTTPC_DEBUG("%c",eth_buffer[a]);
  }
  tcp_entry[index].time = TCP_TIME_OFF;
    if(tcp_entry[index].status & FIN_FLAG)
  {
        http_get_state=-1;
    HTTPC_DEBUG("HTTP Request - EOF\n\r");  
    //tcp_Port_close(index);
    }
    else ////changed to else
  { 
    tcp_entry[index].status = ACK_FLAG;
    create_new_tcp_packet(0,index);
  }
}
removed //unsigned int my_http_cp = LOCAL_HTTP_PORT;    using global one, think else it points to other registers when using it?? my atmega crashes when i use it.. ;P
and added /*new code*/ part


//----------------------------------------------------------------------------
//HTTP Request an einen Webserver stelle
void http_request (void)
{
    unsigned long index = MAX_TCP_ENTRY;
    
    if (http_get_state > 1 && http_get_state < 20) http_get_state++;

    if (http_get_state == 0)
    {

        //offnet eine Verbindung zu meinem Webserver
        HTTPC_DEBUG("HTTP Request\n\r");
        //unsigned int my_http_cp = LOCAL_HTTP_PORT;        

  /*new code*/
    unsigned int my_httpget_cp_new = my_http_cp + time;
    if (my_httpget_cp_new < 1000) my_httpget_cp_new +=1000;
    
    change_port_tcp_app (my_http_cp, my_httpget_cp_new);
    my_http_cp = my_httpget_cp_new;  

  /*eo new code*/
  



        //ARP Request senden
        if(arp_request (WEATHER_SERVER_IP))
        {
            for(unsigned long a=0;a<2000000;a++){asm("nop");};
            
            tcp_port_open (WEATHER_SERVER_IP,HTONS(80),HTONS(my_http_cp));
               
            unsigned char tmp_counter = 0;
            while((index >= MAX_ARP_ENTRY) && (tcp_entry[index].app_status != 1))
            {
                index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
                if (tmp_counter++ > 30)
                {
                    HTTPC_DEBUG("TCP Eintrag nicht gefunden (HTTP_CLIENT)!\r\n");
          http_get_state = -1;
                    return;
                }
            }
             
            HTTPC_DEBUG("TCP Eintrag gefunden (HTTP_CLIENT)!\r\n");
            tcp_entry[index].first_ack = 1;
            http_get_state = 2;
        }
        else
        {
            http_get_state = -1;
        }
    }
    
    //if (http_get_state == 10)  
    if (http_get_state > 10 && http_get_state < 20)
    {
        HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
        index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
        memcpy_P(&eth_buffer[TCP_DATA_START],WEATHER_GET_STRING,(sizeof(WEATHER_GET_STRING)-1));
        tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
        create_new_tcp_packet((sizeof(WEATHER_GET_STRING)-1),index);
    http_get_state=21;
    }
}

Author: Sascha Weber (sascha_w)
Posted on:

Rate this post
0 useful
not useful
//Daten kommen von einem Webserver an!!
void test (unsigned char index)
{
  for (int a = TCP_DATA_START_VAR;a < TCP_DATA_END_VAR;a++)
  {
    HTTPC_DEBUG("%c",eth_buffer[a]);
  }
  tcp_entry[index].time = TCP_TIME_OFF;
    if(tcp_entry[index].status & FIN_FLAG)
    {
        http_get_state=-1;
        HTTPC_DEBUG("HTTP Request - EOF\n\r");
    }
    tcp_entry[index].status = ACK_FLAG;
    create_new_tcp_packet(0,index);
}
/\ send's a ACK packet for each incomming packet, the FIN/ACK packet 
following send by the stack.c if FIN is stated in recived packet.

the portchange function is an good idea too, but calculation with time 
is not necessary.
  /*new code*/
    unsigned int my_httpget_cp_new = my_http_cp + 1;
    if (my_httpget_cp_new > (LOCAL_HTTP_PORT+300)) my_httpget_cp_new = LOCAL_HTTP_PORT;
    
    change_port_tcp_app (my_http_cp, my_httpget_cp_new);
    my_http_cp = my_httpget_cp_new;  

  /*eo new code*/

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
Sascha Weber wrote:

> /\ send's a ACK packet for each incomming packet, the FIN/ACK packet
> following send by the stack.c if FIN is stated in recived packet.

hm, i dont understand what you mean. can you try it again?

----


now i can send data via GET method, i dont know if this is a good way to 
send over data. i was thinking something about soap but i think this 
would be overkill ?

the main goal is getting data into mysql, any other suggestion to send 
over data? think creating a client would be to difficult

Author: Sascha Weber (sascha_w)
Posted on:

Rate this post
0 useful
not useful
Sj Sj wrote:
> Sascha Weber wrote:
>
>> /\ send's a ACK packet for each incomming packet, the FIN/ACK packet
>> following send by the stack.c if FIN is stated in recived packet.
>
> hm, i dont understand what you mean. can you try it again?
with your change (else branch) ACK only send in packets without FIN-flag

> now i can send data via GET method, i dont know if this is a good way to
> send over data.
> i was thinking something about soap but i think this
> would be overkill ?
yes i thinking too, if the exchange with GET enough for your application 
the soap-protokoll dont bring a advantage

> the main goal is getting data into mysql, any other suggestion to send
> over data? think creating a client would be to difficult
if you can use a cronjob at webserver, it can request data from atmega - 
your data put into the file which sends from atmega

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
I'm not sure about the else.

if i remove the else i get one ack to much in wireshark, i.e. i THINK i 
see one to much.

but,

if i look to the code, after every received packet in function:
void http_request (void)

        tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;

there's an ack send

maybe this ack is send to much and not the one in the test function. 
perhaps it is by chance?


if i look at sendmail.c there is no ack send:
//Daten kommen vom EMAIL- Server an!! (Mail wird versendet)

void mail_data (unsigned char index)

{

    //Verbindung wurde abgebaut!

    if (tcp_entry[index].status & FIN_FLAG)

    {

        return;

    }



Author: Sascha Weber (sascha_w)
Posted on:

Rate this post
0 useful
not useful
Sj Sj wrote:
> I'm not sure about the else.
>
> if i remove the else i get one ack to much in wireshark, i.e. i THINK i
> see one to much.
i see, after server send's datapacket with FIN atmega send an ACK packet 
and an FIN/ACK packet - of principle is enough to send second packet 
with FIN/ACK.
see also ...
http://en.wikipedia.org/wiki/Transmission_Control_...
"It is also possible to terminate the connection by a 3-way handshake, 
when host A sends a FIN and host B replies with a FIN & ACK (merely 
combines 2 steps into one) and host A replies with an ACK.[13] This is 
perhaps the most common method."
<- B can send one packet with FIN&ACK or 2 packets - one with ACK and 
one with FIN
i test it to send in second packet only FIN and not FIN/ACK, then 
TCPView says FIN_wait2 status.

> but,
>
> if i look to the code, after every received packet in function:
>
> void http_request (void)
> 
>         tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
> 
this only send with GET request - once per connection

> if i look at sendmail.c there is no ack send:
>
> //Daten kommen vom EMAIL- Server an!! (Mail wird versendet)
> 
> void mail_data (unsigned char index)
> 
> {
> 
>     //Verbindung wurde abgebaut!
> 
>     if (tcp_entry[index].status & FIN_FLAG)
> 
>     {
> 
>         return;
> 
>     }
> 
> 
> 
see above

Sascha

Author: Sj Sj (sj1)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Hi again,

I'm trying to mutate http_get.c into a style of sendmail.c, of course 
without luck.

if i look to sendmail.c there is no
////tcp_entry[index].first_ack = 1;

in the mail_send() function, so i comment it in the http_get.c (any idea 
why this line is used?)

i moved:

    //if (http_get_state == 10)  
    if (http_get_state > 10 && http_get_state < 20)
    {
        HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
        index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
        memcpy_P(&eth_buffer[TCP_DATA_START],WEATHER_GET_STRING,(sizeof(WEATHER_GET_STRING)-1));
        tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
        create_new_tcp_packet((sizeof(WEATHER_GET_STRING)-1),index);
    http_get_state=21;
    }


in to the test() function

as result i do get 3 way handshake but then, for a while nothing happen. 
after a period of time (32 secs) it sends a 'TCP ACK' protocol packet 
thats it.

i guess it would be possible to mutate the code more formally like 
sendmail.c but there's something going wrong. can you help me a little?

Author: Sascha Weber (sascha_w)
Posted on:

Rate this post
0 useful
not useful
Sj Sj wrote:
> Hi again,
>
> I'm trying to mutate http_get.c into a style of sendmail.c, of course
> without luck.
why?

> if i look to sendmail.c there is no
>
>
> ////tcp_entry[index].first_ack = 1;
> 
>
> in the mail_send() function, so i comment it in the http_get.c (any idea
> why this line is used?)
i think that is useless, then in stack.c i found this at
//Server öffnet Port
 ... for outgoing connections, and at
//Empfangene Packet wurde bestätigt keine Daten für Anwendung
//z.B. nach Verbindungsaufbau (SYN-PACKET)
 ... for incomming connections

> i moved:
>
> 
>     //if (http_get_state == 10)
>     if (http_get_state > 10 && http_get_state < 20)
>     {
>         HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
>         index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
>         memcpy_P(&eth_buffer[TCP_DATA_START],WEATHER_GET_STRING,(sizeof(WEATHER_GET_STRING)-1));
>         tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
>         create_new_tcp_packet((sizeof(WEATHER_GET_STRING)-1),index);
>     http_get_state=21;
>     }
> 
> 
>
> in to the test() function
>
> as result i do get 3 way handshake but then, for a while nothing happen.
> after a period of time (32 secs) it sends a 'TCP ACK' protocol packet
> thats it.
the test() function is only execute if incomming packets recived from 
server. If you see at stack.c  "//Server öffnet Port" - there atmega 
send's ACK packet for 3 way handshake (step 3), but user application 
[test()] is not running

> i guess it would be possible to mutate the code more formally like
> sendmail.c but there's something going wrong. can you help me a little?
at sendmail there is a little difference:
after opening connenction initiated by atmega, the server sends a packet 
first. Thereby the user_appliction [mail_send(void)] is running after 
connection opend.
At http_get, you must send the first packet (/GET ...) after connenction 
established.

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
thanks,

i saw it later, but thanks for the confirmation.

i'm trying to create a dynamic GET url but it's PROGMEM.

i tried a few codes but every time the microcontroller reboots

the url:
PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Mainboard_Sensors_Id=c81e728d9d4c2f636f067f89cc14862c&Mainboard_Sensors_Log_Temperature=13 HTTP/1.1\r\n"

and i want to create some like:
PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Mainboard_Sensors_Id=%d&Mainboard_Sensors_Log_Temperature=%d HTTP/1.1\r\n"
and where %d = the dynamic value

any suggestions? i tried to use sprintf_P but then the mic crashes and i 
need to declare a big char for the url string, but then the advantage 
isn't any more i guess.

-------
ok found a solution:
    sprintf(WEATHER_GET_STRING,"GET /temp/insert.php?Mainboard_Sensors_Id=%d&Mainboard_Sensors_Log_Temperature=%d HTTP/1.1\r\n \r\n Connection: close\r\n\r\n", 1,2);
    HTTPC_DEBUG("test: %s\r\n", WEATHER_GET_STRING);

Author: krepperm (Guest)
Posted on:

Rate this post
0 useful
not useful
Hello Sj Sj,

I got from Sascha a tip that you both spoke about the problem to fetch 
web sites with ETH_M32. I have the same problem. Did you fix the 
problem?

Can you send me your source of the http_get.c.


Thanks for your support


Markus

Author: Sj Sj (sj1)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Hi Markus,

see attachment, this is my working code. if you change the code or have 
some new idea's, please share.

are you using the m32 or webserver with fat support version from uli?

Author: krepperm (Guest)
Posted on:

Rate this post
0 useful
not useful
Hey Sj Sj,

thanks for the answer. I use at the moment the standard Stack 1.2.5 from 
Uli. My AVR is a 644P.

I tried your code but I have no look. It doesn't work.
Following situation:

AVR send SYN
WEB SERVER SYN;ACK
AVR sends no ACK, it sends the GET Request


I have to check the code.


Do you have any answer?


br Markus

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
hm maybe this part of code stuck, im trying to create a dynamic url but 
didnt work yet,

try this:
comment the last PROGMEM line and uncomment the first, think the %d 
stucks
//PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Mainboard_Sensors_Id=c81e728d9d4c2f636f067f89cc14862c&Mainboard_Sensors_Log_Temperature=13 HTTP/1.1\r\n"
PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Mainboard_Sensors_Id=%d&Mainboard_Sensors_Log_Temperature=13 HTTP/1.1\r\n"


comment this sprintf line too.
void run_http_request (void)
{


  if (http_get_state==-1)
  {
    sprintf(WEATHER_GET_STRING,"GET /temp/insert.php?Mainboard_Sensors_Id=%d&Mainboard_Sensors_Log_Temperature=%d HTTP/1.1\r\n \r\n Connection: close\r\n\r\n", 1,2);
    HTTPC_DEBUG("%s\r\n", WEATHER_GET_STRING);
    
    http_get_state=0;
  } else {
    HTTPC_DEBUG("ERROR - HTTP Request BUSY\n\r");
  }
}


try again,

Author: krepperm (Guest)
Posted on:

Rate this post
0 useful
not useful
I did before. I use this code.


PROGMEM char WEATHER_GET_STRING[] = {"GET /xampp/mypost.php 
HTTP/1.1\r\n"
                                     "Host: 10.1.61.188\r\n"
                                     //"Keep-Alive: 300\r\n"
                                     "Connection: Close\r\n\r\n"};



It's a INTRANET with a Apache Server. All ip's you see are in the 
private lan.

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
can you upload your pcap file and your http_get.c?

Author: krepperm (Guest)
Posted on:
Attached files:

Rate this post
0 useful
not useful
attached you will find the most important files.

thx markus

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
aint be sure but i think you dont need to add PROGMEM char 
WEATHER_GET_STRING[] = {"GET /xampp/mypost.php HTTP/1.1\r\n"


xampp dir to the url


are you using wireshark to verify the handshake? please upload, you can 
filter out the rest of your network traffic

Author: krepperm (Guest)
Posted on:

Rate this post
0 useful
not useful
sorry I have no time the next day's.

I check it.

br markus

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
hi how its going? already got it working?

i tried the same code with the 'will mmc/ftp' version and its not 
working. no idea yet,

its sending the post as a retransmission :/

Author: Katarina Beecker (Guest)
Posted on:

Rate this post
0 useful
not useful
Hello Harry,

my  I am new here. My Hobbys are Centre Dialect and detecting lies.
I craving to deal with people here with the unchanging interests.

Cu
Kat

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
i've got a working code but it does not working when i'm logging to a 
remote lan via vpn.

<lan atmega> <vpn device> internet <vpn device> <webserver>

for local lan test i used a windows webserver, remote its linux.

i dont know why but it seems that the GET sends earlier then an ack is 
send:
No.     Time        Source                Destination           Protocol Info
      1 0.000000    192.168.10.99         192.168.20.2          TCP      23794 > http [SYN] Seq=0 Win=1100 Len=0 MSS=1100
      2 0.000078    192.168.20.2          192.168.10.99         TCP      http > 23794 [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
      3 0.043718    192.168.10.99         192.168.20.2          HTTP     [TCP ACKed lost segment] [TCP Retransmission] GET /temp/insert.php?S1=1&T1=0&S2=2&T2=218&S3=3&T3=0&S4=4&T4=223&Time=14:23:21&Date=2010-10-04 HTTP/1.1 Continuation or non-HTTP traffic
      4 0.043776    192.168.20.2          192.168.10.99         TCP      http > 23794 [RST] Seq=459887518 Win=0 Len=0
      5 0.054712    192.168.10.99         192.168.20.2          TCP      23794 > http [ACK] Seq=1 Ack=1 Win=1100 Len=0
      6 3.399613    192.168.20.2          192.168.10.99         TCP      http > 23794 [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
      7 3.399979    192.168.10.99         192.168.20.2          TCP      23794 > http [RST] Seq=1 Win=0 Len=0

any idea why its working on local lan but not via vpn?
when my pc is quite busy and rs232 is 'hanging' sometimes the connection 
works, looks like timing / delay issue

Author: Sascha Weber (sascha-w)
Posted on:

Rate this post
0 useful
not useful
Hello,

after
HTTPC_DEBUG("TCP Eintrag gefunden (HTTP_CLIENT)!\r\n");
tcp_entry[index].first_ack = 1;
you must wait that
tcp_entry[index].app_status == 1
, only then ACK-Packet has been send.

At fast connections at LAN, the looptime in main for calling 
http_request brings enough delay to send ACK before http_get_state 
achieved a value greater than 10.

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
hm

at what point do i need to wait?

its already waiting at: ???
            while((index >= MAX_ARP_ENTRY) && (tcp_entry[index].app_status != 1))
            {

#include "config.h"
#include "http_get.h" 
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <string.h>

#include <stdio.h>
#include "stack.h"
#include "usart.h"
#include "timer.h"
  
//PROGMEM char WEATHER_GET_STRING[] = {"GET /koch.htm HTTP/1.1\r\n"
//PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Mainboard_Sensors_Id=c81e728d9d4c2f636f067f89cc14862c&Mainboard_Sensors_Log_Temperature=13 HTTP/1.1\r\n"

//PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Mainboard_Sensors_Id_1=%d&Mainboard_Sensors_Log_Temperature_1=%d&Mainboard_Sensors_Id_2=%d&Mainboard_Sensors_Log_Temperature_2=%d&Mainboard_Sensors_Id_3=%d&Mainboard_Sensors_Log_Temperature_3=%d&Mainboard_Sensors_Id_4=%d&Mainboard_Sensors_Log_Temperature_4=%d HTTP/1.1\r\n"

//PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Id=%d&Temperature=%d&DateTimeGenerated=%s&blaat=1 HTTP/1.1\r\n"
//PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Temperature1=%d&Temperature2=%d&Temperature3=%d&Temperature4=%d&Time=%s&Date=%s HTTP/1.1\r\n"
//PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Sensor1=%s&Temperature1=%d&Sensor2=%s&Temperature2=%d&Sensor3=%s&Temperature3=%d&Sensor4=%s&Temperature4=%d&Time=%s&Date=%s HTTP/1.1\r\n"
//PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?S1=1&T1=0&S2=2&T2=195&S3=3&T3=0&S4=4&T4=223&Time=10:30:53&Date=2010-10-04 HTTP/1.1\r\n"
PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?S1=%s&T1=%d&S2=%s&T2=%d&S3=%s&T3=%d&S4=%s&T4=%d&Time=%s&Date=%s HTTP/1.1\r\n"




                                     //"GET / HTTP/1.1\r\n"
                                     "Host: www.webservicex.net\r\n"
                                     //"Host: www.ulrichradig.de\r\n"
                                     "Connection: close\r\n\r\n"};

volatile unsigned int http_get_state = -1;
unsigned int my_http_cp = LOCAL_HTTP_PORT;
char buffer_string[230]={0};

//----------------------------------------------------------------------------
//HTTP_GET INIT
void httpg_init (void)
{
        ////unsigned int my_http_cp = LOCAL_HTTP_PORT;
        add_tcp_app (my_http_cp, (void(*)(unsigned char))test);
}
//----------------------------------------------------------------------------



//Abfrage starten
//void run_http_request (void)
void run_http_request (char *sensor1, int16_t *LM92_CurrentTemp1, char *sensor2, int16_t *LM92_CurrentTemp2, char *sensor3, int16_t *LM92_CurrentTemp3, char *sensor4, int16_t *LM92_CurrentTemp4, char *sql_date, char *sql_time)
{
  sprintf_P(buffer_string,WEATHER_GET_STRING,sensor1, *LM92_CurrentTemp1,sensor2, *LM92_CurrentTemp2,sensor3, *LM92_CurrentTemp3,sensor4, *LM92_CurrentTemp4,sql_time,sql_date);
    
  if (http_get_state==-1)
  {

    http_get_state=0;

    //usart_write("DataLog: [Sensor: %i] [Temperature: %i] [Time: %s] [Date: %s]\r\n",*sensor_id,*LM92_CurrentTemp,sql_time,sql_date);
    //usart_write("DataLog: [Temperature1: %i] [Temperature2: %i] [Temperature3: %i] [Temperature4: %i] [Time: %s] [Date: %s]\r\n",*LM92_CurrentTemp1,*LM92_CurrentTemp2,*LM92_CurrentTemp3,*LM92_CurrentTemp4,sql_time,sql_date);
    usart_write("DataLog: sensor: %s %s %s %s [Temperature1: %i] [Temperature2: %i] [Temperature3: %i] [Temperature4: %i] [Time: %s] [Date: %s]\r\n",sensor1, sensor2, sensor3, sensor4, *LM92_CurrentTemp1,*LM92_CurrentTemp2,*LM92_CurrentTemp3,*LM92_CurrentTemp4,sql_time,sql_date);
    
    usart_write("HTTP GET URL: %s\r\n",buffer_string);
    
    
    HTTPC_DEBUG("buffer: %s\r\n", buffer_string);
  
  } else {
    //usart_write("DataLog Fail: [Sensor: %i] [Temperature: %i] [Time: %s] [Date: %s]\r\n",*sensor_id,*LM92_CurrentTemp,sql_time,sql_date);
    usart_write("DataLog Fail: %s %s %s %s [Temperature1: %i] [Temperature2: %i] [Temperature3: %i] [Temperature4: %i] [Time: %s] [Date: %s]\r\n",sensor1, sensor2, sensor3, sensor4, *LM92_CurrentTemp1,*LM92_CurrentTemp2,*LM92_CurrentTemp3,*LM92_CurrentTemp4,sql_time,sql_date);    
    usart_write("HTTP GET URL: %s\r\n",buffer_string);
    usart_write("-------\r\n");
    
    //savetosd()
    
    HTTPC_DEBUG("ERROR - HTTP Request BUSY\n\r");
  }
}
//----------------------------------------------------------------------------
//Daten kommen von einem Webserver an!!
void test (unsigned char index)
{
char buffer[10]={0};

  for (int a = TCP_DATA_START_VAR;a < TCP_DATA_END_VAR;a++)
  {
    HTTPC_DEBUG("%c",eth_buffer[a]);

    if (eth_buffer[a] == '$') //look for #$ string
    {
      if (eth_buffer[a+1] == '#') 
      {  
        if (eth_buffer[a+2] != '1') 
        {  
          usart_write("SQL insert failed\r\n",eth_buffer[a+2]);
          
        
        }
      }
    }  
  }
  
  
  tcp_entry[index].time = TCP_TIME_OFF;
    if(tcp_entry[index].status & FIN_FLAG)
  {
        http_get_state=-1;
    
    usart_write("HTTP Request - EOF\n\r");  
    usart_write("-------\r\n");
    return;
    }
    //else ////changed to else
  //{ 
    tcp_entry[index].status = ACK_FLAG;
    create_new_tcp_packet(0,index);
  //}
}

//----------------------------------------------------------------------------
//HTTP Request an einen Webserver stelle
void http_request (void)
{
    unsigned long index = MAX_TCP_ENTRY;
    
    if (http_get_state > 1 && http_get_state < 20) http_get_state++;

    if (http_get_state == 0)
    {

        //offnet eine Verbindung zu meinem Webserver
        HTTPC_DEBUG("HTTP Request\n\r");
        //unsigned int my_http_cp = LOCAL_HTTP_PORT;        


    unsigned int my_httpget_cp_new = my_http_cp + time;
    if (my_httpget_cp_new < 1000) my_httpget_cp_new +=1000;
    
    change_port_tcp_app (my_http_cp, my_httpget_cp_new);
    my_http_cp = my_httpget_cp_new;  

       //ARP Request senden
        if(arp_request (WEATHER_SERVER_IP))
        {
            for(unsigned long a=0;a<2000000;a++){asm("nop");};
            
            tcp_port_open (WEATHER_SERVER_IP,HTONS(80),HTONS(my_http_cp));
               
            unsigned char tmp_counter = 0;
            while((index >= MAX_ARP_ENTRY) && (tcp_entry[index].app_status != 1))
            {
                index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
                if (tmp_counter++ > 30)
                {
                    HTTPC_DEBUG("TCP Eintrag nicht gefunden (HTTP_CLIENT)!\r\n");
          http_get_state = -1;
                    return;
                }
            }
             
            HTTPC_DEBUG("TCP Eintrag gefunden (HTTP_CLIENT)!\r\n");
            tcp_entry[index].first_ack = 1;
            http_get_state = 2;
        }
        else
        {
            http_get_state = -1;
        }
    }
    
    //if (http_get_state == 10)  
    if (http_get_state > 10 && http_get_state < 20)
    {
        HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
        index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
        //memcpy_P(&eth_buffer[TCP_DATA_START],WEATHER_GET_STRING,(sizeof(WEATHER_GET_STRING)-1));
    memcpy(&eth_buffer[TCP_DATA_START],buffer_string,(sizeof(buffer_string)-1));
        tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
        create_new_tcp_packet((sizeof(buffer_string)-1),index);
    http_get_state=21;
    
    usart_write("index: %i\r\n", index);
    }
}



something like:??
    if (tcp_entry[index].app_status == 1)
  {
    //if (http_get_state == 10)  
    if (http_get_state > 10 && http_get_state < 20)
    {
      HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
      index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
      //memcpy_P(&eth_buffer[TCP_DATA_START],WEATHER_GET_STRING,(sizeof(WEATHER_GET_STRING)-1));
      memcpy(&eth_buffer[TCP_DATA_START],buffer_string,(sizeof(buffer_string)-1));
      tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
      create_new_tcp_packet((sizeof(buffer_string)-1),index);
      http_get_state=21;
      
      usart_write("index: %i\r\n", index);
    }
  }


Author: Sascha Weber (sascha-w)
Posted on:
Attached files:

Rate this post
0 useful
not useful
... no - while waiting the stack must process incoming pakets

see attachment

to info:
* stackentry found if SYN-Packet has been sent (tcp_entry_search)
* app_status=1 if SYN/ACK has been received and ACK sent

in mainloop it would better that calling 'http_request' only once every 
second. Then timeouts are better definable.

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
ok i build the situation back to my locallan.

i debug tcp_entry[index].app_status == 1 and it never reaches >0


i debugged the stack

i added:
  while (TCP_PORT_TABLE[port_index].port && TCP_PORT_TABLE[port_index].port!=(htons(tcp->TCP_DestPort)))
  { 
--->>>>>>>>  usart_write("port index %i\r\n",port_index);
    port_index++;
  }


my German failures, maybe you can translate? :)
ystem Ready
Compiliert am Oct  4 2010 um 19:16:38
Compiliert mit GCC Version 4.3.2

NIC init:My IP: 192.168.1.99

TCP Anwendung wird in Liste eingetragen: Eintrag 0
TCP Anwendung wird in Liste eingetragen: Eintrag 1
TCP Anwendung wird in Liste eingetragen: Eintrag 2

IP   192.168.1.99
MASK 255.255.255.0
GW   192.168.1.1
UDP Anwendung wird in Liste eingetragen: Eintrag 0
ROUTING!
ARP Eintrag nicht gefunden*
port index 0
port index 1
port index 2
TCP Keine Anwendung gefunden!
ARP REPLY EMPFANGEN!
**KEINEN ARP EINTRAG GEFUNDEN**
ARP EINTRAG GEFUNDEN!
ROUTING!
ARP Eintrag nicht gefunden*
ARP EINTRAG GEFUNDEN!
ARP REPLY EMPFANGEN!

TIME: 18:29:26
http\port index 0
port index 1
port index 2
TCP Keine Anwendung gefunden!
http
ERROR

DataLog: sensor: 1 2 3 4 [Temperature1: 0] [Temperature2: 221] [Temperature3: 0] [Temperature4: 231] [Time: 19:29:35] [Date: 2010-10-04]
HTTP GET URL: GET /temp/insert.php?S1=1&T1=0&S2=2&T2=221&S3=3&T3=0&S4=4&T4=231&Time=19:29:35&Date=2010-10-04 HTTP/1.1
Host: www.webservicex.net
Connection: close


buffer: GET /temp/insert.php?S1=1&T1=0&S2=2&T2=221&S3=3&T3=0&S4=4&T4=231&Time=19:29:35&Date=2010-10-04 HTTP/1.1
Host: www.webservicex.net
Connection: close


HTTP Request
TCP Anwendung Port ändern: Eintrag 2
MY NETWORK!
ARP EINTRAG GEFUNDEN!
Oeffen eines Ports mit Server
TCP Open neuer Eintrag 0
TCP SrcPort -23368
TCP Eintrag gefunden (HTTP_CLIENT)!
ARP REPLY EMPFANGEN!
port index 0
port index 1
TCP Entry gefunden 0
TCP Port wurde vom Server geöffnet STACK:0
TCP SrcPort -23368
port index 0
port index 1
port index 2
TCP Keine Anwendung gefunden!
DataLog Fail: 1 2 3 4 [Temperature1: 0] [Temperature2: 221] [Temperature3: 0] [Temperature4: 232] [Time: 19:29:45] [Date: 2010-10-04]
HTTP GET URL: GET /temp/insert.php?S1=1&T1=0&S2=2&T2=221&S3=3&T3=0&S4=4&T4=232&Time=19:29:45&Date=2010-10-04 HTTP/1.1
Host: www.webservicex.net
Connection: close


-------
ERROR - HTTP Request BUSY
DataLog Fail: 1 2 3 4 [Temperature1: 0] [Temperature2: 221] [Temperature3: 0] [Temperature4: 231] [Time: 19:29:55] [Date: 2010-10-04]
HTTP GET URL: GET /temp/insert.php?S1=1&T1=0&S2=2&T2=221&S3=3&T3=0&S4=4&T4=231&Time=19:29:55&Date=2010-10-04 HTTP/1.1
Host: www.webservicex.net
Connection: close


-------
ERROR - HTTP Request BUSY
DataLog Fail: 1 2 3 4 [Temperature1: 0] [Temperature2: 221] [Temperature3: 0] [Temperature4: 231] [Time: 19:30:05] [Date: 2010-10-04]
HTTP GET URL: GET /temp/insert.php?S1=1&T1=0&S2=2&T2=221&S3=3&T3=0&S4=4&T4=231&Time=19:30:05&Date=2010-10-04 HTTP/1.1
Host: www.webservicex.net
Connection: close

Author: Sascha Weber (sascha-w)
Posted on:
Attached files:

Rate this post
0 useful
not useful
at stack.c you can see that app_status set to 1 after debugmessage
"TCP Port wurde vom Server geöffnet STACK:0; TCP SrcPort -23368"

the failur in my code is, that the variable 'index' is not initialize 
from second call of http_request.

I correct it ...

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
i was guessing about that because when passing
if ((http_get_state > 10 && http_get_state < 20) && (tcp_entry[index].app_status == 1))
    {
    usart_write("tcp_entry[index].app_status2 %i\r\n",tcp_entry[index].app_status);
    
    
    
        HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
        index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
        //memcpy_P(&eth_buffer[TCP_DATA_START],WEATHER_GET_STRING,(sizeof(WEATHER_GET_STRING)-1));
    memcpy(&eth_buffer[TCP_DATA_START],buffer_string,(sizeof(buffer_string)-1));
        tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
        create_new_tcp_packet((sizeof(buffer_string)-1),index);
    http_get_state=21;
    
    usart_write("index: %i\r\n", index);
    }


i created an extra delay but without luck

        #if GET_WEATHER
    if (!teller)
    {
      http_request ();
      teller = 1000;
    }  
        #endif
        teller--;



tcp_entry[index].app_status == 1 and not 0

your code is better but when capturing with wireshark i get three transmissions.

[code]
No.     Time        Source                Destination           Protocol Info
      1 0.000000    192.168.1.99         192.168.2.2          TCP      46927 > http [SYN] Seq=0 Win=1100 Len=0 MSS=1100
      2 0.000068    192.168.2.2          192.168.1.99         TCP      http > 46927 [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
      3 0.059202    192.168.1.99         192.168.2.2          TCP      46927 > http [ACK] Seq=1 Ack=1 Win=1100 Len=0
      4 0.113420    192.168.1.99         192.168.2.2          HTTP     GET /temp/insert.php?S1=1&T1=0&S2=2&T2=227&S3=3&T3=0&S4=4&T4=230&Time=20:48:54&Date=2010-10-04 HTTP/1.1 Continuation or non-HTTP traffic
      5 0.113490    192.168.2.2          192.168.1.99         TCP      http > 46927 [ACK] Seq=1 Ack=230 Win=6432 Len=0
      6 0.117004    192.168.2.2          192.168.1.99         HTTP     HTTP/1.1 200 OK  (text/html)
      7 0.117233    192.168.2.2          192.168.1.99         TCP      http > 46927 [FIN, ACK] Seq=201 Ack=230 Win=6432 Len=0
      8 0.159392    192.168.1.99         192.168.2.2          HTTP     [TCP Retransmission] GET /temp/insert.php?S1=1&T1=0&S2=2&T2=227&S3=3&T3=0&S4=4&T4=230&Time=20:48:54&Date=2010-10-04 HTTP/1.1 Continuation or non-HTTP traffic
      9 0.159453    192.168.2.2          192.168.1.99         TCP      [TCP Dup ACK 7#1] http > 46927 [ACK] Seq=202 Ack=230 Win=6432 Len=0
     10 0.173377    192.168.1.99         192.168.2.2          TCP      [TCP Dup ACK 8#1] 46927 > http [ACK] Seq=230 Ack=1 Win=1100 Len=0
     11 0.250335    192.168.1.99         192.168.2.2          TCP      46927 > http [ACK] Seq=230 Ack=201 Win=1100 Len=0
     12 0.268817    192.168.1.99         192.168.2.2          TCP      46927 > http [FIN, ACK] Seq=230 Ack=202 Win=1100 Len=0
     13 0.268867    192.168.2.2          192.168.1.99         TCP      http > 46927 [ACK] Seq=202 Ack=231 Win=6432 Len=0


Author: Sascha Weber (sascha-w)
Posted on:

Rate this post
0 useful
not useful
I'm not sure - after Frame 6 AVR must ACK this paket, but 192.168.2.2 
send's directly an FIN/ACK ??

test transmission without vpn please.

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
i tested without vpn and still the same

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
i tested without vpn and still the same

i changed:
"            if ((tcp_entry[index].app_status == 1) && (http_get_state < 20))
            {



its working under windows.

when i'm using the vpn > linux i get an extra ack / duplicate ack 
instead of windows

windows capture same lan:
No.     Time        Source                Destination           Protocol Info
    125 30.443885   192.168.1.99         192.168.1.22         TCP      13161 > http [SYN] Seq=0 Win=1100 Len=0 MSS=1100
    126 30.443971   192.168.1.22         192.168.1.99         TCP      http > 13161 [SYN, ACK] Seq=0 Ack=1 Win=64900 Len=0 MSS=1460
    127 30.490949   192.168.1.99         192.168.1.22         TCP      13161 > http [ACK] Seq=1 Ack=1 Win=1100 Len=0
    128 30.518474   192.168.1.99         192.168.1.22         HTTP     GET /temp/insert.php?S1=1&T1=0&S2=2&T2=226&S3=3&T3=0&S4=4&T4=229&Time=21:34:18&Date=2010-10-04 HTTP/1.1 Continuation or non-HTTP traffic
    129 30.542955   192.168.1.22         192.168.1.99         HTTP     HTTP/1.1 200 OK  (text/html)
    130 30.543120   192.168.1.22         192.168.1.99         TCP      http > 13161 [FIN, ACK] Seq=305 Ack=230 Win=64671 Len=0
    131 30.654627   192.168.1.99         192.168.1.22         TCP      13161 > http [ACK] Seq=230 Ack=305 Win=1100 Len=0
    132 30.673119   192.168.1.99         192.168.1.22         TCP      13161 > http [FIN, ACK] Seq=230 Ack=306 Win=1100 Len=0
    133 30.673179   192.168.1.22         192.168.1.99         TCP      http > 13161 [ACK] Seq=306 Ack=231 Win=64671 Len=0


linux remote vpn capture:
No.     Time        Source                Destination           Protocol Info
      1 0.000000    192.168.1.99         192.168.2.2          TCP      50877 > http [SYN] Seq=0 Win=1100 Len=0 MSS=1100
      2 0.000104    192.168.2.2          192.168.1.99         TCP      http > 50877 [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
      3 0.048717    192.168.1.99         192.168.2.2          TCP      50877 > http [ACK] Seq=1 Ack=1 Win=1100 Len=0
      4 0.081688    192.168.1.99         192.168.2.2          HTTP     GET /temp/insert.php?S1=1&T1=0&S2=2&T2=226&S3=3&T3=0&S4=4&T4=230&Time=21:54:44&Date=2010-10-04 HTTP/1.1 Continuation or non-HTTP traffic
      5 0.081757    192.168.2.2          192.168.1.99         TCP      http > 50877 [ACK] Seq=1 Ack=230 Win=6432 Len=0
      6 0.085280    192.168.2.2          192.168.1.99         HTTP     HTTP/1.1 200 OK  (text/html)
      7 0.085511    192.168.2.2          192.168.1.99         TCP      http > 50877 [FIN, ACK] Seq=201 Ack=230 Win=6432 Len=0
      8 0.124417    192.168.1.99         192.168.2.2          TCP      [TCP Dup ACK 4#1] 50877 > http [ACK] Seq=230 Ack=1 Win=1100 Len=0
      9 0.201862    192.168.1.99         192.168.2.2          TCP      50877 > http [ACK] Seq=230 Ack=201 Win=1100 Len=0
     10 0.219848    192.168.1.99         192.168.2.2          TCP      50877 > http [FIN, ACK] Seq=230 Ack=202 Win=1100 Len=0
     11 0.219891    192.168.2.2          192.168.1.99         TCP      http > 50877 [ACK] Seq=202 Ack=231 Win=6432 Len=0



i tested with a linux machine in my other local lan (routed) and got the 
same results as the vpn!!

this is what i see when i connect from a pc > vpn > linux webserver
No.     Time        Source                Destination           Protocol Info
      1 0.000000    192.168.1.22         192.168.2.2          TCP      tarantella > http [SYN] Seq=0 Win=64512 Len=0 MSS=1350
      2 0.000101    192.168.2.2          192.168.1.22         TCP      http > tarantella [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
      3 0.032238    192.168.1.22         192.168.2.2          TCP      tarantella > http [ACK] Seq=1 Ack=1 Win=64800 Len=0
      4 0.037490    192.168.1.22         192.168.2.2          HTTP     GET /temp/insert.php?S1=1&T1=0&S2=2&T2=225&S3=3&T3=0&S4=4&T4=239&Time=15:50:20&Date=2010-10-04 HTTP/1.1 
      5 0.037586    192.168.2.2          192.168.1.22         TCP      http > tarantella [ACK] Seq=1 Ack=464 Win=6432 Len=0
      6 0.076260    192.168.2.2          192.168.1.22         HTTP     HTTP/1.1 200 OK  (text/html)
      7 0.076571    192.168.2.2          192.168.1.22         TCP      http > tarantella [FIN, ACK] Seq=201 Ack=464 Win=6432 Len=0
      8 0.111936    192.168.1.22         192.168.2.2          TCP      tarantella > http [ACK] Seq=464 Ack=202 Win=64600 Len=0
      9 0.123671    192.168.1.22         192.168.2.2          TCP      tarantella > http [FIN, ACK] Seq=464 Ack=202 Win=64600 Len=0
     10 0.123710    192.168.2.2          192.168.1.22         TCP      http > tarantella [ACK] Seq=202 Ack=465 Win=6432 Len=0


Author: Sascha Weber (sascha-w)
Posted on:

Rate this post
0 useful
not useful
Hello,

the only different between Windows and Linux ist the extra ACK-Paket in 
Frame 5 as answer of GET-Paket. I look at stack.c and tcp_application is 
running every ACK-Paket is incoming - also an empty ACK-Paket. From APP 
=>void test (unsigned char index) this pakets also replyed with ACK - 
its an ACK to much.
Test with return if paket is empty ...
[c]
//Daten kommen von einem Webserver an!!
void test (unsigned char index)
{
char buffer[10]={0};
  for (int a = TCP_DATA_START_VAR;a < TCP_DATA_END_VAR;a++)
  {
    HTTPC_DEBUG("%c",eth_buffer[a]);
    if (eth_buffer[a] == '$') //look for #$ string
    {
      if (eth_buffer[a+1] == '#')
      {
        if (eth_buffer[a+2] != '1')
        {
          usart_write("SQL insert failed\r\n",eth_buffer[a+2]);
        }
      }
    }
  }
  tcp_entry[index].time = TCP_TIME_OFF;
    if(tcp_entry[index].status & FIN_FLAG)
  {
        http_get_state=-1;
    usart_write("HTTP Request - EOF\n\r");
    usart_write("-------\r\n");
    return;
    }
    if (TCP_DATA_START_VAR == TCP_DATA_END_VAR)
    {
       return;  //no reply for empty pakets
    }
    tcp_entry[index].status = ACK_FLAG;
    create_new_tcp_packet(0,index);
}

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
thanks again! its working

but still got a amount of questions,

- why it's replying to an empty ack? why is linux sending this ack and 
windows don't?

- why do i need to delay the http_request in main() when using vpn?

- seems to be that sometimes when my pc is busy, rs232 is delayed, 
because rs232 delay, tcp packets of the atmega are to late because of 
rs232 looping? if its to late then the tcp session broke, any idea how 
to fix this?

Author: Sascha Weber (sascha-w)
Posted on:

Rate this post
0 useful
not useful
Sj Sj wrote:
> thanks again! its working
>
> but still got a amount of questions,
>
> - why it's replying to an empty ack? why is linux sending this ack and
> windows don't?
why? both variants are approved, the stack can send an "only"-ACK-packet 
(Linux) or it can combine with reply of data (Win)

> - why do i need to delay the http_request in main() when using vpn?
you don't need the delay, I said it's better for set timeoutvalues if 
the time between two calls is a fixed value
For example you can use the 1 sec timebase from timer.c, add a flag that 
check in main to call http_request(), or move the line ...
if (http_get_state > 1 && http_get_state < 20) http_get_state++;
... from http_request() into timer.c ...
//Timer Interrupt
#if EXTCLOCK==1
  #if defined (__AVR_ATmega644__)
    ISR (TIMER2_COMPA_vect)
  #else
    ISR (TIMER2_COMP_vect)
  #endif
#else
  ISR (TIMER1_COMPA_vect)
#endif
{
  //tick 1 second
  time++;
    if((stack_watchdog++) > WTT)  //emergency reset of the stack
    {
        RESET();
  }
    eth.timer = 1;
//INSERT
if (http_get_state > 1 && http_get_state < 20) http_get_state++;
  #if USE_NTP
  ntp_timer--;
  #endif //USE_NTP
  #if USE_DHCP
  if ( dhcp_lease > 0 ) dhcp_lease--;
    if ( gp_timer   > 0 ) gp_timer--;
    #endif //USE_DHCP
}

> - seems to be that sometimes when my pc is busy, rs232 is delayed,
> because rs232 delay, tcp packets of the atmega are to late because of
> rs232 looping? if its to late then the tcp session broke, any idea how
> to fix this?
if connection etablished in stack.c is an function 'tcp_timer_call' to 
kill stackentry after 3 sec (TCP_MAX_ENTRY_TIME) of inactivity. Before 
connection etablished the timeout is realized with counting of 
'http_get_state'.

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
i tested the code and it crashes after a while.
like about > 1 hour logging. with samples of 10 secs, the tcp stack is 
crashing, i think.
last count was from sourceport 2345 till 2663 = 318




i debugged the code when testing.
everytime the last GET is going fine. but then it crashed and i dont 
know where.

when its working the debug code looks like:
TCP SrcPort 2717
TCP TCP_DestPort 80
TCP-Stack Eintrag gelöscht! STACK:0
TCP Eintrag nicht gefunden
DataLog: sensor: 1 2 3 4 [Temperature1: 0] [Temperature2: 202] [Temperature3: 0] [Temperature4: 202] [Time: 20:32:36] [Date: 2010-10-07]
HTTP GET URL: GET /temp/insert.php?S1=1&T1=0&S2=2&T2=202&S3=3&T3=0&S4=4&T4=202&Time=20:32:36&Date=2010-10-07 HTTP/1.1
Host: www.webservicex.net
Connection: close


buffer: GET /temp/insert.php?S1=1&T1=0&S2=2&T2=202&S3=3&T3=0&S4=4&T4=202&Time=20:32:36&Date=2010-10-07 HTTP/1.1
Host: www.webservicex.net
Connection: close


HTTP Request
TCP Anwendung Port ändern: Eintrag 2
ROUTING!
ARP EINTRAG GEFUNDEN!
Oeffen eines Ports mit Server
TCP Open neuer Eintrag 0
TCP SrcPort 2718
TCP TCP_DestPort 80
TCP Eintrag gefunden (HTTP_CLIENT)!
ARP REPLY EMPFANGEN!
TCP Entry gefunden 0
TCP Port wurde vom Server geöffnet STACK:0
TCP SrcPort 2718
TCP TCP_DestPort 80



Daten Anfordern
TCP SrcPort 2718
TCP TCP_DestPort 80
index: 0
TCP Entry gefunden 0
TCP Entry gefunden 0
HTTP/1.1 200 OK
Date: Fri, 08 Oct 2010 18:22:03 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.2.10
Content-Length: 9
Connection: close
Content-Type: text/html; charset=UTF-8



$#1
TCP SrcPort 2718
TCP TCP_DestPort 80
TCP Entry gefunden 0
HTTP Request - EOF
-------
TCP SrcPort 2718
TCP TCP_DestPort 80
TCP-Stack Eintrag gelöscht! STACK:0
TCP Eintrag nicht gefunden
DataLog: sensor: 1 2 3 4 [Temperature1: 0] [Temperature2: 202] [Temperature3: 0] [Temperature4: 202] [Time: 20:32:46] [Date: 2010-10-07]
HTTP GET URL: GET /temp/insert.php?S1=1&T1=0&S2=2&T2=202&S3=3&T3=0&S4=4&T4=202&Time=20:32:46&Date=2010-10-07 HTTP/1.1
Host: www.webservicex.net
Connection: close


buffer: GET /temp/insert.php?S1=1&T1=0&S2=2&T2=202&S3=3&T3=0&S4=4&T4=202&Time=20:32:46&Date=2010-10-07 HTTP/1.1
Host: www.webservicex.net
Connection: close


HTTP Request
TCP Anwendung Port ändern: Eintrag 2
ROUTING!
ARP EINTRAG GEFUNDEN!
Oeffen eines Ports mit Server
TCP Open neuer Eintrag 0
TCP SrcPort 2719
TCP TCP_DestPort 80
TCP Eintrag gefunden (HTTP_CLIENT)!
ARP REPLY EMPFANGEN!
DataLog Fail: 1 2 3 4 [Temperature1: 0] [Temperature2: 202] [Temperature3: 0] [Temperature4: 201] [Time: 20:32:56] [Date: 2010-10-07]
HTTP GET URL: GET /temp/insert.php?S1=1&T1=0&S2=2&T2=202&S3=3&T3=0&S4=4&T4=201&Time=20:32:56&Date=2010-10-07 HTTP/1.1
Host: www.webservicex.net
Connection: close

not even tcp stack debug code so thats why i think it crashes, the tcp 
entry list is empty too..

[code]
RROR - HTTP Request BUSY
tcp
ERROR

tcp
00  IP:000.000.000.000  PORT:0000  Time:0000
01  IP:000.000.000.000  PORT:0000  Time:0000
02  IP:000.000.000.000  PORT:0000  Time:0000
03  IP:000.000.000.000  PORT:0000  Time:0000
04  IP:000.000.000.000  PORT:0000  Time:0000
Ready

arp
00  MAC:00.00.00.00.00.00  IP:000.000.000.000  Time:0000
01  MAC:00.10.db.9f.f0.02  IP:192.168.010.001  Time:0099
02  MAC:00.00.00.00.00.00  IP:000.000.000.000  Time:0000
03  MAC:00.00.00.00.00.00  IP:000.000.000.000  Time:0000
04  MAC:00.00.00.00.00.00  IP:000.000.000.000  Time:0000
Ready
[code]



any idea how to futher debug this and if there is a timer that crashes?

after a reboot everything works fine.

Author: Sascha Weber (sascha-w)
Posted on:

Rate this post
0 useful
not useful
what crashes?
AVRServer ist complete busy?
No connections at net are acceptet, no serial commands are execute?

Before are moving count of 'http_get_state' it works continuously?

How much you start the transmission - 10s? -> its too often!

TCP-Connection-Timeout is 30s!
If connection is break, after this time the stackentry is killed. 
Therefore the requestrate should greater than Timeout!

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
hi,

i tought it was  crashing but i still can ping the device, telnet to the 
device and the webserver http page is working.

[quote]
Before are moving count of 'http_get_state' it works continuously?
[/quote]

no

[quote]
How much you start the transmission - 10s? -> its too often!

TCP-Connection-Timeout is 30s!
If connection is break, after this time the stackentry is killed.
Therefore the requestrate should greater than Timeout!
[/quote]

temp samples are 10 secs yes. what do you mean by timeout 30 secs? i 
start a new tcp session with a different tcp source port.

and if it's to often, why its working for aproxx > 1 hour?

Author: Sascha Weber (sascha-w)
Posted on:

Rate this post
0 useful
not useful
Sj Sj wrote:
> hi,
>
> i tought it was  crashing but i still can ping the device, telnet to the
> device and the webserver http page is working.
then server not crashed! The error message is "HTTP Request BUSY" ?

>> TCP-Connection-Timeout is 30s!
>> If connection is break, after this time the stackentry is killed.
>> Therefore the requestrate should greater than Timeout!
>
> temp samples are 10 secs yes. what do you mean by timeout 30 secs? i
> start a new tcp session with a different tcp source port.
you read temps every 10 secs? You send temps also ervery 10 secs?

> and if it's to often, why its working for aproxx > 1 hour?
if tcp-connection is hang stackentry is kill after timeout (30secs), if 
you start a new connection - a new stackentry is needed but only place 
for 5 entrys at stack.
--
If you get "HTTP Request BUSY" it says that previous transmission is not 
end.
If counting 'http_get_state' each second, a timeout not until 21 secs.

please send your actual timer.c, and http_get.c

Sascha

Author: Sj Sj (sj1)
Posted on:
Attached files:

Rate this post
0 useful
not useful
yes, error message is ERROR - HTTP Request BUSY

every 10 secs is a temperature sample and GET to the remote server. this 
delay was small, just for testing.

today i tried to sample/GET every 40 secs. it runs for 4.5 hours then it 
quits

with 10 secs it approx 1,10 hour, 40 secs 4,5,  looks proportional.


see attachments

i commented
  //NEW
    //if (http_get_state == 20) //20 or more (if waittime to short) but you must change some values more 
    //{
      //DEBUG "Error - no answer from server 
     // http_get_state = -1;
    //}

because this will only bypass the actual problem

Author: Sascha Weber (sascha-w)
Posted on:
Attached files:

Rate this post
0 useful
not useful
I changed something ...

new http_get_state's
-1     nothing to do
0      start request; try to open connection
2      tcp-entry at stack successful, SYN-packet sent
       if error at tcp-entry go to state -1

2..6   wait to SYN-ACK receiving [4 secs max]
       if reached 6 go to state -1

10     connection etablished; data sent
10..16 wait for incomming data from server (at each packet reset state 
to 11)
       timeout after 5 secs and go to state -1

test it with minimum of 20 secs between requests, and look for last 
message before crash (i hope not).


Sascha

Author: Sj Sj (sj1)
Posted on:
Attached files:

Rate this post
0 useful
not useful
i tried the code,

but... without luck =)

see attachment.

- much arp request at startup,
- after "Connection etablished!" 3 times Daten Anfordern instead of 1 ?

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
i changed
    if (tcp_entry[index].app_status == 1)

to:

    if ((tcp_entry[index].app_status == 1)  && (http_get_state < 10))


the mega sends a syn, get syn,ack back but does not response again with 
ack
HTTP Request
debug 1
debug 2
debug 3
debug 4
TCP Eintrag gefunden (HTTP_CLIENT)!
TCP-SYN-Timerout!
HTTP Request
debug 1
debug 2
debug 3
debug 4
TCP Eintrag gefunden (HTTP_CLIENT)!
LM92_ReadTemperature
DataLog Fail: 1 2 3 4 [Temperature1: 0] [Temperature2: 210] [Temperature3: 0] [Temperature4: 211] [Time: 22:25:52] [Date: 2010-10-11]
HTTP GET URL: GET /temp/insert.php?S1=1&T1=0&S2=2&T2=210&S3=3&T3=0&S4=4&T4=211&Time=22:25:52&Date=2010-10-11 HTTP/1.1
Host: www.webservicex.net
Connection: close


-------
ERROR - HTTP Request BUSY
TCP-SYN-Timerout!
HTTP Request
debug 1
debug 2
debug 3
debug 4
TCP Eintrag gefunden (HTTP_CLIENT)!
tcp_entry[index].app_status4 1
Connection etablished!



Daten Anfordern
index: 0
tcp
00  IP:192.168.002.002  PORT:0080  Time:0028
01  IP:192.168.002.002  PORT:0080  Time:0021
02  IP:192.168.002.002  PORT:0080  Time:0027
03  IP:000.000.000.000  PORT:0000  Time:0000
04  IP:000.000.000.000  PORT:0000  Time:0000
Ready

TCP-Connection-Timeout!
tcp_entry[index].app_status4 1
Connection etablished!

the strange thing is, it starts automatic

i comment the http_get_state=0; line and still HTTP Request is running!
  if (http_get_state==-1)
  {

    http_get_state=0;
HTTP Request
debug 1
debug 2
debug 3
debug 4
TCP Eintrag gefunden (HTTP_CLIENT)!
TCP-SYN-Timerout!
HTTP Request
debug 1
debug 2
debug 3
debug 4

Author: Sascha Weber (sascha-w)
Posted on:

Rate this post
0 useful
not useful
is there a problem with parallel access to variable "http_get_state" 
from main/http_request and ISR in timer.c possible? Is the declaration 
correct? - I dont know about C.

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
ok found the problem.

at startup
volatile unsigned int http_get_state = -1;

is set in http_get.c but timer.c start http_get_state at 0

timer.c is including the http_get_state from http_get.h because if i 
dont include this file i get an error.
System Ready
Compiliert am Oct 12 2010 um 18:48:24
Compiliert mit GCC Version 4.3.2

IP   192.168.1.99
MASK 255.255.255.0
GW   192.168.1.1
http_get_state timer = -1

TIME: 17:52:18
HTTP Request
http_get_state timer = 0
http_get_state timer = 0
debug 1
debug 2
debug 3
debug 4
TCP Eintrag gefunden (HTTP_CLIENT)!
http_get_state timer = 2
http_get_state timer = 3
http_get_state timer = 4
http_get_state timer = 5
TCP-SYN-Timerout!
http_get_state timer = -1
HTTP Request
http_get_state timer = 0
debug 1
debug 2
debug 3
debug 4
TCP Eintrag gefunden (HTTP_CLIENT)!
http_get_state timer = 2
LM92_ReadTemperature
http_get_state timer = 3
http_get_state timer = 4
http_get_state timer = 5
TCP-SYN-Timerout!
http_get_state timer = -1
HTTP Request
http_get_state timer = 0

http_get_state is always counting and its the counter from timer.c

    if (http_get_state > 1)
    {
    http_get_state++;

so i think if >1 is not working, or is -1 greater then 1 ? =)

Author: Sascha Weber (sascha-w)
Posted on:

Rate this post
0 useful
not useful
I see - problem is ...
volatile unsigned int http_get_state = -1;
         ^^^^^^^^

it must defined only as int !

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
until now it seems to be working, but i only tested for a few hours.

i split the lm92 (temperature sensor) samples and the http_requests with 
different timers.

lm92 polls every 10 secs and http_request 40 secs.

i copied the same code from ntp_timer in main.c
    if (!lm92_timer)
    {    
      lm92_timer = LM92_TIMER;
      LM92_ReadTemperature();
      
      usart_write("LM92_CurrentTemp %i %i %i %i \r\n",LM92_CurrentTemp[0],LM92_CurrentTemp[1],LM92_CurrentTemp[2],LM92_CurrentTemp[3]);
    }

    if (!http_request_timer)
    {    
      //usart_write("http_request_timer\r\n");
      http_request_timer = HTTP_GET_TIMER;
      insert_into_db();
      
    }

the var's are countdown in timer.c the strange thing is, sometimes 
lm92_timer is -1 if POST and lm92 samples runs at the same time.

using ! does not seem reliable, i think it would be better to define the 
countdown var as
volatile char lm92_timer; (not unsigned)

and then using:
    if (lm92_timer <=0)
    {    
      lm92_timer = LM92_TIMER;
      LM92_ReadTemperature();
      
      usart_write("LM92_CurrentTemp %i %i %i %i \r\n",LM92_CurrentTemp[0],LM92_CurrentTemp[1],LM92_CurrentTemp[2],LM92_CurrentTemp[3]);
    }

what do you think of this solution?

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
hi,

I tested for a few days now. i get notice by mail when http_get_state=-1

            while((index >= MAX_ARP_ENTRY) && (tcp_entry[index].app_status != 1))
            {
                index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
                if (tmp_counter++ > 30)
                {
                    HTTPC_DEBUG("TCP Eintrag nicht gefunden (HTTP_CLIENT)!\r\n");
          http_get_state = -1;
                    mail_enable = 1;
          sprintf(mail_error,"%s","no TCP");
          
          return;
                }
            }
             
        else
        {
            http_get_state = -1;
      mail_enable = 1;
      sprintf(mail_error,"%s","no arp");

        }
  
    if (http_get_state==6)
    {
      usart_write("TCP-SYN-Timerout!\r\n");  //no syn-ack within 4 secs (State from 2 to 6)
      http_get_state = -1;
      mail_enable = 1;
      sprintf(mail_error,"%s","No Syn");
    }
    
    if (http_get_state==16)
    {
      usart_write("TCP-Connection-Timeout!\r\n");  //no incomming packets within 5 secs (State from 11 to 16)
      http_get_state = -1;
      mail_enable = 1;
      sprintf(mail_error,"%s","TCP Time");
    }

i still get mails with TCP Time and No Syn messages. i dont know how to 
fix, is this normal? can tcp packets dropped that much? sometimes it 
goes ok for a while but then it stucks for 30 mins, it fixes itself but 
i miss data...

Author: Sascha Weber (sascha-w)
Posted on:

Rate this post
0 useful
not useful
Sj Sj wrote:
> i still get mails with TCP Time and No Syn messages. i dont know how to
> fix, is this normal?
i don't know
> can tcp packets dropped that much? sometimes it
> goes ok for a while but then it stucks for 30 mins, it fixes itself but
> i miss data...
packet loss is not an error, but regular single packet loss only.

with which transmission path you tested?
how much send packets?

an delay for 30 mins sees for me as an packet block up at your server to 
prevent DOS-Attack?!

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
ok this is strange,

i bugged better and see that the data is inserted but after a while 
every insert(http_get_state) ends with 16. i captured with wireshark and 
the packets are ok! looks like when data arrives, http_get_state == 11 
till 16 is to short?

    if (http_get_state==16)
    {
      usart_write("TCP-Connection-Timeout!\r\n");  //no incomming packets within 5 secs (State from 11 to 16)
      http_get_state = -1;
      mail_enable = 1;
      sprintf(mail_error,"%s","TCP Time");
    }

any suggestions? else i try to change 16 to 20?

    if(tcp_entry[index].status & FIN_FLAG)
  {
        http_get_state=-1;
    
    usart_write("HTTP Request - EOF\n\r");  
    usart_write("-------\r\n");
    return;
    }

after inserting the sql data i see at console HTTP Request - EOF then it 
tooks 5 secs before i get the message
usart_write("TCP-Connection-Timeout!\r\n");

so it looks like that the timer.c overwrite's the value -1

Author: Sascha Weber (sascha-w)
Posted on:

Rate this post
0 useful
not useful
Sj Sj wrote:
> so it looks like that the timer.c overwrite's the value -1
yes this can be a problem!
solution:
at timer.c only set a flag like 'eth.timer', move the http_get_state 
handling from timer.c to http_get.c and process if flag is set and reset 
flag following.

timer.c
http_get_timer=1
http_get.c
void http_request (void)
{
    unsigned long index = MAX_TCP_ENTRY;

    if (http_get_timer=1) {
       http_get_timer=0
       //code moved from timer.c
    }
//other code from http_request

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
here's the debug:
HTTP Request
HTTP GET URL: GET /temp/insert.php?S1=1&T1=0&S2=2&T2=175&S3=3&T3=0&S4=4&T4=180&Time=12:25:28&Date=2010-10-24 HTTP/1.1
Host: www.webservicex.net
Connection: close


http_get_state timer sec 0
http_get_state timer sec 2
SQL inserted
HTTP Request - EOF
-------
http_get_state -1
http_get_state timer sec 11
http_get_state timer sec 12
http_get_state timer sec 13
http_get_state timer sec 14
LM92_CurrentTemp 0 175 0 180
http_get_state timer sec 15
TCP-Connection-Timeout!
http_get_state -1
mail_enable
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
LM92_CurrentTemp 0 175 0 180
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
LM92_CurrentTemp 0 175 0 180
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
LM92_CurrentTemp 0 175 0 181
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1
HTTP Request
HTTP GET URL: GET /temp/insert.php?S1=1&T1=0&S2=2&T2=175&S3=3&T3=0&S4=4&T4=181&Time=12:26:08&Date=2010-10-24 HTTP/1.1
Host: www.webservicex.net
Connection: close


http_get_state timer sec 0
http_get_state timer sec 2
http_get_state timer sec 11
http_get_state timer sec 12
http_get_state timer sec 13
SQL inserted
HTTP Request - EOF
-------
http_get_state -1
http_get_state timer sec 11
LM92_CurrentTemp 0 175 0 180
http_get_state timer sec 12
http_get_state timer sec 13
http_get_state timer sec 14
http_get_state timer sec 15
TCP-Connection-Timeout!
http_get_state -1
mail_enable
http_get_state timer sec -1
http_get_state timer sec -1
http_get_state timer sec -1


i dont understand your solution, the variable is already used for other 
states so i cant use it for 0/1 (flag)?

Author: Sascha Weber (sascha-w)
Posted on:

Rate this post
0 useful
not useful
Sj Sj wrote:
> i dont understand your solution, the variable is already used for other
> states so i cant use it for 0/1 (flag)?
which variable ?
for flag you must define a new global variable ...
volatile unsigned char http_get_timer;

Sascha

Author: FemEdireern (Guest)
Posted on:

Rate this post
0 useful
not useful
If you love playing DotA Games join us and become part of a family of 
players!
Download the newest dota version on the 
http://www.dota-gaming.com/index.php?site=files - Download section
You can search on our community latest interviews about your favorite 
players

http://www.dota-gaming.com - DotA Gaming Community 
http://www.dota-gaming.com/ref/s_m.gif

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
ah,

so every tick in timer.c, the flag is set en http_get_status is counting 
up ?

new code:
void http_request (void)
{
    unsigned long index = MAX_TCP_ENTRY;
    if (http_get_state == 0)
    {

        //offnet eine Verbindung zu meinem Webserver
        HTTPC_DEBUG("HTTP Request\n\r");
        //unsigned int my_http_cp = LOCAL_HTTP_PORT;        

//usart_write("time: %i\r\n",time);


    //unsigned int my_httpget_cp_new = my_http_cp + time;
    unsigned int my_httpget_cp_new = my_http_cp + 1;
    //if (my_httpget_cp_new < 2345) my_httpget_cp_new +=1000;
    if (my_httpget_cp_new == 5000) my_httpget_cp_new =LOCAL_HTTP_PORT;

    
    change_port_tcp_app (my_http_cp, my_httpget_cp_new);
    my_http_cp = my_httpget_cp_new;  

       //ARP Request senden
        if(arp_request (WEATHER_SERVER_IP))
        {
            for(unsigned long a=0;a<2000000;a++){asm("nop");};

            tcp_port_open (WEATHER_SERVER_IP,HTONS(80),HTONS(my_http_cp));

   
            unsigned char tmp_counter = 0;

            while((index >= MAX_ARP_ENTRY) && (tcp_entry[index].app_status != 1))
            {
                index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
                if (tmp_counter++ > 30)
                {
                    HTTPC_DEBUG("TCP Eintrag nicht gefunden (HTTP_CLIENT)!\r\n");
          http_get_state = -1;
                    mail_enable = 1;
          sprintf(mail_error,"%s","no TCP");
          usart_write("http_get_state %i\n\r",http_get_state);
          
          return;
                }
            }
             
            HTTPC_DEBUG("TCP Eintrag gefunden (HTTP_CLIENT)!\r\n");
            tcp_entry[index].first_ack = 1;
            http_get_state = 2;
      
      //usart_write("tcp_entry[index].app_status %i\r\n",tcp_entry[index].app_status);
        }
        else
        {
            http_get_state = -1;
      mail_enable = 1;
      sprintf(mail_error,"%s","no arp");
      usart_write("http_get_state %i\n\r",http_get_state);

        }
    }
    if (http_get_state > 1)
    {
    index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));        
    
    if ((tcp_entry[index].app_status == 1)  && (http_get_state < 10))
    {
        HTTPC_DEBUG("tcp_entry[index].app_status4 %i\r\n",tcp_entry[index].app_status);
        HTTPC_DEBUG("Connection etablished!\r\n");    
        //http_get_state = 10;
        HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
        memcpy(&eth_buffer[TCP_DATA_START],buffer_string,(sizeof(buffer_string)-1));
        tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
        create_new_tcp_packet((sizeof(buffer_string)-1),index);
        http_get_state=10;
        HTTPC_DEBUG("index: %i\r\n", index);
    }
  //}

    if (http_get_timer==1) {
    http_get_timer=0;

    http_get_state++;
  
    if (http_get_state==6)
    {
      usart_write("TCP-SYN-Timerout!\r\n");  //no syn-ack within 4 secs (State from 2 to 6)
      http_get_state = -1;
      mail_enable = 1;
      sprintf(mail_error,"%s","No Syn");
      usart_write("http_get_state %i\n\r",http_get_state);

    }
    
    if (http_get_state==16)
    {
      usart_write("TCP-Connection-Timeout!\r\n");  //no incomming packets within 5 secs (State from 11 to 16)
      http_get_state = -1;
      mail_enable = 1;
      sprintf(mail_error,"%s","TCP Time");
      usart_write("http_get_state %i\n\r",http_get_state);

    }
    }
  }
}




with the old code i did get a few problems when i get a tcp syn error, 
with new i dont know but i guess its the same.
00  IP:000.000.000.000  PORT:0000  Time:0000
01  IP:000.000.000.000  PORT:0000  Time:0000
02  IP:192.168.002.002  PORT:0080  Time:0255
03  IP:192.168.002.002  PORT:0080  Time:0255
04  IP:000.000.000.000  PORT:0000  Time:0000


even after 10 min's the entry's are still there, any suggestion?

Author: #pancakeboos[OCSSSCSSSSHS] (Guest)
Posted on:

Rate this post
0 useful
not useful
Comanda numai acum lenjeria ta, de pe cel mai profesional website de 
comenzi de chiloti  de pe internet http://www.chilotick.com

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
ok still the same with new code
HTTP Request
HTTP GET URL: GET /temp/insert.php?S1=8b31&T1=0&S2=157b&T2=151&S3=052a&T3=0&S4=b65e&T4=171&Time=21:47:04&Date=2010-10-26 HTTP/1.1
Host: www.webservicex.net
Connection: close


http_get_state timer sec 0
http_get_state timer sec 3
SQL inserted
HTTP Request - EOF
-------
http_get_state -1
http_get_state timer sec 11
http_get_state timer sec 12
http_get_state timer sec 13
http_get_state timer sec 14
LM92_CurrentTemp 0 152 0 172
http_get_state timer sec 15
TCP-Connection-Timeout!
http_get_state -1

looks like data is still received after syn flag?

Author: fumpruini (Guest)
Posted on:

Rate this post
0 useful
not useful
Comanda numai acum ilustratele, tale de pe cel mai de calitate site de 
comenzi de fotografii Online http://www.photolaminut.com

Author: Sascha Weber (sascha-w)
Posted on:

Rate this post
0 useful
not useful
Hallo,

i look at your debuglog and i belief the problem is at "void test 
(unsigned char index)". It's the only position to set state to 11. The 
function is running after transmission FIN+ACK and set state to -1 
another once if ACK-packet from server received and set state to 11 and 
set TCP-Time to 255 (TCP_TIME_OFF) also.

add the follow line ...
void test (unsigned char index)
{
char buffer[10]={0};
//NEW
  if (http_get_state < 10) return;
//ENDNEW
  for (int a = TCP_DATA_START_VAR;a < TCP_DATA_END_VAR;a++)
  {
    HTTPC_DEBUG("%c",eth_buffer[a]);

    if (eth_buffer[a] == '$') //look for #$ string
    {
      if (eth_buffer[a+1] == '#') 
      {  
        if (eth_buffer[a+2] != '1') 
        {  
          usart_write("SQL insert failed\r\n",eth_buffer[a+2]);
          
        
        }
      }
    }  
  }
  
  
  tcp_entry[index].time = TCP_TIME_OFF;
        http_get_state=11;  //reset timeout
    if(tcp_entry[index].status & FIN_FLAG)
  {
        http_get_state=-1;
    
    usart_write("HTTP Request - EOF\n\r");  
    usart_write("-------\r\n");
    return;
    }
  if (TCP_DATA_START_VAR == TCP_DATA_END_VAR)
  {
    return;
  }
  
  
    //else ////changed to else
  //{ 
    tcp_entry[index].status = ACK_FLAG;
    create_new_tcp_packet(0,index);
  //}

}
...  to break receive before connection opend or after connection 
closed.

Sascha

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
when adding this line it failures at start
lm92_timer 2, http_request_timer 2
http_get_state timer sec -1
lm92_timer 1, http_request_timer 1
http_get_state timer sec -1
lm92_timer 0, http_request_timer 0
LM92_CurrentTemp 0 161 0 175
HTTP Request
HTTP GET URL: GET /temp/insert.php?S1=8b31&T1=0&S2=157b&T2=161&S3=052a&T3=0&S4=b65e&T4=175&Time=18:48:33&Date=2010-10-27 HTTP/1.1
Host: www.webservicex.net
Connection: close


http_get_state timer sec 0
lm92_timer 9, http_request_timer 39
http_get_state timer sec 0
lm92_timer 8, http_request_timer 38
http_get_state timer sec 3
lm92_timer 7, http_request_timer 37
http_get_state timer sec 4
lm92_timer 6, http_request_timer 36
http_get_state timer sec 5
lm92_timer 5, http_request_timer 35
TCP-SYN-Timerout!
http_get_state -1
mail_enable
Send E-Mail (Sie haben Post ;-)


think because it dont reaches the fin flag anymore

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
i captured with wireshark maybe it helps.

it runs fine for x minutes and then it crashes. looks like the mega 
can't handle the duplicated syn from the webserver?
No.     Time        Source                Destination           Protocol Info
    462 1839.979898 192.168.1.99         192.168.2.2          TCP      rprt > http [SYN] Seq=0 Win=1100 Len=0 MSS=1100
    463 1839.979970 192.168.2.2          192.168.1.99         TCP      http > rprt [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
    464 1843.578899 192.168.2.2          192.168.1.99         TCP      http > rprt [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
    465 1844.957153 192.168.1.99         192.168.2.2          TCP      rprt > http [ACK] Seq=1 Ack=1 Win=1100 Len=0
    466 1849.578467 192.168.2.2          192.168.1.99         TCP      http > rprt [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
    467 1849.696817 192.168.1.99         192.168.2.2          TCP      [TCP Dup ACK 465#1] rprt > http [ACK] Seq=1 Ack=1 Win=1100 Len=0
    468 1861.576604 192.168.2.2          192.168.1.99         TCP      http > rprt [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
    469 1861.679115 192.168.1.99         192.168.2.2          TCP      [TCP Dup ACK 465#2] rprt > http [ACK] Seq=1 Ack=1 Win=1100 Len=0
    470 1879.979129 192.168.1.99         192.168.2.2          TCP      slinterbase > http [SYN] Seq=0 Win=1100 Len=0 MSS=1100
    471 1879.979197 192.168.2.2          192.168.1.99         TCP      http > slinterbase [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
    472 1879.998121 192.168.1.99         192.168.2.2          HTTP     GET /temp/insert.php?S1=8b31&T1=0&S2=157b&T2=153&S3=052a&T3=0&S4=b65e&T4=172&Time=22:34:13&Date=2010-10-26 HTTP/1.1 Continuation or non-HTTP traffic
    473 1879.998215 192.168.2.2          192.168.1.99         TCP      http > rprt [ACK] Seq=1 Ack=230 Win=6432 Len=0
    474 1880.006826 192.168.2.2          192.168.1.99         HTTP     HTTP/1.1 200 OK  (text/html)
    475 1880.007024 192.168.2.2          192.168.1.99         TCP      http > rprt [FIN, ACK] Seq=201 Ack=230 Win=6432 Len=0
    476 1883.007089 192.168.2.2          192.168.1.99         HTTP     [TCP Retransmission] HTTP/1.1 200 OK  (text/html)
    477 1883.173055 192.168.2.2          192.168.1.99         TCP      http > slinterbase [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
    478 1889.005637 192.168.2.2          192.168.1.99         HTTP     [TCP Retransmission] HTTP/1.1 200 OK  (text/html)
    479 1889.171620 192.168.2.2          192.168.1.99         TCP      http > slinterbase [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
    480 1901.003775 192.168.2.2          192.168.1.99         HTTP     [TCP Retransmission] HTTP/1.1 200 OK  (text/html)
    481 1901.169763 192.168.2.2          192.168.1.99         TCP      http > slinterbase [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
    482 1901.170162 192.168.1.99         192.168.2.2          TCP      slinterbase > http [RST] Seq=1 Win=0 Len=0

Author: Sj Sj (sj1)
Posted on:

Rate this post
0 useful
not useful
it looks like when it failures sequence numbers are zero, the next try 
(tcp session) the sequence number is again zero, this cant be?

or can a sequence number be zero again when using a different source 
port?


i'm not sure, aint be that good to research...

Author: Sascha Weber (sascha-w)
Posted on:

Rate this post
0 useful
not useful
Sj Sj wrote:
> when adding this line it failures at start
> ...
> http_get_state timer sec 0
> lm92_timer 9, http_request_timer 39
> http_get_state timer sec 0
> lm92_timer 8, http_request_timer 38
> http_get_state timer sec 3
> lm92_timer 7, http_request_timer 37
> http_get_state timer sec 4
> lm92_timer 6, http_request_timer 36
> http_get_state timer sec 5
> lm92_timer 5, http_request_timer 35
> TCP-SYN-Timerout!
> http_get_state -1
> ...
>
> think because it dont reaches the fin flag anymore
i dont understand - AVR don't get SYN-ACK from server, but the 
connection establishment is handled by stack, and the function "test" is 
not runnig there.
------------------------------------------------------------------------
> i captured with wireshark maybe it helps.
>
> it runs fine for x minutes and then it crashes. looks like the mega
> can't handle the duplicated syn from the webserver?
this capture is recorded without or with added line?
for SYN/ACK at frame 463 avr sends no reply with ACK !? Is it too busy?

Between frame 471 and 472 ACK-packet, which created by stack.c, are 
missing!
------------------------------------------------------------------------
> it looks like when it failures sequence numbers are zero, the next try
> (tcp session) the sequence number is again zero, this cant be?
Yes it's ok - the zero is always the "relativ seq-number" the absolute 
number starts always with the value at >stack.c/tcp_port_open<

Sascha

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.