get local IP from RedPitaya [C#]

Applications, development tools, FPGA, C, WEB
Post Reply
aschuetz
Posts: 34
Joined: Tue Nov 24, 2015 11:26 am

get local IP from RedPitaya [C#]

Post by aschuetz » Tue Apr 04, 2017 8:08 am

Dear all,

as far as I know RedPitaya Ecosystem is using "systemd" to manage network connections and "ifconfig" doesn't show me the correct local IP of eth0. Anyway, I have a program that runs at the RedPitaya and is a server. It needs to know its own local IP. Usually I use the following snippet:

Code: Select all

...
var host = Dns.GetHostEntry(Dns.GetHostName());
                
                foreach (var ip in host.AddressList)
                {

                    // extract IPv4
                        if (ip.AddressFamily == AddressFamily.InterNetwork)
                        {
                            return ip.ToString();
                        }
               }
...
But this doesn't work for the RedPitaya. It works for Windows 7, Ubuntu 14.04 and Raspbian Jessie. Is this related to the the "systemd" service or maybe to the avahi-daemon? I had a lot of problems using the RedPitaya in an enterprise network because of ignoring the DHCP as it was used in older version (but this is olved). The RedPitaya has a reserved IP which is coupled to the Bonjour ID instead of the MAC address.

This is the output of "ip a" with the correct IP 172.31.153.79

Code: Select all

root@rp-f010d0:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:26:32:f0:10:d0 brd ff:ff:ff:ff:ff:ff
    inet 169.254.172.202/16 brd 169.254.255.255 scope link eth0
       valid_lft forever preferred_lft forever
    inet 172.31.153.79/16 brd 172.31.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::226:32ff:fef0:10d0/64 scope link
       valid_lft forever preferred_lft forever
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default
    link/sit 0.0.0.0 brd 0.0.0.0
To conclude: Why does this function doesn't work for the RedPitaya? Is this because "Dns.GetHostName()"?

Thanks,
Alex

izi
Posts: 34
Joined: Wed May 27, 2015 11:49 am

Re: get local IP from RedPitaya [C#]

Post by izi » Wed Apr 12, 2017 9:48 am

Are you using Mono to tun C# apps on redpitaya?

The IP address should be accessible using the kernel interface, but I can not comment regarding specific implementations (languages) especially ones I do not use (C#).

I do not think systemd is relevant here. While it provides its own services instead of some tools used in System V, mechanisms for obtaining the system IP address should not rely on them but instead use the kernel interface. Services from systemd we use are for DHCP (both client and server), DNS, NTP, ... I can only speculate, DNS could be responsible for your issues, if C# is attempting to parse configuration/status files not available on this board. I would recommend trying a different C# approach for obtaining the IP address.

ifconfig is deprecated and unable to handle newer Linux kernel IP features, so please do not use it, use 'ip' instead.

You mentioned DHCP without many details, both the client and the server were replaced with tools provided in systemd.
1. On the client side, the main incompatible change compared to older releases is the inability to have a default lease is there is no server on the network, this was used for direct connection between PC and Red Pitaya, zeroconf addresses should be used now.
2. On the server side, the latest released image has a problem in the configuration so the DHCP server on Red Pitaya will not work in WiFi access point mode, this is already fixed in the current beta.

Regards,
Iztok Jeras

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 31 guests