TCP connection to fixe IP

View: New views
10 Messages — Rating Filter:   Alert me  

TCP connection to fixe IP

by Gilles-27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 

Hi all,

I have developed a piece of code to establish a dialog between my ARM9 board
and a PC in 2 different location.(2 different IP fix addresses)

 

When the PC establish the TCP link ,  the ARM9 receive and respond to the
TCP frame correctly.

 

If I try to establish the TCP dialog starting from the ARM9, it fails on the
NutTcpConnect(sock1,dest_addr, PortSend)

 

All is good if I stay inside my office network.

 

Mask and IPgate seems correct.

 

Is anybody has an idea about my trouble?

 

Thanks for the help

Best regards

Gilles

 

_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: TCP connection to fixe IP

by Ole Reinhardt-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Gilles,

> I have developed a piece of code to establish a dialog between my ARM9 board
> and a PC in 2 different location.(2 different IP fix addresses)
> When the PC establish the TCP link ,  the ARM9 receive and respond to the
> TCP frame correctly.
> If I try to establish the TCP dialog starting from the ARM9, it fails on the
> NutTcpConnect(sock1,dest_addr, PortSend)
> All is good if I stay inside my office network.

Are you sure there is neither a masquerading (NAT) nor any other kind of
firewall between the pc and your board? Have you correctly set your
gateways on both entities?

Have you checked the error code after the failed connect with
NutTcpError()? It might give you a hint what is going wrong.

Regards,

Ole Reinhardt

--
 _____________________________________________________________
|                                                             |
| Embedded-IT                                                 |
|                                                             |
| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
| 57076 Siegen         eMail:    ole.reinhardt@... |
| Germany              Web:         http://www.embedded-it.de |
|_____________________________________________________________|

_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: TCP connection to fixe IP

by Gilles-27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bonjour Ole,

1) As I said in my previous Email, the code works correctly in a local
network BUT with respect of the IP range.
Example:
 
GOOD: device IP = 192.168.0.1     and   gateway IP = 192.168.0.254

NOT GOOD : device IP = 192.168.1.1     and   gateway IP = 192.168.0.254

In that case, the gateway IP is force to 0.0.0.0 by NutOS

How can I bypass the 0.0.0.0 change ?

2) I have redo some test between my ARM9 and a distant PC to be able to give
you more details about this type of connection. Actually, the error received
is : Time out
Firewall have check and seems correct.
No TCPIP message can be send out to an external IP

Best regards
Gilles

-----Original Message-----
From: Ole Reinhardt [mailto:ole.reinhardt@...]
Sent: lundi 5 octobre 2009 09:55
To: gilles@...; Ethernut User Chat (English)
Subject: Re: [En-Nut-Discussion] TCP connection to fixe IP

Hi Gilles,

> I have developed a piece of code to establish a dialog between my ARM9
board
> and a PC in 2 different location.(2 different IP fix addresses)
> When the PC establish the TCP link ,  the ARM9 receive and respond to the
> TCP frame correctly.
> If I try to establish the TCP dialog starting from the ARM9, it fails on
the
> NutTcpConnect(sock1,dest_addr, PortSend)
> All is good if I stay inside my office network.

Are you sure there is neither a masquerading (NAT) nor any other kind of
firewall between the pc and your board? Have you correctly set your
gateways on both entities?

Have you checked the error code after the failed connect with
NutTcpError()? It might give you a hint what is going wrong.

Regards,

Ole Reinhardt

--
 _____________________________________________________________
|                                                             |
| Embedded-IT                                                 |
|                                                             |
| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
| 57076 Siegen         eMail:    ole.reinhardt@... |
| Germany              Web:         http://www.embedded-it.de |
|_____________________________________________________________|


_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: TCP connection to fixe IP

by EnNut :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

   Gilles,
   I see multiple problems.
1.) You will only have connectivity between
192.168.xxx.yyy addresses on a local network
because these are local IP addresses.
They will not go out of the local network onto
the internet with these 192.168 based addresses.
Your router will convert these 192.168 based IP addresses
to an IP Address and port number that is actually
accessible from the internet. The router won't
even try to convert a destination address
starting with 192.168 to an internet address.

2.) Assuming the subnet mask is 255.255.255.0, your "not good" example shows a
device IP of 192.168.1.1 with a gateway of
192.168.0.254. These are not compatible.

To communicate with a distant PC, one of the
devices need to have a fixed IP Address that is not a local address.
The other unit then must connect to the PC with the fixed IP Address.

   Zack



At 05:12 PM 10/12/2009, you wrote:

>Bonjour Ole,
>
>1) As I said in my previous Email, the code works correctly in a local
>network BUT with respect of the IP range.
>Example:
>
>GOOD: device IP = 192.168.0.1     and   gateway IP = 192.168.0.254
>
>NOT GOOD : device IP = 192.168.1.1     and   gateway IP = 192.168.0.254
>
>In that case, the gateway IP is force to 0.0.0.0 by NutOS
>
>How can I bypass the 0.0.0.0 change ?
>
>2) I have redo some test between my ARM9 and a distant PC to be able to give
>you more details about this type of connection. Actually, the error received
>is : Time out
>Firewall have check and seems correct.
>No TCPIP message can be send out to an external IP
>
>Best regards
>Gilles
>
>-----Original Message-----
>From: Ole Reinhardt [mailto:ole.reinhardt@...]
>Sent: lundi 5 octobre 2009 09:55
>To: gilles@...; Ethernut User Chat (English)
>Subject: Re: [En-Nut-Discussion] TCP connection to fixe IP
>
>Hi Gilles,
>
> > I have developed a piece of code to establish a dialog between my ARM9
>board
> > and a PC in 2 different location.(2 different IP fix addresses)
> > When the PC establish the TCP link ,  the ARM9 receive and respond to the
> > TCP frame correctly.
> > If I try to establish the TCP dialog starting from the ARM9, it fails on
>the
> > NutTcpConnect(sock1,dest_addr, PortSend)
> > All is good if I stay inside my office network.
>
>Are you sure there is neither a masquerading (NAT) nor any other kind of
>firewall between the pc and your board? Have you correctly set your
>gateways on both entities?
>
>Have you checked the error code after the failed connect with
>NutTcpError()? It might give you a hint what is going wrong.
>
>Regards,
>
>Ole Reinhardt
>
>--
>  _____________________________________________________________
>|                                                             |
>| Embedded-IT                                                 |
>|                                                             |
>| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
>| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
>| 57076 Siegen         eMail:    ole.reinhardt@... |
>| Germany              Web:         http://www.embedded-it.de |
>|_____________________________________________________________|
>
>
>_______________________________________________
>http://lists.egnite.de/mailman/listinfo/en-nut-discussion

_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: TCP connection to fixe IP

by Gilles-27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Zack,
I agree on the local addresses compatibilities.
But for distant PC, I don't understand why it does not work.

The code is :

TCPSOCKET *sock1;
    FILE *stream1;

            if ((sock1 = NutTcpCreateSocket()) != 0)
            {
            if (NutTcpConnect(sock1,dest_addr, PortSend) == 0)
            {
                    if ((stream1 = _fdopen((int) sock1, "r+b")) != 0)
                    {
                        fwrite(buff,1,i,stream1);
                        fclose(stream1);
            }
              else
            {
            puts("Assigning a
stream failed");
            }
            }
            else
            {
                  int errorTCP;
                  errorTCP = NutTcpError(sock1);
                  printf("failed: 0x%x",errorTCP);
            }
           
          NutTcpCloseSocket(sock1);
          }

Init Values are :
PortSend = 5001;
Dest_addr = 82.xx.yy.zz
bridge are OK is both directions on port 5001&5002

This code work in local network.
I assume that it will work also to distant IP
So the faulty code is maybe in the initialisation of my IP stuff.

Void InitEthernetDevice(void);
{
 
    if (NutRegisterDevice(&DEV_ETHER, 0 , 0))
    {
        puts("No Ethernet Device");
        return -1;
    }

    printf("\nConfigure %s...", DEV_ETHER_NAME);
   
    NutNetLoadConfig("eth0");
   

    NutNetIfConfig(DEV_ETHER_NAME, confnet.cdn_mac, confnet.cdn_cip_addr,
confnet.cdn_ip_mask);
   

    if(confnet.cdn_gateway)
    {
        printf("\nAdd Gateway...");
        NutIpRouteAdd(0,0, confnet.cdn_gateway, &DEV_ETHER);
    }
    puts("\nOK");

    return 0;
}

The complete initialisation code is :

    InitEthernetDevice();
    printf("Start Responder...");
    if (NutRegisterDiscovery((u_long)-1, 0, DISF_INITAL_ANN)) {
        puts("failed");
    }
    else {
        puts("OK");
    }


Any idea where to looking for?
Gilles


-----Original Message-----
From: ennut@... [mailto:ennut@...]
Sent: lundi 12 octobre 2009 23:48
To: gilles@...; Ethernut User Chat (English)
Subject: Re: [En-Nut-Discussion] TCP connection to fixe IP

   Gilles,
   I see multiple problems.
1.) You will only have connectivity between
192.168.xxx.yyy addresses on a local network
because these are local IP addresses.
They will not go out of the local network onto
the internet with these 192.168 based addresses.
Your router will convert these 192.168 based IP addresses
to an IP Address and port number that is actually
accessible from the internet. The router won't
even try to convert a destination address
starting with 192.168 to an internet address.

2.) Assuming the subnet mask is 255.255.255.0, your "not good" example shows
a
device IP of 192.168.1.1 with a gateway of
192.168.0.254. These are not compatible.

To communicate with a distant PC, one of the
devices need to have a fixed IP Address that is not a local address.
The other unit then must connect to the PC with the fixed IP Address.

   Zack



At 05:12 PM 10/12/2009, you wrote:

>Bonjour Ole,
>
>1) As I said in my previous Email, the code works correctly in a local
>network BUT with respect of the IP range.
>Example:
>
>GOOD: device IP = 192.168.0.1     and   gateway IP = 192.168.0.254
>
>NOT GOOD : device IP = 192.168.1.1     and   gateway IP = 192.168.0.254
>
>In that case, the gateway IP is force to 0.0.0.0 by NutOS
>
>How can I bypass the 0.0.0.0 change ?
>
>2) I have redo some test between my ARM9 and a distant PC to be able to
give
>you more details about this type of connection. Actually, the error
received

>is : Time out
>Firewall have check and seems correct.
>No TCPIP message can be send out to an external IP
>
>Best regards
>Gilles
>
>-----Original Message-----
>From: Ole Reinhardt [mailto:ole.reinhardt@...]
>Sent: lundi 5 octobre 2009 09:55
>To: gilles@...; Ethernut User Chat (English)
>Subject: Re: [En-Nut-Discussion] TCP connection to fixe IP
>
>Hi Gilles,
>
> > I have developed a piece of code to establish a dialog between my ARM9
>board
> > and a PC in 2 different location.(2 different IP fix addresses)
> > When the PC establish the TCP link ,  the ARM9 receive and respond to
the

> > TCP frame correctly.
> > If I try to establish the TCP dialog starting from the ARM9, it fails on
>the
> > NutTcpConnect(sock1,dest_addr, PortSend)
> > All is good if I stay inside my office network.
>
>Are you sure there is neither a masquerading (NAT) nor any other kind of
>firewall between the pc and your board? Have you correctly set your
>gateways on both entities?
>
>Have you checked the error code after the failed connect with
>NutTcpError()? It might give you a hint what is going wrong.
>
>Regards,
>
>Ole Reinhardt
>
>--
>  _____________________________________________________________
>|                                                             |
>| Embedded-IT                                                 |
>|                                                             |
>| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
>| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
>| 57076 Siegen         eMail:    ole.reinhardt@... |
>| Germany              Web:         http://www.embedded-it.de |
>|_____________________________________________________________|
>
>
>_______________________________________________
>http://lists.egnite.de/mailman/listinfo/en-nut-discussion


_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: TCP connection to fixe IP

by EnNut :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

   Gilles,
   I'm a little confused where the 82.xx.yy.zz IP
Address is coming from. It was not mentioned earlier.

If you bring up a command prompt window on the distant PC and type
ipconfig
then hit the "Enter" key,

What is displayed for all instances of:
IP Address
Subnet Mask and
Default Gateway?


If communication is to work, that distant PC had
better have an IP Address starting with 82.
If all of the addresses start with 192. then the
distant PC is behind a router and
unable to be accessed directly from the internet.

Let me know what you find.


There is something else to try. Can you ping the
distant PC from a PC on the local network?
 From a command prompt window on the local PC type:
ping 82.xx.yy.zz
then hit the "Enter" key.

If the ping request times out from the local PC
then there is no way your ARM9 board will be able to talk to the distant PC.


   Regards!
     Zack




At 08:31 PM 10/12/2009, Gilles wrote:

>Zack,
>I agree on the local addresses compatibilities.
>But for distant PC, I don't understand why it does not work.
>
>The code is :
>
>TCPSOCKET *sock1;
>     FILE *stream1;
>
>             if ((sock1 = NutTcpCreateSocket()) != 0)
>             {
>                    if (NutTcpConnect(sock1,dest_addr, PortSend) == 0)
>                    {
>                     if ((stream1 = _fdopen((int) sock1, "r+b")) != 0)
>                                         {
>                                         fwrite(buff,1,i,stream1);
>                                         fclose(stream1);
>                                                 }
>                            else
>                                                 {
>                                                         puts("Assigning a
>stream failed");
>                                                 }
>                         }
>                         else
>                         {
>                   int errorTCP;
>                   errorTCP = NutTcpError(sock1);
>                   printf("failed: 0x%x",errorTCP);
>                    }
>
>                    NutTcpCloseSocket(sock1);
>                 }
>
>Init Values are :
>PortSend = 5001;
>Dest_addr = 82.xx.yy.zz
>bridge are OK is both directions on port 5001&5002
>
>This code work in local network.
>I assume that it will work also to distant IP
>So the faulty code is maybe in the initialisation of my IP stuff.
>
>Void InitEthernetDevice(void);
>{
>
>     if (NutRegisterDevice(&DEV_ETHER, 0 , 0))
>     {
>         puts("No Ethernet Device");
>         return -1;
>     }
>
>     printf("\nConfigure %s...", DEV_ETHER_NAME);
>
>     NutNetLoadConfig("eth0");
>
>
>     NutNetIfConfig(DEV_ETHER_NAME, confnet.cdn_mac, confnet.cdn_cip_addr,
>confnet.cdn_ip_mask);
>
>
>     if(confnet.cdn_gateway)
>         {
>         printf("\nAdd Gateway...");
>         NutIpRouteAdd(0,0, confnet.cdn_gateway, &DEV_ETHER);
>         }
>     puts("\nOK");
>
>     return 0;
>}
>
>The complete initialisation code is :
>
>     InitEthernetDevice();
>     printf("Start Responder...");
>     if (NutRegisterDiscovery((u_long)-1, 0, DISF_INITAL_ANN)) {
>         puts("failed");
>     }
>     else {
>         puts("OK");
>     }
>
>
>Any idea where to looking for?
>Gilles
>
>
>-----Original Message-----
>From: ennut@... [mailto:ennut@...]
>Sent: lundi 12 octobre 2009 23:48
>To: gilles@...; Ethernut User Chat (English)
>Subject: Re: [En-Nut-Discussion] TCP connection to fixe IP
>
>    Gilles,
>    I see multiple problems.
>1.) You will only have connectivity between
>192.168.xxx.yyy addresses on a local network
>because these are local IP addresses.
>They will not go out of the local network onto
>the internet with these 192.168 based addresses.
>Your router will convert these 192.168 based IP addresses
>to an IP Address and port number that is actually
>accessible from the internet. The router won't
>even try to convert a destination address
>starting with 192.168 to an internet address.
>
>2.) Assuming the subnet mask is 255.255.255.0, your "not good" example shows
>a
>device IP of 192.168.1.1 with a gateway of
>192.168.0.254. These are not compatible.
>
>To communicate with a distant PC, one of the
>devices need to have a fixed IP Address that is not a local address.
>The other unit then must connect to the PC with the fixed IP Address.
>
>    Zack
>
>
>
>At 05:12 PM 10/12/2009, you wrote:
> >Bonjour Ole,
> >
> >1) As I said in my previous Email, the code works correctly in a local
> >network BUT with respect of the IP range.
> >Example:
> >
> >GOOD: device IP = 192.168.0.1     and   gateway IP = 192.168.0.254
> >
> >NOT GOOD : device IP = 192.168.1.1     and   gateway IP = 192.168.0.254
> >
> >In that case, the gateway IP is force to 0.0.0.0 by NutOS
> >
> >How can I bypass the 0.0.0.0 change ?
> >
> >2) I have redo some test between my ARM9 and a distant PC to be able to
>give
> >you more details about this type of connection. Actually, the error
>received
> >is : Time out
> >Firewall have check and seems correct.
> >No TCPIP message can be send out to an external IP
> >
> >Best regards
> >Gilles
> >
> >-----Original Message-----
> >From: Ole Reinhardt [mailto:ole.reinhardt@...]
> >Sent: lundi 5 octobre 2009 09:55
> >To: gilles@...; Ethernut User Chat (English)
> >Subject: Re: [En-Nut-Discussion] TCP connection to fixe IP
> >
> >Hi Gilles,
> >
> > > I have developed a piece of code to establish a dialog between my ARM9
> >board
> > > and a PC in 2 different location.(2 different IP fix addresses)
> > > When the PC establish the TCP link ,  the ARM9 receive and respond to
>the
> > > TCP frame correctly.
> > > If I try to establish the TCP dialog starting from the ARM9, it fails on
> >the
> > > NutTcpConnect(sock1,dest_addr, PortSend)
> > > All is good if I stay inside my office network.
> >
> >Are you sure there is neither a masquerading (NAT) nor any other kind of
> >firewall between the pc and your board? Have you correctly set your
> >gateways on both entities?
> >
> >Have you checked the error code after the failed connect with
> >NutTcpError()? It might give you a hint what is going wrong.
> >
> >Regards,
> >
> >Ole Reinhardt
> >
> >--
> >  _____________________________________________________________
> >|                                                             |
> >| Embedded-IT                                                 |
> >|                                                             |
> >| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
> >| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
> >| 57076 Siegen         eMail:    ole.reinhardt@... |
> >| Germany              Web:         http://www.embedded-it.de |
> >|_____________________________________________________________|
> >
> >
> >_______________________________________________
> >http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>
>_______________________________________________
>http://lists.egnite.de/mailman/listinfo/en-nut-discussion

_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: TCP connection to fixe IP

by Gilles-27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry to confuse you but I have difficulties to explain exactly my problem.

I send TCPIP frame to a distant PC.

I use the code sent in my last email.

The code work perfectly if the PC is in my local network.

The code fail is I try to send to a distant PC.

The PC is connect through a bridge that redirect fix IP to remote network.
        -Fix IP is : 82.xxx.yyy.zzz
        -remote network is : 192.168.1.23 (example)
        -port is: 5001
The bridge is configured to manage redirection between Fix IP et remote PC
IP.

My code try to send TCPIP frame from my ARM9 board to the distant PC.

I hope this is clear for you now.
Any idea?
Gilles

 


-----Original Message-----
From: ennut@... [mailto:ennut@...]
Sent: mardi 13 octobre 2009 16:51
To: gilles@...; Ethernut User Chat (English); 'Ethernut User Chat
(English)'
Subject: Re: [En-Nut-Discussion] TCP connection to fixe IP

   Gilles,
   I'm a little confused where the 82.xx.yy.zz IP
Address is coming from. It was not mentioned earlier.

If you bring up a command prompt window on the distant PC and type
ipconfig
then hit the "Enter" key,

What is displayed for all instances of:
IP Address
Subnet Mask and
Default Gateway?


If communication is to work, that distant PC had
better have an IP Address starting with 82.
If all of the addresses start with 192. then the
distant PC is behind a router and
unable to be accessed directly from the internet.

Let me know what you find.


There is something else to try. Can you ping the
distant PC from a PC on the local network?
 From a command prompt window on the local PC type:
ping 82.xx.yy.zz
then hit the "Enter" key.

If the ping request times out from the local PC
then there is no way your ARM9 board will be able to talk to the distant PC.


   Regards!
     Zack




At 08:31 PM 10/12/2009, Gilles wrote:

>Zack,
>I agree on the local addresses compatibilities.
>But for distant PC, I don't understand why it does not work.
>
>The code is :
>
>TCPSOCKET *sock1;
>     FILE *stream1;
>
>             if ((sock1 = NutTcpCreateSocket()) != 0)
>             {
>                    if (NutTcpConnect(sock1,dest_addr, PortSend) == 0)
>                    {
>                     if ((stream1 = _fdopen((int) sock1, "r+b")) != 0)
>                                         {
>                                         fwrite(buff,1,i,stream1);
>                                         fclose(stream1);
>                                                 }
>                            else
>                                                 {
>                                                         puts("Assigning a
>stream failed");
>                                                 }
>                         }
>                         else
>                         {
>                   int errorTCP;
>                   errorTCP = NutTcpError(sock1);
>                   printf("failed: 0x%x",errorTCP);
>                    }
>
>                    NutTcpCloseSocket(sock1);
>                 }
>
>Init Values are :
>PortSend = 5001;
>Dest_addr = 82.xx.yy.zz
>bridge are OK is both directions on port 5001&5002
>
>This code work in local network.
>I assume that it will work also to distant IP
>So the faulty code is maybe in the initialisation of my IP stuff.
>
>Void InitEthernetDevice(void);
>{
>
>     if (NutRegisterDevice(&DEV_ETHER, 0 , 0))
>     {
>         puts("No Ethernet Device");
>         return -1;
>     }
>
>     printf("\nConfigure %s...", DEV_ETHER_NAME);
>
>     NutNetLoadConfig("eth0");
>
>
>     NutNetIfConfig(DEV_ETHER_NAME, confnet.cdn_mac, confnet.cdn_cip_addr,
>confnet.cdn_ip_mask);
>
>
>     if(confnet.cdn_gateway)
>         {
>         printf("\nAdd Gateway...");
>         NutIpRouteAdd(0,0, confnet.cdn_gateway, &DEV_ETHER);
>         }
>     puts("\nOK");
>
>     return 0;
>}
>
>The complete initialisation code is :
>
>     InitEthernetDevice();
>     printf("Start Responder...");
>     if (NutRegisterDiscovery((u_long)-1, 0, DISF_INITAL_ANN)) {
>         puts("failed");
>     }
>     else {
>         puts("OK");
>     }
>
>
>Any idea where to looking for?
>Gilles
>
>
>-----Original Message-----
>From: ennut@... [mailto:ennut@...]
>Sent: lundi 12 octobre 2009 23:48
>To: gilles@...; Ethernut User Chat (English)
>Subject: Re: [En-Nut-Discussion] TCP connection to fixe IP
>
>    Gilles,
>    I see multiple problems.
>1.) You will only have connectivity between
>192.168.xxx.yyy addresses on a local network
>because these are local IP addresses.
>They will not go out of the local network onto
>the internet with these 192.168 based addresses.
>Your router will convert these 192.168 based IP addresses
>to an IP Address and port number that is actually
>accessible from the internet. The router won't
>even try to convert a destination address
>starting with 192.168 to an internet address.
>
>2.) Assuming the subnet mask is 255.255.255.0, your "not good" example
shows

>a
>device IP of 192.168.1.1 with a gateway of
>192.168.0.254. These are not compatible.
>
>To communicate with a distant PC, one of the
>devices need to have a fixed IP Address that is not a local address.
>The other unit then must connect to the PC with the fixed IP Address.
>
>    Zack
>
>
>
>At 05:12 PM 10/12/2009, you wrote:
> >Bonjour Ole,
> >
> >1) As I said in my previous Email, the code works correctly in a local
> >network BUT with respect of the IP range.
> >Example:
> >
> >GOOD: device IP = 192.168.0.1     and   gateway IP = 192.168.0.254
> >
> >NOT GOOD : device IP = 192.168.1.1     and   gateway IP = 192.168.0.254
> >
> >In that case, the gateway IP is force to 0.0.0.0 by NutOS
> >
> >How can I bypass the 0.0.0.0 change ?
> >
> >2) I have redo some test between my ARM9 and a distant PC to be able to
>give
> >you more details about this type of connection. Actually, the error
>received
> >is : Time out
> >Firewall have check and seems correct.
> >No TCPIP message can be send out to an external IP
> >
> >Best regards
> >Gilles
> >
> >-----Original Message-----
> >From: Ole Reinhardt [mailto:ole.reinhardt@...]
> >Sent: lundi 5 octobre 2009 09:55
> >To: gilles@...; Ethernut User Chat (English)
> >Subject: Re: [En-Nut-Discussion] TCP connection to fixe IP
> >
> >Hi Gilles,
> >
> > > I have developed a piece of code to establish a dialog between my ARM9
> >board
> > > and a PC in 2 different location.(2 different IP fix addresses)
> > > When the PC establish the TCP link ,  the ARM9 receive and respond to
>the
> > > TCP frame correctly.
> > > If I try to establish the TCP dialog starting from the ARM9, it fails
on

> >the
> > > NutTcpConnect(sock1,dest_addr, PortSend)
> > > All is good if I stay inside my office network.
> >
> >Are you sure there is neither a masquerading (NAT) nor any other kind of
> >firewall between the pc and your board? Have you correctly set your
> >gateways on both entities?
> >
> >Have you checked the error code after the failed connect with
> >NutTcpError()? It might give you a hint what is going wrong.
> >
> >Regards,
> >
> >Ole Reinhardt
> >
> >--
> >  _____________________________________________________________
> >|                                                             |
> >| Embedded-IT                                                 |
> >|                                                             |
> >| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
> >| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
> >| 57076 Siegen         eMail:    ole.reinhardt@... |
> >| Germany              Web:         http://www.embedded-it.de |
> >|_____________________________________________________________|
> >
> >
> >_______________________________________________
> >http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>
>_______________________________________________
>http://lists.egnite.de/mailman/listinfo/en-nut-discussion


_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: TCP connection to fixe IP

by EnNut :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

   Gilles,
   Have you performed the ping test I requested?
   If the ping test doesn't work then the bridge
is probably not configured properly.
What is the make and model of the bridge?

   Thanks!
     Zack


At 04:05 AM 10/14/2009, Gilles wrote:

>Sorry to confuse you but I have difficulties to explain exactly my problem.
>
>I send TCPIP frame to a distant PC.
>
>I use the code sent in my last email.
>
>The code work perfectly if the PC is in my local network.
>
>The code fail is I try to send to a distant PC.
>
>The PC is connect through a bridge that redirect fix IP to remote network.
>         -Fix IP is : 82.xxx.yyy.zzz
>         -remote network is : 192.168.1.23 (example)
>         -port is: 5001
>The bridge is configured to manage redirection between Fix IP et remote PC
>IP.
>
>My code try to send TCPIP frame from my ARM9 board to the distant PC.
>
>I hope this is clear for you now.
>Any idea?
>Gilles
>
>
>
>
>-----Original Message-----
>From: ennut@... [mailto:ennut@...]
>Sent: mardi 13 octobre 2009 16:51
>To: gilles@...; Ethernut User Chat (English); 'Ethernut User Chat
>(English)'
>Subject: Re: [En-Nut-Discussion] TCP connection to fixe IP
>
>    Gilles,
>    I'm a little confused where the 82.xx.yy.zz IP
>Address is coming from. It was not mentioned earlier.
>
>If you bring up a command prompt window on the distant PC and type
>ipconfig
>then hit the "Enter" key,
>
>What is displayed for all instances of:
>IP Address
>Subnet Mask and
>Default Gateway?
>
>
>If communication is to work, that distant PC had
>better have an IP Address starting with 82.
>If all of the addresses start with 192. then the
>distant PC is behind a router and
>unable to be accessed directly from the internet.
>
>Let me know what you find.
>
>
>There is something else to try. Can you ping the
>distant PC from a PC on the local network?
>  From a command prompt window on the local PC type:
>ping 82.xx.yy.zz
>then hit the "Enter" key.
>
>If the ping request times out from the local PC
>then there is no way your ARM9 board will be able to talk to the distant PC.
>
>
>    Regards!
>      Zack
>
>
>
>
>At 08:31 PM 10/12/2009, Gilles wrote:
> >Zack,
> >I agree on the local addresses compatibilities.
> >But for distant PC, I don't understand why it does not work.
> >
> >The code is :
> >
> >TCPSOCKET *sock1;
> >     FILE *stream1;
> >
> >             if ((sock1 = NutTcpCreateSocket()) != 0)
> >             {
> >                    if (NutTcpConnect(sock1,dest_addr, PortSend) == 0)
> >                    {
> >                     if ((stream1 = _fdopen((int) sock1, "r+b")) != 0)
> >                                         {
> >                                         fwrite(buff,1,i,stream1);
> >                                         fclose(stream1);
> >                                                 }
> >                            else
> >                                                 {
> >                                                         puts("Assigning a
> >stream failed");
> >                                                 }
> >                         }
> >                         else
> >                         {
> >                   int errorTCP;
> >                   errorTCP = NutTcpError(sock1);
> >                   printf("failed: 0x%x",errorTCP);
> >                    }
> >
> >                    NutTcpCloseSocket(sock1);
> >                 }
> >
> >Init Values are :
> >PortSend = 5001;
> >Dest_addr = 82.xx.yy.zz
> >bridge are OK is both directions on port 5001&5002
> >
> >This code work in local network.
> >I assume that it will work also to distant IP
> >So the faulty code is maybe in the initialisation of my IP stuff.
> >
> >Void InitEthernetDevice(void);
> >{
> >
> >     if (NutRegisterDevice(&DEV_ETHER, 0 , 0))
> >     {
> >         puts("No Ethernet Device");
> >         return -1;
> >     }
> >
> >     printf("\nConfigure %s...", DEV_ETHER_NAME);
> >
> >     NutNetLoadConfig("eth0");
> >
> >
> >     NutNetIfConfig(DEV_ETHER_NAME, confnet.cdn_mac, confnet.cdn_cip_addr,
> >confnet.cdn_ip_mask);
> >
> >
> >     if(confnet.cdn_gateway)
> >         {
> >         printf("\nAdd Gateway...");
> >         NutIpRouteAdd(0,0, confnet.cdn_gateway, &DEV_ETHER);
> >         }
> >     puts("\nOK");
> >
> >     return 0;
> >}
> >
> >The complete initialisation code is :
> >
> >     InitEthernetDevice();
> >     printf("Start Responder...");
> >     if (NutRegisterDiscovery((u_long)-1, 0, DISF_INITAL_ANN)) {
> >         puts("failed");
> >     }
> >     else {
> >         puts("OK");
> >     }
> >
> >
> >Any idea where to looking for?
> >Gilles
> >
> >
> >-----Original Message-----
> >From: ennut@... [mailto:ennut@...]
> >Sent: lundi 12 octobre 2009 23:48
> >To: gilles@...; Ethernut User Chat (English)
> >Subject: Re: [En-Nut-Discussion] TCP connection to fixe IP
> >
> >    Gilles,
> >    I see multiple problems.
> >1.) You will only have connectivity between
> >192.168.xxx.yyy addresses on a local network
> >because these are local IP addresses.
> >They will not go out of the local network onto
> >the internet with these 192.168 based addresses.
> >Your router will convert these 192.168 based IP addresses
> >to an IP Address and port number that is actually
> >accessible from the internet. The router won't
> >even try to convert a destination address
> >starting with 192.168 to an internet address.
> >
> >2.) Assuming the subnet mask is 255.255.255.0, your "not good" example
>shows
> >a
> >device IP of 192.168.1.1 with a gateway of
> >192.168.0.254. These are not compatible.
> >
> >To communicate with a distant PC, one of the
> >devices need to have a fixed IP Address that is not a local address.
> >The other unit then must connect to the PC with the fixed IP Address.
> >
> >    Zack
> >
> >
> >
> >At 05:12 PM 10/12/2009, you wrote:
> > >Bonjour Ole,
> > >
> > >1) As I said in my previous Email, the code works correctly in a local
> > >network BUT with respect of the IP range.
> > >Example:
> > >
> > >GOOD: device IP = 192.168.0.1     and   gateway IP = 192.168.0.254
> > >
> > >NOT GOOD : device IP = 192.168.1.1     and   gateway IP = 192.168.0.254
> > >
> > >In that case, the gateway IP is force to 0.0.0.0 by NutOS
> > >
> > >How can I bypass the 0.0.0.0 change ?
> > >
> > >2) I have redo some test between my ARM9 and a distant PC to be able to
> >give
> > >you more details about this type of connection. Actually, the error
> >received
> > >is : Time out
> > >Firewall have check and seems correct.
> > >No TCPIP message can be send out to an external IP
> > >
> > >Best regards
> > >Gilles
> > >
> > >-----Original Message-----
> > >From: Ole Reinhardt [mailto:ole.reinhardt@...]
> > >Sent: lundi 5 octobre 2009 09:55
> > >To: gilles@...; Ethernut User Chat (English)
> > >Subject: Re: [En-Nut-Discussion] TCP connection to fixe IP
> > >
> > >Hi Gilles,
> > >
> > > > I have developed a piece of code to establish a dialog between my ARM9
> > >board
> > > > and a PC in 2 different location.(2 different IP fix addresses)
> > > > When the PC establish the TCP link ,  the ARM9 receive and respond to
> >the
> > > > TCP frame correctly.
> > > > If I try to establish the TCP dialog starting from the ARM9, it fails
>on
> > >the
> > > > NutTcpConnect(sock1,dest_addr, PortSend)
> > > > All is good if I stay inside my office network.
> > >
> > >Are you sure there is neither a masquerading (NAT) nor any other kind of
> > >firewall between the pc and your board? Have you correctly set your
> > >gateways on both entities?
> > >
> > >Have you checked the error code after the failed connect with
> > >NutTcpError()? It might give you a hint what is going wrong.
> > >
> > >Regards,
> > >
> > >Ole Reinhardt
> > >
> > >--
> > >  _____________________________________________________________
> > >|                                                             |
> > >| Embedded-IT                                                 |
> > >|                                                             |
> > >| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
> > >| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
> > >| 57076 Siegen         eMail:    ole.reinhardt@... |
> > >| Germany              Web:         http://www.embedded-it.de |
> > >|_____________________________________________________________|
> > >
> > >
> > >_______________________________________________
> > >http://lists.egnite.de/mailman/listinfo/en-nut-discussion
> >
> >
> >_______________________________________________
> >http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>
>_______________________________________________
>http://lists.egnite.de/mailman/listinfo/en-nut-discussion

_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: TCP connection to fixe IP

by uprinz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Gilles,

I am not a moderator, but I have to interrupt because some clarification
is needed.

Please specify the _complete_ configuration of the networks and devices.
Otherwise no one can help.

A device on a network has 3 parameters not two, a Router has more.

So to understand your problem we need:
EtherNut IP
EtherNut Netmask
EtherNut Gateway

Your routers parameters for the internal network:
IP
Netmask

If your Router spans a network of IP/Netmask 192.168.0.254/255.255.0.0
and your EtherNut has a IP/Netmask of 192.168.1.86/255.255.0.0
and this does'nt work, Nut/OS has a problem.

If _one_or_both_ of these devices has/have a netmask of 255.255.255.0
like it is defined for the Class-C Range 192.168.x.y, you have a problem
with the configuration.
Remember that, again, 192.168.x.y is an IP-Range defined for 256 Class-C
networks what means, that there should be a 255.255.255.0 netmask. Very
often Home-Routers are assuming an Class-C Netmask if they are assigned
to 192.168.x.y. networks.
I know, that 10.x.y.z is used to be 1 Class-A network, where 255.0.0.0
is the right netmask. I forgot about the Class-B, i.e. 255.255.0.0

As all these networks specify numberings for internal networks, everyone
is free to use it as specified... or not.

If you use a Class-B network and there is no router in between your
ethernut on 192.168.1.x and your internet-router on 192.168.0.y then you
have to set the netmask in every device on both networks to 255.255.0.0

I hope, you can clarify the situation, so we are talking about the same
data to find the bug.

I cannot really believe that exchanging ip-packets through the internet
doesn't work with Nut/OS, as I use the Elektor Internet Radio. It gets
its playlists via http-request and receives the selected streams without
any problems.

Best regards,
Ulrich

Gilles schrieb:

>  
>
> Hi all,
>
> I have developed a piece of code to establish a dialog between my ARM9 board
> and a PC in 2 different location.(2 different IP fix addresses)
>
>  
>
> When the PC establish the TCP link ,  the ARM9 receive and respond to the
> TCP frame correctly.
>
>  
>
> If I try to establish the TCP dialog starting from the ARM9, it fails on the
> NutTcpConnect(sock1,dest_addr, PortSend)
>
>  
>
> All is good if I stay inside my office network.
>
>  
>
> Mask and IPgate seems correct.
>
>  
>
> Is anybody has an idea about my trouble?
>
>  
>
> Thanks for the help
>
> Best regards
>
> Gilles
>
>  
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: TCP connection to fixe IP

by Thiago A. Corrêa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Thu, Nov 12, 2009 at 6:24 PM, Ulrich Prinz <uprinz2@...> wrote:
> I cannot really believe that exchanging ip-packets through the internet
> doesn't work with Nut/OS, as I use the Elektor Internet Radio. It gets
> its playlists via http-request and receives the selected streams without
> any problems.
>

My company produces Ethernut 1 based boards and one of those was
accessible thru the internet as a server and working ok. Harald and
some others also have done the same with ARM, so I think there is
clearly a problem with either the code or the network configuration.

A better test than ping is to telnet to your port 5001 from the board
network to your remote network. If a connection isn't established,
then there is some network config issue, most likely a NAT forward
rule missing on the remote end. While pinging is valid, if there is a
NAT forward rule to access this specific port, a telnet will also
certify that a connection to that port specific, using the TCP
protocol is possible.

I noticed that you have enabled Nut Discovery, what does the nutdisc
tool gives you as your board's setup address? Does the gateway IP is
correct? And mask? According to your earlier emails, the only way your
board at 192.168.1.x would be able to access your gateway at
192.168.0.254 were if it was using an 255.255.0.0 mask. Also, notice
that your gateway must use the same mask or it won't talk back to the
board ;)

Kind Regards,
    Thiago A. Correa
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion