ip address questions - Netduino 2 (and Netduino 1) - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

ip address questions


  • Please log in to reply
11 replies to this topic

#1 jeremytio

jeremytio

    New Member

  • Members
  • Pip
  • 9 posts

Posted 05 March 2015 - 04:37 PM

Hello Netduino folks.

 

I am total noob to netduino... running a test:

 

I used the Microsoft.SPOT.Net.NetworkInformation.NetworkInterface class to  call the

class function via:

 

Debug.Print("my ip Address: " + networkInterface.IPAddress.ToString());

 

When I run the program I get the ip address 192.168.5.100 back to VS.

So I am glad that I am getting a response.

 

The strange thing is when I run "tracert 192.168.5.100" from my dos cmd prompt,

It hops from my router to my ISP provider then times out!

 

I dunno what is happening here. Why is the packet going beyond my local network????

 

Thanks a million in advanced.

 

Until then I will dig the internet for clues :)

 

 



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 09 March 2015 - 12:56 AM

Hi Jeremy,

192.168.5.100 may be the default address and not a DHCP-assigned address.

If you open up MFDeploy, select your device, go to the Target menu and then go to Network Configuration...is DHCP selected?

Welcome to the Netduino community,

Chris

#3 jeremytio

jeremytio

    New Member

  • Members
  • Pip
  • 9 posts

Posted 25 March 2015 - 04:00 PM

Thanks Chris!

 

I took your advice and set MFDeploy to use DHCP as well changed my Static IP address to 192.168.0.100.

 

At this point I can ping and tracert to the Netduino Plus.

 

I decided to purchase your book "Getting started with Netduino"

 

it has been great!

 

I am stuck on Project 8: (  I copied the example per verbatim):

 

tracking it down with the debugger I can see it is on line:

 

Socket clientSocket = listenerSocket.Accept();

 

I assume it is waiting for the client.. so I go to my browser and enter http://192.168.0.100

 

but the web browser says the web page is not available.

 

At this point the the MS visual C# debugger has the play and step over, and step through buttons greyed out,

and the debugger's yellow arrow cursor is not visible either.

 

I assume the the socket is still listening for a request... but isn't getting any?

 

Thanks so much Chris, your work is opening exciting new opportunities!



#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 March 2015 - 05:12 PM

Hi Jeremy,

Which Netduino board are you using?

What is the IP address of your computer?

How is your computer connected to the Netduino?

And...can you please copy and paste the code snippet here?

Thank you,

Chris

#5 jeremytio

jeremytio

    New Member

  • Members
  • Pip
  • 9 posts

Posted 29 March 2015 - 04:33 PM

Thank you Chris.

 

 

1. Board is a Netduino Plus

2. The ip address of the computer connected to the Netduino is a 192.168.0.103

3. the method of connect is the usb port.

4. Code Snippet:

< will paste on next post>



#6 jeremytio

jeremytio

    New Member

  • Members
  • Pip
  • 9 posts

Posted 29 March 2015 - 04:35 PM

code snippet

 

        public static void Main()
        {
            // write your code here
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
            int port = 80;
            Thread.Sleep(5000);
            Microsoft.SPOT.Net.NetworkInformation.NetworkInterface
                 networkInterface = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0];

            Debug.Print("my ip address: " + networkInterface.IPAddress.ToString());
            Socket listenerSocket = new Socket(AddressFamily.InterNetwork,
                                               SocketType.Stream,
                                               ProtocolType.Tcp);
            IPEndPoint listenerEndPoint = new IPEndPoint(IPAddress.Any, port);

            listenerSocket.Bind(listenerEndPoint);
            listenerSocket.Listen(1);

            while(true)
            {
                Socket clientSocket = listenerSocket.Accept();
                bool dataReady = clientSocket.Poll(5000000, SelectMode.SelectRead);
                if (dataReady && clientSocket.Available > 0)
                {
                    byte[] buffer = new byte[clientSocket.Available];
                    
                    int bytesRead = clientSocket.Receive(buffer);

                    string request =
                        new string(System.Text.Encoding.UTF8.GetChars(buffer));

                    if (request.IndexOf("ON") >= 0)
                    {
                        led.Write(true);
                    }
                    else if (request.IndexOf("OFF") >= 0)
                    {
                        led.Write(false);  
                    }
                   
                    string statusText = "Led  is " + (led.Read() ? "ON" : "OFF") + "." ;

                    string response =
                        "HTTP/1.1 200 OK\r\n"+
                        "Content-Type: text/html; charset=utf-8\r\n\r\n"+
                        "<html><head><title>Netduino Plus  LED Sample</title></head>"+
                
                       "<body>"+statusText+"</body></html>";
                    clientSocket.Send(System.Text.Encoding.UTF8.GetBytes(response));
                } // end if dataReady
                clientSocket.Close();
            }
        }
    }
}



#7 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 31 March 2015 - 07:40 AM

Hi Jeremy,

When you run the app, can you "pause" it from Visual Studio?

If not--there may be a bug in the IDE that needs to be addressed.

If so--please pause your app. Note what line of code was "paused" on. Then "single step" to get it running again. Then try connecting from your PC browser to the web server on your Netduino...does execution stop (i.e. it saw the connection)?

Chris

#8 jeremytio

jeremytio

    New Member

  • Members
  • Pip
  • 9 posts

Posted 01 April 2015 - 10:33 PM

Thanks Chris, I am able to step with the debugger.

 

The program seems to be stuck at:

 

Socket clientSocket = listenerSocket.Accept();

 

so I assume it is waiting for the client to send to the socket .

 

I enter the ip address in the browser, but that does not seem to do much.

 

Any tips É



#9 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 April 2015 - 01:20 AM

Hi Jeremy,

Any chance you can grab a copy of Wireshark, make the connection from your browser, and let us know what actually happens on the network?

If you're running the book sample as-is, it sounds like traffic is not making it to/from your device.

Chris

#10 jeremytio

jeremytio

    New Member

  • Members
  • Pip
  • 9 posts

Posted 05 April 2015 - 05:21 PM

Thanks Chris,

 

I used wire shark to collect the traffic. I can see requests and acks being sent from the netduino card

( 192.168.0.100) and my computer ( 192.168.0.103). However the web page is still not being served.

 

Judging from the contents of the packets shown via wire shark, it doesn't seem that the html is being sent over.

I am not familiar enough with the protocol to know if this is making sense.

 

I included a snippet of the wire shark log.. I am hoping you might know what this means?

 

 

 



#11 jeremytio

jeremytio

    New Member

  • Members
  • Pip
  • 9 posts

Posted 05 April 2015 - 05:22 PM



#12 jeremytio

jeremytio

    New Member

  • Members
  • Pip
  • 9 posts

Posted 05 April 2015 - 05:29 PM

Url to log of wireshark

 

"http://s1180.photobu...shark.jpg.html"






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.