EmbDev.net

Forum: µC & Digital Electronics http_get from ulrich radig


von Sj S. (sj1)


Rate this post
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.
1
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.

von sascha (Guest)


Rate this post
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

von Sj S. (sj1)


Rate this post
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?

von Sascha (Guest)


Rate this post
useful
not useful
Hi,

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

Sascha

von Sascha (Guest)


Attached files:

Rate this post
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

von Sj S. (sj1)


Rate this post
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:
1
        #if GET_WEATHER
2
        http_request ();
3
        #endif


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

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(); ?

von Sj S. (sj1)


Rate this post
useful
not useful
I changed the code to this:
1
void run_http_request (void)
2
{
3
  if (http_get_state==-1)
4
  {
5
    http_get_state=0;
6
    http_request();
7
  } else {
8
    HTTPC_DEBUG("ERROR - HTTP Request BUSY\n\r");
9
  }
10
}

result:
1
get
2
HTTP Request
3
TCP Eintrag gefunden (HTTP_CLIENT)!
4
Ready
5
6
7
8
9
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

von Sascha W. (sascha_w)


Rate this post
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:
>
>
1
>         #if GET_WEATHER
2
>         http_request ();
3
>         #endif
4
>
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
>
>
1
> void run_http_request (void)
2
> {
3
>   if (http_get_state==-1)
4
>   {
5
>     http_get_state=0;
6
>   } else {
7
>     HTTPC_DEBUG("ERROR - HTTP Request BUSY\n\r");
8
>   }
9
> }
10
>
>
> 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

von Sj S. (sj1)


Attached files:

Rate this post
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?

von Sascha W. (sascha_w)


Rate this post
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

von Sj S. (sj1)



Rate this post
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: ??

von Sj S. (sj1)



Rate this post
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 :/

von Sj S. (sj1)


Rate this post
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?

von Sascha W. (sascha_w)


Rate this post
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

von Sj S. (sj1)


Rate this post
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?
1
/*----------------------------------------------------------------------------
2
 Copyright:      Radig Ulrich  mailto: mail@ulrichradig.de
3
 Author:         Radig Ulrich
4
 Remarks:        
5
 known Problems: none
6
 Version:        12.11.2007
7
 Description:    HTTP-Client (empfang einer Webseite)
8
9
 Dieses Programm ist freie Software. Sie können es unter den Bedingungen der 
10
 GNU General Public License, wie von der Free Software Foundation veröffentlicht, 
11
 weitergeben und/oder modifizieren, entweder gemäß Version 2 der Lizenz oder 
12
 (nach Ihrer Option) jeder späteren Version. 
13
14
 Die Veröffentlichung dieses Programms erfolgt in der Hoffnung, 
15
 daß es Ihnen von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, 
16
 sogar ohne die implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT 
17
 FÜR EINEN BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License. 
18
19
 Sie sollten eine Kopie der GNU General Public License zusammen mit diesem 
20
 Programm erhalten haben. 
21
 Falls nicht, schreiben Sie an die Free Software Foundation, 
22
 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 
23
------------------------------------------------------------------------------*/
24
#include "config.h"
25
#include "http_get.h" 
26
#include <avr/io.h>
27
#include <avr/pgmspace.h>
28
#include "stack.h"
29
#include "usart.h"
30
#include "timer.h"
31
  
32
//PROGMEM char WEATHER_GET_STRING[] = {"GET /koch.htm HTTP/1.1\r\n"
33
PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Mainboard_Sensors_Id=c81e728d9d4c2f636f067f89cc14862c&Mainboard_Sensors_Log_Temperature=13 HTTP/1.1\r\n"
34
                                     //"GET / HTTP/1.1\r\n"
35
                                     "Host: www.webservicex.net\r\n"
36
                                     //"Host: www.ulrichradig.de\r\n"
37
                                     "Connection: close\r\n\r\n"};
38
39
volatile unsigned int http_get_state = -1;
40
unsigned int my_http_cp = LOCAL_HTTP_PORT;
41
42
//----------------------------------------------------------------------------
43
//HTTP_GET INIT
44
void httpg_init (void)
45
{
46
        ////unsigned int my_http_cp = LOCAL_HTTP_PORT;
47
        add_tcp_app (my_http_cp, (void(*)(unsigned char))test);
48
}
49
//----------------------------------------------------------------------------
50
//Abfrage starten
51
void run_http_request (void)
52
{
53
  if (http_get_state==-1)
54
  {
55
    http_get_state=0;
56
  } else {
57
    HTTPC_DEBUG("ERROR - HTTP Request BUSY\n\r");
58
  }
59
}
60
//----------------------------------------------------------------------------
61
//Daten kommen von einem Webserver an!!
62
void test (unsigned char index)
63
{
64
  for (int a = TCP_DATA_START_VAR;a < TCP_DATA_END_VAR;a++)
65
  {
66
    HTTPC_DEBUG("%c",eth_buffer[a]);
67
  }
68
  tcp_entry[index].time = TCP_TIME_OFF;
69
    if(tcp_entry[index].status & FIN_FLAG)
70
  {
71
        http_get_state=-1;
72
    HTTPC_DEBUG("HTTP Request - EOF\n\r");  
73
    //tcp_Port_close(index);
74
    }
75
    else ////changed to else
76
  { 
77
    tcp_entry[index].status = ACK_FLAG;
78
    create_new_tcp_packet(0,index);
79
  }
80
}
81
82
//----------------------------------------------------------------------------
83
//HTTP Request an einen Webserver stelle
84
void http_request (void)
85
{
86
    unsigned long index = MAX_TCP_ENTRY;
87
    
88
    if (http_get_state > 1 && http_get_state < 20) http_get_state++;
89
90
    if (http_get_state == 0)
91
    {
92
93
        //offnet eine Verbindung zu meinem Webserver
94
        HTTPC_DEBUG("HTTP Request\n\r");
95
        //unsigned int my_http_cp = LOCAL_HTTP_PORT;        
96
97
  /*new code*/
98
    unsigned int my_httpget_cp_new = my_http_cp + time;
99
    if (my_httpget_cp_new < 1000) my_httpget_cp_new +=1000;
100
    
101
    change_port_tcp_app (my_http_cp, my_httpget_cp_new);
102
    my_http_cp = my_httpget_cp_new;  
103
104
  /*eo new code*/
105
  
106
107
108
109
        //ARP Request senden
110
        if(arp_request (WEATHER_SERVER_IP))
111
        {
112
            for(unsigned long a=0;a<2000000;a++){asm("nop");};
113
            
114
            tcp_port_open (WEATHER_SERVER_IP,HTONS(80),HTONS(my_http_cp));
115
               
116
            unsigned char tmp_counter = 0;
117
            while((index >= MAX_ARP_ENTRY) && (tcp_entry[index].app_status != 1))
118
            {
119
                index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
120
                if (tmp_counter++ > 30)
121
                {
122
                    HTTPC_DEBUG("TCP Eintrag nicht gefunden (HTTP_CLIENT)!\r\n");
123
          http_get_state = -1;
124
                    return;
125
                }
126
            }
127
             
128
            HTTPC_DEBUG("TCP Eintrag gefunden (HTTP_CLIENT)!\r\n");
129
            tcp_entry[index].first_ack = 1;
130
            http_get_state = 2;
131
        }
132
        else
133
        {
134
            http_get_state = -1;
135
        }
136
    }
137
    
138
    //if (http_get_state == 10)  
139
    if (http_get_state > 10 && http_get_state < 20)
140
    {
141
        HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
142
        index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
143
        memcpy_P(&eth_buffer[TCP_DATA_START],WEATHER_GET_STRING,(sizeof(WEATHER_GET_STRING)-1));
144
        tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
145
        create_new_tcp_packet((sizeof(WEATHER_GET_STRING)-1),index);
146
    http_get_state=21;
147
    }
148
}


i changed:
1
define global:
2
unsigned int my_http_cp = LOCAL_HTTP_PORT;
1
void httpg_init (void)
2
{
3
        ////unsigned int my_http_cp = LOCAL_HTTP_PORT;
4
        add_tcp_app (my_http_cp, (void(*)(unsigned char))test);
5
}
1
added the else statement, else when FIN the connection you get an extra ACK, the extra ACK is not needed i think?
2
3
void test (unsigned char index)
4
{
5
  for (int a = TCP_DATA_START_VAR;a < TCP_DATA_END_VAR;a++)
6
  {
7
    HTTPC_DEBUG("%c",eth_buffer[a]);
8
  }
9
  tcp_entry[index].time = TCP_TIME_OFF;
10
    if(tcp_entry[index].status & FIN_FLAG)
11
  {
12
        http_get_state=-1;
13
    HTTPC_DEBUG("HTTP Request - EOF\n\r");  
14
    //tcp_Port_close(index);
15
    }
16
    else ////changed to else
17
  { 
18
    tcp_entry[index].status = ACK_FLAG;
19
    create_new_tcp_packet(0,index);
20
  }
21
}
1
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
2
and added /*new code*/ part
3
4
5
//----------------------------------------------------------------------------
6
//HTTP Request an einen Webserver stelle
7
void http_request (void)
8
{
9
    unsigned long index = MAX_TCP_ENTRY;
10
    
11
    if (http_get_state > 1 && http_get_state < 20) http_get_state++;
12
13
    if (http_get_state == 0)
14
    {
15
16
        //offnet eine Verbindung zu meinem Webserver
17
        HTTPC_DEBUG("HTTP Request\n\r");
18
        //unsigned int my_http_cp = LOCAL_HTTP_PORT;        
19
20
  /*new code*/
21
    unsigned int my_httpget_cp_new = my_http_cp + time;
22
    if (my_httpget_cp_new < 1000) my_httpget_cp_new +=1000;
23
    
24
    change_port_tcp_app (my_http_cp, my_httpget_cp_new);
25
    my_http_cp = my_httpget_cp_new;  
26
27
  /*eo new code*/
28
  
29
30
31
32
        //ARP Request senden
33
        if(arp_request (WEATHER_SERVER_IP))
34
        {
35
            for(unsigned long a=0;a<2000000;a++){asm("nop");};
36
            
37
            tcp_port_open (WEATHER_SERVER_IP,HTONS(80),HTONS(my_http_cp));
38
               
39
            unsigned char tmp_counter = 0;
40
            while((index >= MAX_ARP_ENTRY) && (tcp_entry[index].app_status != 1))
41
            {
42
                index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
43
                if (tmp_counter++ > 30)
44
                {
45
                    HTTPC_DEBUG("TCP Eintrag nicht gefunden (HTTP_CLIENT)!\r\n");
46
          http_get_state = -1;
47
                    return;
48
                }
49
            }
50
             
51
            HTTPC_DEBUG("TCP Eintrag gefunden (HTTP_CLIENT)!\r\n");
52
            tcp_entry[index].first_ack = 1;
53
            http_get_state = 2;
54
        }
55
        else
56
        {
57
            http_get_state = -1;
58
        }
59
    }
60
    
61
    //if (http_get_state == 10)  
62
    if (http_get_state > 10 && http_get_state < 20)
63
    {
64
        HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
65
        index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
66
        memcpy_P(&eth_buffer[TCP_DATA_START],WEATHER_GET_STRING,(sizeof(WEATHER_GET_STRING)-1));
67
        tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
68
        create_new_tcp_packet((sizeof(WEATHER_GET_STRING)-1),index);
69
    http_get_state=21;
70
    }
71
}

von Sascha W. (sascha_w)


Rate this post
useful
not useful
1
//Daten kommen von einem Webserver an!!
2
void test (unsigned char index)
3
{
4
  for (int a = TCP_DATA_START_VAR;a < TCP_DATA_END_VAR;a++)
5
  {
6
    HTTPC_DEBUG("%c",eth_buffer[a]);
7
  }
8
  tcp_entry[index].time = TCP_TIME_OFF;
9
    if(tcp_entry[index].status & FIN_FLAG)
10
    {
11
        http_get_state=-1;
12
        HTTPC_DEBUG("HTTP Request - EOF\n\r");
13
    }
14
    tcp_entry[index].status = ACK_FLAG;
15
    create_new_tcp_packet(0,index);
16
}
/\ 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.
1
  /*new code*/
2
    unsigned int my_httpget_cp_new = my_http_cp + 1;
3
    if (my_httpget_cp_new > (LOCAL_HTTP_PORT+300)) my_httpget_cp_new = LOCAL_HTTP_PORT;
4
    
5
    change_port_tcp_app (my_http_cp, my_httpget_cp_new);
6
    my_http_cp = my_httpget_cp_new;  
7
8
  /*eo new code*/

Sascha

von Sj S. (sj1)


Rate this post
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

von Sascha W. (sascha_w)


Rate this post
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

von Sj S. (sj1)


Rate this post
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:
1
void http_request (void)
2
3
        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:
1
//Daten kommen vom EMAIL- Server an!! (Mail wird versendet)
2
3
void mail_data (unsigned char index)
4
5
{
6
7
    //Verbindung wurde abgebaut!
8
9
    if (tcp_entry[index].status & FIN_FLAG)
10
11
    {
12
13
        return;
14
15
    }

von Sascha W. (sascha_w)


Rate this post
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_Protocol#Connection_termination
"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:
>
1
> void http_request (void)
2
> 
3
>         tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
4
>
this only send with GET request - once per connection

> if i look at sendmail.c there is no ack send:
>
1
> //Daten kommen vom EMAIL- Server an!! (Mail wird versendet)
2
> 
3
> void mail_data (unsigned char index)
4
> 
5
> {
6
> 
7
>     //Verbindung wurde abgebaut!
8
> 
9
>     if (tcp_entry[index].status & FIN_FLAG)
10
> 
11
>     {
12
> 
13
>         return;
14
> 
15
>     }
16
> 
17
> 
18
>
see above

Sascha

von Sj S. (sj1)


Attached files:

Rate this post
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
1
////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:
1
    //if (http_get_state == 10)  
2
    if (http_get_state > 10 && http_get_state < 20)
3
    {
4
        HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
5
        index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
6
        memcpy_P(&eth_buffer[TCP_DATA_START],WEATHER_GET_STRING,(sizeof(WEATHER_GET_STRING)-1));
7
        tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
8
        create_new_tcp_packet((sizeof(WEATHER_GET_STRING)-1),index);
9
    http_get_state=21;
10
    }

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?

von Sascha W. (sascha_w)


Rate this post
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
>
>
1
> ////tcp_entry[index].first_ack = 1;
2
>
>
> 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:
>
1
> 
2
>     //if (http_get_state == 10)
3
>     if (http_get_state > 10 && http_get_state < 20)
4
>     {
5
>         HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
6
>         index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
7
>         memcpy_P(&eth_buffer[TCP_DATA_START],WEATHER_GET_STRING,(sizeof(WEATHER_GET_STRING)-1));
8
>         tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
9
>         create_new_tcp_packet((sizeof(WEATHER_GET_STRING)-1),index);
10
>     http_get_state=21;
11
>     }
12
> 
13
>
>
> 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

von Sj S. (sj1)


Rate this post
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:
1
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:
1
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:
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);
2
    HTTPC_DEBUG("test: %s\r\n", WEATHER_GET_STRING);

von krepperm (Guest)


Rate this post
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

von Sj S. (sj1)


Attached files:

Rate this post
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?

von krepperm (Guest)


Rate this post
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

von Sj S. (sj1)


Rate this post
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
1
//PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Mainboard_Sensors_Id=c81e728d9d4c2f636f067f89cc14862c&Mainboard_Sensors_Log_Temperature=13 HTTP/1.1\r\n"
2
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.
1
void run_http_request (void)
2
{
3
4
5
  if (http_get_state==-1)
6
  {
7
    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);
8
    HTTPC_DEBUG("%s\r\n", WEATHER_GET_STRING);
9
    
10
    http_get_state=0;
11
  } else {
12
    HTTPC_DEBUG("ERROR - HTTP Request BUSY\n\r");
13
  }
14
}


try again,

von krepperm (Guest)


Rate this post
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.

von Sj S. (sj1)


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

von krepperm (Guest)


Attached files:

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

thx markus

von Sj S. (sj1)


Rate this post
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

von krepperm (Guest)


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

I check it.

br markus

von Sj S. (sj1)


Rate this post
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 :/

von Katarina Beecker (Guest)


Rate this post
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

von Sj S. (sj1)


Rate this post
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:
1
No.     Time        Source                Destination           Protocol Info
2
      1 0.000000    192.168.10.99         192.168.20.2          TCP      23794 > http [SYN] Seq=0 Win=1100 Len=0 MSS=1100
3
      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
4
      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
5
      4 0.043776    192.168.20.2          192.168.10.99         TCP      http > 23794 [RST] Seq=459887518 Win=0 Len=0
6
      5 0.054712    192.168.10.99         192.168.20.2          TCP      23794 > http [ACK] Seq=1 Ack=1 Win=1100 Len=0
7
      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
8
      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

von Sascha W. (sascha-w)


Rate this post
useful
not useful
Hello,

after
1
HTTPC_DEBUG("TCP Eintrag gefunden (HTTP_CLIENT)!\r\n");
2
tcp_entry[index].first_ack = 1;
you must wait that
1
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

von Sj S. (sj1)


Rate this post
useful
not useful
hm

at what point do i need to wait?

its already waiting at: ???
1
            while((index >= MAX_ARP_ENTRY) && (tcp_entry[index].app_status != 1))
2
            {
1
#include "config.h"
2
#include "http_get.h" 
3
#include <avr/io.h>
4
#include <avr/pgmspace.h>
5
#include <string.h>
6
7
#include <stdio.h>
8
#include "stack.h"
9
#include "usart.h"
10
#include "timer.h"
11
  
12
//PROGMEM char WEATHER_GET_STRING[] = {"GET /koch.htm HTTP/1.1\r\n"
13
//PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Mainboard_Sensors_Id=c81e728d9d4c2f636f067f89cc14862c&Mainboard_Sensors_Log_Temperature=13 HTTP/1.1\r\n"
14
15
//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"
16
17
//PROGMEM char WEATHER_GET_STRING[] = {"GET /temp/insert.php?Id=%d&Temperature=%d&DateTimeGenerated=%s&blaat=1 HTTP/1.1\r\n"
18
//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"
19
//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"
20
//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"
21
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"
22
23
24
25
26
                                     //"GET / HTTP/1.1\r\n"
27
                                     "Host: www.webservicex.net\r\n"
28
                                     //"Host: www.ulrichradig.de\r\n"
29
                                     "Connection: close\r\n\r\n"};
30
31
volatile unsigned int http_get_state = -1;
32
unsigned int my_http_cp = LOCAL_HTTP_PORT;
33
char buffer_string[230]={0};
34
35
//----------------------------------------------------------------------------
36
//HTTP_GET INIT
37
void httpg_init (void)
38
{
39
        ////unsigned int my_http_cp = LOCAL_HTTP_PORT;
40
        add_tcp_app (my_http_cp, (void(*)(unsigned char))test);
41
}
42
//----------------------------------------------------------------------------
43
44
45
46
//Abfrage starten
47
//void run_http_request (void)
48
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)
49
{
50
  sprintf_P(buffer_string,WEATHER_GET_STRING,sensor1, *LM92_CurrentTemp1,sensor2, *LM92_CurrentTemp2,sensor3, *LM92_CurrentTemp3,sensor4, *LM92_CurrentTemp4,sql_time,sql_date);
51
    
52
  if (http_get_state==-1)
53
  {
54
55
    http_get_state=0;
56
57
    //usart_write("DataLog: [Sensor: %i] [Temperature: %i] [Time: %s] [Date: %s]\r\n",*sensor_id,*LM92_CurrentTemp,sql_time,sql_date);
58
    //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);
59
    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);
60
    
61
    usart_write("HTTP GET URL: %s\r\n",buffer_string);
62
    
63
    
64
    HTTPC_DEBUG("buffer: %s\r\n", buffer_string);
65
  
66
  } else {
67
    //usart_write("DataLog Fail: [Sensor: %i] [Temperature: %i] [Time: %s] [Date: %s]\r\n",*sensor_id,*LM92_CurrentTemp,sql_time,sql_date);
68
    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);    
69
    usart_write("HTTP GET URL: %s\r\n",buffer_string);
70
    usart_write("-------\r\n");
71
    
72
    //savetosd()
73
    
74
    HTTPC_DEBUG("ERROR - HTTP Request BUSY\n\r");
75
  }
76
}
77
//----------------------------------------------------------------------------
78
//Daten kommen von einem Webserver an!!
79
void test (unsigned char index)
80
{
81
char buffer[10]={0};
82
83
  for (int a = TCP_DATA_START_VAR;a < TCP_DATA_END_VAR;a++)
84
  {
85
    HTTPC_DEBUG("%c",eth_buffer[a]);
86
87
    if (eth_buffer[a] == '$') //look for #$ string
88
    {
89
      if (eth_buffer[a+1] == '#') 
90
      {  
91
        if (eth_buffer[a+2] != '1') 
92
        {  
93
          usart_write("SQL insert failed\r\n",eth_buffer[a+2]);
94
          
95
        
96
        }
97
      }
98
    }  
99
  }
100
  
101
  
102
  tcp_entry[index].time = TCP_TIME_OFF;
103
    if(tcp_entry[index].status & FIN_FLAG)
104
  {
105
        http_get_state=-1;
106
    
107
    usart_write("HTTP Request - EOF\n\r");  
108
    usart_write("-------\r\n");
109
    return;
110
    }
111
    //else ////changed to else
112
  //{ 
113
    tcp_entry[index].status = ACK_FLAG;
114
    create_new_tcp_packet(0,index);
115
  //}
116
}
117
118
//----------------------------------------------------------------------------
119
//HTTP Request an einen Webserver stelle
120
void http_request (void)
121
{
122
    unsigned long index = MAX_TCP_ENTRY;
123
    
124
    if (http_get_state > 1 && http_get_state < 20) http_get_state++;
125
126
    if (http_get_state == 0)
127
    {
128
129
        //offnet eine Verbindung zu meinem Webserver
130
        HTTPC_DEBUG("HTTP Request\n\r");
131
        //unsigned int my_http_cp = LOCAL_HTTP_PORT;        
132
133
134
    unsigned int my_httpget_cp_new = my_http_cp + time;
135
    if (my_httpget_cp_new < 1000) my_httpget_cp_new +=1000;
136
    
137
    change_port_tcp_app (my_http_cp, my_httpget_cp_new);
138
    my_http_cp = my_httpget_cp_new;  
139
140
       //ARP Request senden
141
        if(arp_request (WEATHER_SERVER_IP))
142
        {
143
            for(unsigned long a=0;a<2000000;a++){asm("nop");};
144
            
145
            tcp_port_open (WEATHER_SERVER_IP,HTONS(80),HTONS(my_http_cp));
146
               
147
            unsigned char tmp_counter = 0;
148
            while((index >= MAX_ARP_ENTRY) && (tcp_entry[index].app_status != 1))
149
            {
150
                index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
151
                if (tmp_counter++ > 30)
152
                {
153
                    HTTPC_DEBUG("TCP Eintrag nicht gefunden (HTTP_CLIENT)!\r\n");
154
          http_get_state = -1;
155
                    return;
156
                }
157
            }
158
             
159
            HTTPC_DEBUG("TCP Eintrag gefunden (HTTP_CLIENT)!\r\n");
160
            tcp_entry[index].first_ack = 1;
161
            http_get_state = 2;
162
        }
163
        else
164
        {
165
            http_get_state = -1;
166
        }
167
    }
168
    
169
    //if (http_get_state == 10)  
170
    if (http_get_state > 10 && http_get_state < 20)
171
    {
172
        HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
173
        index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
174
        //memcpy_P(&eth_buffer[TCP_DATA_START],WEATHER_GET_STRING,(sizeof(WEATHER_GET_STRING)-1));
175
    memcpy(&eth_buffer[TCP_DATA_START],buffer_string,(sizeof(buffer_string)-1));
176
        tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
177
        create_new_tcp_packet((sizeof(buffer_string)-1),index);
178
    http_get_state=21;
179
    
180
    usart_write("index: %i\r\n", index);
181
    }
182
}

something like:??
1
    if (tcp_entry[index].app_status == 1)
2
  {
3
    //if (http_get_state == 10)  
4
    if (http_get_state > 10 && http_get_state < 20)
5
    {
6
      HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
7
      index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
8
      //memcpy_P(&eth_buffer[TCP_DATA_START],WEATHER_GET_STRING,(sizeof(WEATHER_GET_STRING)-1));
9
      memcpy(&eth_buffer[TCP_DATA_START],buffer_string,(sizeof(buffer_string)-1));
10
      tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
11
      create_new_tcp_packet((sizeof(buffer_string)-1),index);
12
      http_get_state=21;
13
      
14
      usart_write("index: %i\r\n", index);
15
    }
16
  }

von Sascha W. (sascha-w)


Attached files:

Rate this post
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

von Sj S. (sj1)


Rate this post
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:
1
  while (TCP_PORT_TABLE[port_index].port && TCP_PORT_TABLE[port_index].port!=(htons(tcp->TCP_DestPort)))
2
  { 
3
--->>>>>>>>  usart_write("port index %i\r\n",port_index);
4
    port_index++;
5
  }


my German failures, maybe you can translate? :)
1
ystem Ready
2
Compiliert am Oct  4 2010 um 19:16:38
3
Compiliert mit GCC Version 4.3.2
4
5
NIC init:My IP: 192.168.1.99
6
7
TCP Anwendung wird in Liste eingetragen: Eintrag 0
8
TCP Anwendung wird in Liste eingetragen: Eintrag 1
9
TCP Anwendung wird in Liste eingetragen: Eintrag 2
10
11
IP   192.168.1.99
12
MASK 255.255.255.0
13
GW   192.168.1.1
14
UDP Anwendung wird in Liste eingetragen: Eintrag 0
15
ROUTING!
16
ARP Eintrag nicht gefunden*
17
port index 0
18
port index 1
19
port index 2
20
TCP Keine Anwendung gefunden!
21
ARP REPLY EMPFANGEN!
22
**KEINEN ARP EINTRAG GEFUNDEN**
23
ARP EINTRAG GEFUNDEN!
24
ROUTING!
25
ARP Eintrag nicht gefunden*
26
ARP EINTRAG GEFUNDEN!
27
ARP REPLY EMPFANGEN!
28
29
TIME: 18:29:26
30
http\port index 0
31
port index 1
32
port index 2
33
TCP Keine Anwendung gefunden!
34
http
35
ERROR
36
37
DataLog: sensor: 1 2 3 4 [Temperature1: 0] [Temperature2: 221] [Temperature3: 0] [Temperature4: 231] [Time: 19:29:35] [Date: 2010-10-04]
38
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
39
Host: www.webservicex.net
40
Connection: close
41
42
43
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
44
Host: www.webservicex.net
45
Connection: close
46
47
48
HTTP Request
49
TCP Anwendung Port ändern: Eintrag 2
50
MY NETWORK!
51
ARP EINTRAG GEFUNDEN!
52
Oeffen eines Ports mit Server
53
TCP Open neuer Eintrag 0
54
TCP SrcPort -23368
55
TCP Eintrag gefunden (HTTP_CLIENT)!
56
ARP REPLY EMPFANGEN!
57
port index 0
58
port index 1
59
TCP Entry gefunden 0
60
TCP Port wurde vom Server geöffnet STACK:0
61
TCP SrcPort -23368
62
port index 0
63
port index 1
64
port index 2
65
TCP Keine Anwendung gefunden!
66
DataLog Fail: 1 2 3 4 [Temperature1: 0] [Temperature2: 221] [Temperature3: 0] [Temperature4: 232] [Time: 19:29:45] [Date: 2010-10-04]
67
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
68
Host: www.webservicex.net
69
Connection: close
70
71
72
-------
73
ERROR - HTTP Request BUSY
74
DataLog Fail: 1 2 3 4 [Temperature1: 0] [Temperature2: 221] [Temperature3: 0] [Temperature4: 231] [Time: 19:29:55] [Date: 2010-10-04]
75
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
76
Host: www.webservicex.net
77
Connection: close
78
79
80
-------
81
ERROR - HTTP Request BUSY
82
DataLog Fail: 1 2 3 4 [Temperature1: 0] [Temperature2: 221] [Temperature3: 0] [Temperature4: 231] [Time: 19:30:05] [Date: 2010-10-04]
83
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
84
Host: www.webservicex.net
85
Connection: close

von Sascha W. (sascha-w)


Attached files:

Rate this post
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

von Sj S. (sj1)


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

i created an extra delay but without luck
1
        #if GET_WEATHER
2
    if (!teller)
3
    {
4
      http_request ();
5
      teller = 1000;
6
    }  
7
        #endif
8
        teller--;
1
tcp_entry[index].app_status == 1 and not 0
2
3
your code is better but when capturing with wireshark i get three transmissions.
4
5
[code]
6
No.     Time        Source                Destination           Protocol Info
7
      1 0.000000    192.168.1.99         192.168.2.2          TCP      46927 > http [SYN] Seq=0 Win=1100 Len=0 MSS=1100
8
      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
9
      3 0.059202    192.168.1.99         192.168.2.2          TCP      46927 > http [ACK] Seq=1 Ack=1 Win=1100 Len=0
10
      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
11
      5 0.113490    192.168.2.2          192.168.1.99         TCP      http > 46927 [ACK] Seq=1 Ack=230 Win=6432 Len=0
12
      6 0.117004    192.168.2.2          192.168.1.99         HTTP     HTTP/1.1 200 OK  (text/html)
13
      7 0.117233    192.168.2.2          192.168.1.99         TCP      http > 46927 [FIN, ACK] Seq=201 Ack=230 Win=6432 Len=0
14
      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
15
      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
16
     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
17
     11 0.250335    192.168.1.99         192.168.2.2          TCP      46927 > http [ACK] Seq=230 Ack=201 Win=1100 Len=0
18
     12 0.268817    192.168.1.99         192.168.2.2          TCP      46927 > http [FIN, ACK] Seq=230 Ack=202 Win=1100 Len=0
19
     13 0.268867    192.168.2.2          192.168.1.99         TCP      http > 46927 [ACK] Seq=202 Ack=231 Win=6432 Len=0

von Sascha W. (sascha-w)


Rate this post
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

von Sj S. (sj1)


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

von Sj S. (sj1)


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

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



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:
1
No.     Time        Source                Destination           Protocol Info
2
    125 30.443885   192.168.1.99         192.168.1.22         TCP      13161 > http [SYN] Seq=0 Win=1100 Len=0 MSS=1100
3
    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
4
    127 30.490949   192.168.1.99         192.168.1.22         TCP      13161 > http [ACK] Seq=1 Ack=1 Win=1100 Len=0
5
    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
6
    129 30.542955   192.168.1.22         192.168.1.99         HTTP     HTTP/1.1 200 OK  (text/html)
7
    130 30.543120   192.168.1.22         192.168.1.99         TCP      http > 13161 [FIN, ACK] Seq=305 Ack=230 Win=64671 Len=0
8
    131 30.654627   192.168.1.99         192.168.1.22         TCP      13161 > http [ACK] Seq=230 Ack=305 Win=1100 Len=0
9
    132 30.673119   192.168.1.99         192.168.1.22         TCP      13161 > http [FIN, ACK] Seq=230 Ack=306 Win=1100 Len=0
10
    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:
1
No.     Time        Source                Destination           Protocol Info
2
      1 0.000000    192.168.1.99         192.168.2.2          TCP      50877 > http [SYN] Seq=0 Win=1100 Len=0 MSS=1100
3
      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
4
      3 0.048717    192.168.1.99         192.168.2.2          TCP      50877 > http [ACK] Seq=1 Ack=1 Win=1100 Len=0
5
      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
6
      5 0.081757    192.168.2.2          192.168.1.99         TCP      http > 50877 [ACK] Seq=1 Ack=230 Win=6432 Len=0
7
      6 0.085280    192.168.2.2          192.168.1.99         HTTP     HTTP/1.1 200 OK  (text/html)
8
      7 0.085511    192.168.2.2          192.168.1.99         TCP      http > 50877 [FIN, ACK] Seq=201 Ack=230 Win=6432 Len=0
9
      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
10
      9 0.201862    192.168.1.99         192.168.2.2          TCP      50877 > http [ACK] Seq=230 Ack=201 Win=1100 Len=0
11
     10 0.219848    192.168.1.99         192.168.2.2          TCP      50877 > http [FIN, ACK] Seq=230 Ack=202 Win=1100 Len=0
12
     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
1
No.     Time        Source                Destination           Protocol Info
2
      1 0.000000    192.168.1.22         192.168.2.2          TCP      tarantella > http [SYN] Seq=0 Win=64512 Len=0 MSS=1350
3
      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
4
      3 0.032238    192.168.1.22         192.168.2.2          TCP      tarantella > http [ACK] Seq=1 Ack=1 Win=64800 Len=0
5
      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 
6
      5 0.037586    192.168.2.2          192.168.1.22         TCP      http > tarantella [ACK] Seq=1 Ack=464 Win=6432 Len=0
7
      6 0.076260    192.168.2.2          192.168.1.22         HTTP     HTTP/1.1 200 OK  (text/html)
8
      7 0.076571    192.168.2.2          192.168.1.22         TCP      http > tarantella [FIN, ACK] Seq=201 Ack=464 Win=6432 Len=0
9
      8 0.111936    192.168.1.22         192.168.2.2          TCP      tarantella > http [ACK] Seq=464 Ack=202 Win=64600 Len=0
10
      9 0.123671    192.168.1.22         192.168.2.2          TCP      tarantella > http [FIN, ACK] Seq=464 Ack=202 Win=64600 Len=0
11
     10 0.123710    192.168.2.2          192.168.1.22         TCP      http > tarantella [ACK] Seq=202 Ack=465 Win=6432 Len=0

von Sascha W. (sascha-w)


Rate this post
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

von Sj S. (sj1)


Rate this post
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?

von Sascha W. (sascha-w)


Rate this post
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 ...
1
if (http_get_state > 1 && http_get_state < 20) http_get_state++;
... from http_request() into timer.c ...
1
//Timer Interrupt
2
#if EXTCLOCK==1
3
  #if defined (__AVR_ATmega644__)
4
    ISR (TIMER2_COMPA_vect)
5
  #else
6
    ISR (TIMER2_COMP_vect)
7
  #endif
8
#else
9
  ISR (TIMER1_COMPA_vect)
10
#endif
11
{
12
  //tick 1 second
13
  time++;
14
    if((stack_watchdog++) > WTT)  //emergency reset of the stack
15
    {
16
        RESET();
17
  }
18
    eth.timer = 1;
19
//INSERT
20
if (http_get_state > 1 && http_get_state < 20) http_get_state++;
21
  #if USE_NTP
22
  ntp_timer--;
23
  #endif //USE_NTP
24
  #if USE_DHCP
25
  if ( dhcp_lease > 0 ) dhcp_lease--;
26
    if ( gp_timer   > 0 ) gp_timer--;
27
    #endif //USE_DHCP
28
}

> - 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

von Sj S. (sj1)


Rate this post
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:
1
TCP SrcPort 2717
2
TCP TCP_DestPort 80
3
TCP-Stack Eintrag gelöscht! STACK:0
4
TCP Eintrag nicht gefunden
5
DataLog: sensor: 1 2 3 4 [Temperature1: 0] [Temperature2: 202] [Temperature3: 0] [Temperature4: 202] [Time: 20:32:36] [Date: 2010-10-07]
6
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
7
Host: www.webservicex.net
8
Connection: close
9
10
11
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
12
Host: www.webservicex.net
13
Connection: close
14
15
16
HTTP Request
17
TCP Anwendung Port ändern: Eintrag 2
18
ROUTING!
19
ARP EINTRAG GEFUNDEN!
20
Oeffen eines Ports mit Server
21
TCP Open neuer Eintrag 0
22
TCP SrcPort 2718
23
TCP TCP_DestPort 80
24
TCP Eintrag gefunden (HTTP_CLIENT)!
25
ARP REPLY EMPFANGEN!
26
TCP Entry gefunden 0
27
TCP Port wurde vom Server geöffnet STACK:0
28
TCP SrcPort 2718
29
TCP TCP_DestPort 80
30
31
32
33
Daten Anfordern
34
TCP SrcPort 2718
35
TCP TCP_DestPort 80
36
index: 0
37
TCP Entry gefunden 0
38
TCP Entry gefunden 0
39
HTTP/1.1 200 OK
40
Date: Fri, 08 Oct 2010 18:22:03 GMT
41
Server: Apache/2.2.3 (CentOS)
42
X-Powered-By: PHP/5.2.10
43
Content-Length: 9
44
Connection: close
45
Content-Type: text/html; charset=UTF-8
46
47
48
49
$#1
50
TCP SrcPort 2718
51
TCP TCP_DestPort 80
52
TCP Entry gefunden 0
53
HTTP Request - EOF
54
-------
55
TCP SrcPort 2718
56
TCP TCP_DestPort 80
57
TCP-Stack Eintrag gelöscht! STACK:0
58
TCP Eintrag nicht gefunden
59
DataLog: sensor: 1 2 3 4 [Temperature1: 0] [Temperature2: 202] [Temperature3: 0] [Temperature4: 202] [Time: 20:32:46] [Date: 2010-10-07]
60
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
61
Host: www.webservicex.net
62
Connection: close
63
64
65
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
66
Host: www.webservicex.net
67
Connection: close
68
69
70
HTTP Request
71
TCP Anwendung Port ändern: Eintrag 2
72
ROUTING!
73
ARP EINTRAG GEFUNDEN!
74
Oeffen eines Ports mit Server
75
TCP Open neuer Eintrag 0
76
TCP SrcPort 2719
77
TCP TCP_DestPort 80
78
TCP Eintrag gefunden (HTTP_CLIENT)!
79
ARP REPLY EMPFANGEN!
80
DataLog Fail: 1 2 3 4 [Temperature1: 0] [Temperature2: 202] [Temperature3: 0] [Temperature4: 201] [Time: 20:32:56] [Date: 2010-10-07]
81
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
82
Host: www.webservicex.net
83
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.

von Sascha W. (sascha-w)


Rate this post
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

von Sj S. (sj1)


Rate this post
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?

von Sascha W. (sascha-w)


Rate this post
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

von Sj S. (sj1)


Attached files:

Rate this post
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
1
  //NEW
2
    //if (http_get_state == 20) //20 or more (if waittime to short) but you must change some values more 
3
    //{
4
      //DEBUG "Error - no answer from server 
5
     // http_get_state = -1;
6
    //}

because this will only bypass the actual problem

von Sascha W. (sascha-w)


Attached files:

Rate this post
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

von Sj S. (sj1)


Attached files:

Rate this post
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 ?

von Sj S. (sj1)


Rate this post
useful
not useful
i changed
1
    if (tcp_entry[index].app_status == 1)
2
3
to:
4
5
    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
1
HTTP Request
2
debug 1
3
debug 2
4
debug 3
5
debug 4
6
TCP Eintrag gefunden (HTTP_CLIENT)!
7
TCP-SYN-Timerout!
8
HTTP Request
9
debug 1
10
debug 2
11
debug 3
12
debug 4
13
TCP Eintrag gefunden (HTTP_CLIENT)!
14
LM92_ReadTemperature
15
DataLog Fail: 1 2 3 4 [Temperature1: 0] [Temperature2: 210] [Temperature3: 0] [Temperature4: 211] [Time: 22:25:52] [Date: 2010-10-11]
16
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
17
Host: www.webservicex.net
18
Connection: close
19
20
21
-------
22
ERROR - HTTP Request BUSY
23
TCP-SYN-Timerout!
24
HTTP Request
25
debug 1
26
debug 2
27
debug 3
28
debug 4
29
TCP Eintrag gefunden (HTTP_CLIENT)!
30
tcp_entry[index].app_status4 1
31
Connection etablished!
32
33
34
35
Daten Anfordern
36
index: 0
37
tcp
38
00  IP:192.168.002.002  PORT:0080  Time:0028
39
01  IP:192.168.002.002  PORT:0080  Time:0021
40
02  IP:192.168.002.002  PORT:0080  Time:0027
41
03  IP:000.000.000.000  PORT:0000  Time:0000
42
04  IP:000.000.000.000  PORT:0000  Time:0000
43
Ready
44
45
TCP-Connection-Timeout!
46
tcp_entry[index].app_status4 1
47
Connection etablished!

the strange thing is, it starts automatic

i comment the http_get_state=0; line and still HTTP Request is running!
1
  if (http_get_state==-1)
2
  {
3
4
    http_get_state=0;
1
HTTP Request
2
debug 1
3
debug 2
4
debug 3
5
debug 4
6
TCP Eintrag gefunden (HTTP_CLIENT)!
7
TCP-SYN-Timerout!
8
HTTP Request
9
debug 1
10
debug 2
11
debug 3
12
debug 4

von Sascha W. (sascha-w)


Rate this post
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

von Sj S. (sj1)


Rate this post
useful
not useful
ok found the problem.

at startup
1
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.
1
System Ready
2
Compiliert am Oct 12 2010 um 18:48:24
3
Compiliert mit GCC Version 4.3.2
4
5
IP   192.168.1.99
6
MASK 255.255.255.0
7
GW   192.168.1.1
8
http_get_state timer = -1
9
10
TIME: 17:52:18
11
HTTP Request
12
http_get_state timer = 0
13
http_get_state timer = 0
14
debug 1
15
debug 2
16
debug 3
17
debug 4
18
TCP Eintrag gefunden (HTTP_CLIENT)!
19
http_get_state timer = 2
20
http_get_state timer = 3
21
http_get_state timer = 4
22
http_get_state timer = 5
23
TCP-SYN-Timerout!
24
http_get_state timer = -1
25
HTTP Request
26
http_get_state timer = 0
27
debug 1
28
debug 2
29
debug 3
30
debug 4
31
TCP Eintrag gefunden (HTTP_CLIENT)!
32
http_get_state timer = 2
33
LM92_ReadTemperature
34
http_get_state timer = 3
35
http_get_state timer = 4
36
http_get_state timer = 5
37
TCP-SYN-Timerout!
38
http_get_state timer = -1
39
HTTP Request
40
http_get_state timer = 0

http_get_state is always counting and its the counter from timer.c
1
    if (http_get_state > 1)
2
    {
3
    http_get_state++;

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

von Sascha W. (sascha-w)


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

it must defined only as int !

Sascha

von Sj S. (sj1)


Rate this post
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
1
    if (!lm92_timer)
2
    {    
3
      lm92_timer = LM92_TIMER;
4
      LM92_ReadTemperature();
5
      
6
      usart_write("LM92_CurrentTemp %i %i %i %i \r\n",LM92_CurrentTemp[0],LM92_CurrentTemp[1],LM92_CurrentTemp[2],LM92_CurrentTemp[3]);
7
    }
8
9
    if (!http_request_timer)
10
    {    
11
      //usart_write("http_request_timer\r\n");
12
      http_request_timer = HTTP_GET_TIMER;
13
      insert_into_db();
14
      
15
    }

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
1
volatile char lm92_timer; (not unsigned)

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

what do you think of this solution?

von Sj S. (sj1)


Rate this post
useful
not useful
hi,

I tested for a few days now. i get notice by mail when http_get_state=-1
1
            while((index >= MAX_ARP_ENTRY) && (tcp_entry[index].app_status != 1))
2
            {
3
                index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
4
                if (tmp_counter++ > 30)
5
                {
6
                    HTTPC_DEBUG("TCP Eintrag nicht gefunden (HTTP_CLIENT)!\r\n");
7
          http_get_state = -1;
8
                    mail_enable = 1;
9
          sprintf(mail_error,"%s","no TCP");
10
          
11
          return;
12
                }
13
            }
1
        else
2
        {
3
            http_get_state = -1;
4
      mail_enable = 1;
5
      sprintf(mail_error,"%s","no arp");
6
7
        }
1
  
2
    if (http_get_state==6)
3
    {
4
      usart_write("TCP-SYN-Timerout!\r\n");  //no syn-ack within 4 secs (State from 2 to 6)
5
      http_get_state = -1;
6
      mail_enable = 1;
7
      sprintf(mail_error,"%s","No Syn");
8
    }
9
    
10
    if (http_get_state==16)
11
    {
12
      usart_write("TCP-Connection-Timeout!\r\n");  //no incomming packets within 5 secs (State from 11 to 16)
13
      http_get_state = -1;
14
      mail_enable = 1;
15
      sprintf(mail_error,"%s","TCP Time");
16
    }

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...

von Sascha W. (sascha-w)


Rate this post
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

von Sj S. (sj1)


Rate this post
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?

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

any suggestions? else i try to change 16 to 20?
1
    if(tcp_entry[index].status & FIN_FLAG)
2
  {
3
        http_get_state=-1;
4
    
5
    usart_write("HTTP Request - EOF\n\r");  
6
    usart_write("-------\r\n");
7
    return;
8
    }

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

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

von Sascha W. (sascha-w)


Rate this post
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
1
http_get_timer=1
http_get.c
1
void http_request (void)
2
{
3
    unsigned long index = MAX_TCP_ENTRY;
4
5
    if (http_get_timer=1) {
6
       http_get_timer=0
7
       //code moved from timer.c
8
    }
9
//other code from http_request

Sascha

von Sj S. (sj1)


Rate this post
useful
not useful
here's the debug:
1
HTTP Request
2
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
3
Host: www.webservicex.net
4
Connection: close
5
6
7
http_get_state timer sec 0
8
http_get_state timer sec 2
9
SQL inserted
10
HTTP Request - EOF
11
-------
12
http_get_state -1
13
http_get_state timer sec 11
14
http_get_state timer sec 12
15
http_get_state timer sec 13
16
http_get_state timer sec 14
17
LM92_CurrentTemp 0 175 0 180
18
http_get_state timer sec 15
19
TCP-Connection-Timeout!
20
http_get_state -1
21
mail_enable
22
http_get_state timer sec -1
23
http_get_state timer sec -1
24
http_get_state timer sec -1
25
http_get_state timer sec -1
26
http_get_state timer sec -1
27
http_get_state timer sec -1
28
http_get_state timer sec -1
29
http_get_state timer sec -1
30
http_get_state timer sec -1
31
LM92_CurrentTemp 0 175 0 180
32
http_get_state timer sec -1
33
http_get_state timer sec -1
34
http_get_state timer sec -1
35
http_get_state timer sec -1
36
http_get_state timer sec -1
37
http_get_state timer sec -1
38
http_get_state timer sec -1
39
http_get_state timer sec -1
40
http_get_state timer sec -1
41
http_get_state timer sec -1
42
LM92_CurrentTemp 0 175 0 180
43
http_get_state timer sec -1
44
http_get_state timer sec -1
45
http_get_state timer sec -1
46
http_get_state timer sec -1
47
http_get_state timer sec -1
48
http_get_state timer sec -1
49
http_get_state timer sec -1
50
http_get_state timer sec -1
51
http_get_state timer sec -1
52
http_get_state timer sec -1
53
LM92_CurrentTemp 0 175 0 181
54
http_get_state timer sec -1
55
http_get_state timer sec -1
56
http_get_state timer sec -1
57
http_get_state timer sec -1
58
HTTP Request
59
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
60
Host: www.webservicex.net
61
Connection: close
62
63
64
http_get_state timer sec 0
65
http_get_state timer sec 2
66
http_get_state timer sec 11
67
http_get_state timer sec 12
68
http_get_state timer sec 13
69
SQL inserted
70
HTTP Request - EOF
71
-------
72
http_get_state -1
73
http_get_state timer sec 11
74
LM92_CurrentTemp 0 175 0 180
75
http_get_state timer sec 12
76
http_get_state timer sec 13
77
http_get_state timer sec 14
78
http_get_state timer sec 15
79
TCP-Connection-Timeout!
80
http_get_state -1
81
mail_enable
82
http_get_state timer sec -1
83
http_get_state timer sec -1
84
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)?

von Sascha W. (sascha-w)


Rate this post
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 ...
1
volatile unsigned char http_get_timer;

Sascha

von FemEdireern (Guest)


Rate this post
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

von Sj S. (sj1)


Rate this post
useful
not useful
ah,

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

new code:
1
void http_request (void)
2
{
3
    unsigned long index = MAX_TCP_ENTRY;
4
    if (http_get_state == 0)
5
    {
6
7
        //offnet eine Verbindung zu meinem Webserver
8
        HTTPC_DEBUG("HTTP Request\n\r");
9
        //unsigned int my_http_cp = LOCAL_HTTP_PORT;        
10
11
//usart_write("time: %i\r\n",time);
12
13
14
    //unsigned int my_httpget_cp_new = my_http_cp + time;
15
    unsigned int my_httpget_cp_new = my_http_cp + 1;
16
    //if (my_httpget_cp_new < 2345) my_httpget_cp_new +=1000;
17
    if (my_httpget_cp_new == 5000) my_httpget_cp_new =LOCAL_HTTP_PORT;
18
19
    
20
    change_port_tcp_app (my_http_cp, my_httpget_cp_new);
21
    my_http_cp = my_httpget_cp_new;  
22
23
       //ARP Request senden
24
        if(arp_request (WEATHER_SERVER_IP))
25
        {
26
            for(unsigned long a=0;a<2000000;a++){asm("nop");};
27
28
            tcp_port_open (WEATHER_SERVER_IP,HTONS(80),HTONS(my_http_cp));
29
30
   
31
            unsigned char tmp_counter = 0;
32
33
            while((index >= MAX_ARP_ENTRY) && (tcp_entry[index].app_status != 1))
34
            {
35
                index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));
36
                if (tmp_counter++ > 30)
37
                {
38
                    HTTPC_DEBUG("TCP Eintrag nicht gefunden (HTTP_CLIENT)!\r\n");
39
          http_get_state = -1;
40
                    mail_enable = 1;
41
          sprintf(mail_error,"%s","no TCP");
42
          usart_write("http_get_state %i\n\r",http_get_state);
43
          
44
          return;
45
                }
46
            }
47
             
48
            HTTPC_DEBUG("TCP Eintrag gefunden (HTTP_CLIENT)!\r\n");
49
            tcp_entry[index].first_ack = 1;
50
            http_get_state = 2;
51
      
52
      //usart_write("tcp_entry[index].app_status %i\r\n",tcp_entry[index].app_status);
53
        }
54
        else
55
        {
56
            http_get_state = -1;
57
      mail_enable = 1;
58
      sprintf(mail_error,"%s","no arp");
59
      usart_write("http_get_state %i\n\r",http_get_state);
60
61
        }
62
    }
63
    if (http_get_state > 1)
64
    {
65
    index = tcp_entry_search (WEATHER_SERVER_IP,HTONS(80));        
66
    
67
    if ((tcp_entry[index].app_status == 1)  && (http_get_state < 10))
68
    {
69
        HTTPC_DEBUG("tcp_entry[index].app_status4 %i\r\n",tcp_entry[index].app_status);
70
        HTTPC_DEBUG("Connection etablished!\r\n");    
71
        //http_get_state = 10;
72
        HTTPC_DEBUG("\r\n\r\n\r\nDaten Anfordern\r\n");
73
        memcpy(&eth_buffer[TCP_DATA_START],buffer_string,(sizeof(buffer_string)-1));
74
        tcp_entry[index].status =  ACK_FLAG | PSH_FLAG;
75
        create_new_tcp_packet((sizeof(buffer_string)-1),index);
76
        http_get_state=10;
77
        HTTPC_DEBUG("index: %i\r\n", index);
78
    }
79
  //}
80
81
    if (http_get_timer==1) {
82
    http_get_timer=0;
83
84
    http_get_state++;
85
  
86
    if (http_get_state==6)
87
    {
88
      usart_write("TCP-SYN-Timerout!\r\n");  //no syn-ack within 4 secs (State from 2 to 6)
89
      http_get_state = -1;
90
      mail_enable = 1;
91
      sprintf(mail_error,"%s","No Syn");
92
      usart_write("http_get_state %i\n\r",http_get_state);
93
94
    }
95
    
96
    if (http_get_state==16)
97
    {
98
      usart_write("TCP-Connection-Timeout!\r\n");  //no incomming packets within 5 secs (State from 11 to 16)
99
      http_get_state = -1;
100
      mail_enable = 1;
101
      sprintf(mail_error,"%s","TCP Time");
102
      usart_write("http_get_state %i\n\r",http_get_state);
103
104
    }
105
    }
106
  }
107
}




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.
1
00  IP:000.000.000.000  PORT:0000  Time:0000
2
01  IP:000.000.000.000  PORT:0000  Time:0000
3
02  IP:192.168.002.002  PORT:0080  Time:0255
4
03  IP:192.168.002.002  PORT:0080  Time:0255
5
04  IP:000.000.000.000  PORT:0000  Time:0000


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

von #pancakeboos[OCSSSCSSSSHS] (Guest)


Rate this post
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

von Sj S. (sj1)


Rate this post
useful
not useful
ok still the same with new code
1
HTTP Request
2
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
3
Host: www.webservicex.net
4
Connection: close
5
6
7
http_get_state timer sec 0
8
http_get_state timer sec 3
9
SQL inserted
10
HTTP Request - EOF
11
-------
12
http_get_state -1
13
http_get_state timer sec 11
14
http_get_state timer sec 12
15
http_get_state timer sec 13
16
http_get_state timer sec 14
17
LM92_CurrentTemp 0 152 0 172
18
http_get_state timer sec 15
19
TCP-Connection-Timeout!
20
http_get_state -1

looks like data is still received after syn flag?

von fumpruini (Guest)


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

von Sascha W. (sascha-w)


Rate this post
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 ...
1
void test (unsigned char index)
2
{
3
char buffer[10]={0};
4
//NEW
5
  if (http_get_state < 10) return;
6
//ENDNEW
7
  for (int a = TCP_DATA_START_VAR;a < TCP_DATA_END_VAR;a++)
8
  {
9
    HTTPC_DEBUG("%c",eth_buffer[a]);
10
11
    if (eth_buffer[a] == '$') //look for #$ string
12
    {
13
      if (eth_buffer[a+1] == '#') 
14
      {  
15
        if (eth_buffer[a+2] != '1') 
16
        {  
17
          usart_write("SQL insert failed\r\n",eth_buffer[a+2]);
18
          
19
        
20
        }
21
      }
22
    }  
23
  }
24
  
25
  
26
  tcp_entry[index].time = TCP_TIME_OFF;
27
        http_get_state=11;  //reset timeout
28
    if(tcp_entry[index].status & FIN_FLAG)
29
  {
30
        http_get_state=-1;
31
    
32
    usart_write("HTTP Request - EOF\n\r");  
33
    usart_write("-------\r\n");
34
    return;
35
    }
36
  if (TCP_DATA_START_VAR == TCP_DATA_END_VAR)
37
  {
38
    return;
39
  }
40
  
41
  
42
    //else ////changed to else
43
  //{ 
44
    tcp_entry[index].status = ACK_FLAG;
45
    create_new_tcp_packet(0,index);
46
  //}
47
48
}
...  to break receive before connection opend or after connection 
closed.

Sascha

von Sj S. (sj1)


Rate this post
useful
not useful
when adding this line it failures at start
1
lm92_timer 2, http_request_timer 2
2
http_get_state timer sec -1
3
lm92_timer 1, http_request_timer 1
4
http_get_state timer sec -1
5
lm92_timer 0, http_request_timer 0
6
LM92_CurrentTemp 0 161 0 175
7
HTTP Request
8
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
9
Host: www.webservicex.net
10
Connection: close
11
12
13
http_get_state timer sec 0
14
lm92_timer 9, http_request_timer 39
15
http_get_state timer sec 0
16
lm92_timer 8, http_request_timer 38
17
http_get_state timer sec 3
18
lm92_timer 7, http_request_timer 37
19
http_get_state timer sec 4
20
lm92_timer 6, http_request_timer 36
21
http_get_state timer sec 5
22
lm92_timer 5, http_request_timer 35
23
TCP-SYN-Timerout!
24
http_get_state -1
25
mail_enable
26
Send E-Mail (Sie haben Post ;-)


think because it dont reaches the fin flag anymore

von Sj S. (sj1)


Rate this post
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?
1
No.     Time        Source                Destination           Protocol Info
2
    462 1839.979898 192.168.1.99         192.168.2.2          TCP      rprt > http [SYN] Seq=0 Win=1100 Len=0 MSS=1100
3
    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
4
    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
5
    465 1844.957153 192.168.1.99         192.168.2.2          TCP      rprt > http [ACK] Seq=1 Ack=1 Win=1100 Len=0
6
    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
7
    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
8
    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
9
    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
10
    470 1879.979129 192.168.1.99         192.168.2.2          TCP      slinterbase > http [SYN] Seq=0 Win=1100 Len=0 MSS=1100
11
    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
12
    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
13
    473 1879.998215 192.168.2.2          192.168.1.99         TCP      http > rprt [ACK] Seq=1 Ack=230 Win=6432 Len=0
14
    474 1880.006826 192.168.2.2          192.168.1.99         HTTP     HTTP/1.1 200 OK  (text/html)
15
    475 1880.007024 192.168.2.2          192.168.1.99         TCP      http > rprt [FIN, ACK] Seq=201 Ack=230 Win=6432 Len=0
16
    476 1883.007089 192.168.2.2          192.168.1.99         HTTP     [TCP Retransmission] HTTP/1.1 200 OK  (text/html)
17
    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
18
    478 1889.005637 192.168.2.2          192.168.1.99         HTTP     [TCP Retransmission] HTTP/1.1 200 OK  (text/html)
19
    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
20
    480 1901.003775 192.168.2.2          192.168.1.99         HTTP     [TCP Retransmission] HTTP/1.1 200 OK  (text/html)
21
    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
22
    482 1901.170162 192.168.1.99         192.168.2.2          TCP      slinterbase > http [RST] Seq=1 Win=0 Len=0

von Sj S. (sj1)


Rate this post
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...

von Sascha W. (sascha-w)


Rate this post
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

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.