Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » Network Admin in Kura - how does it work?
Network Admin in Kura - how does it work? [message #1645183] Mon, 02 March 2015 11:20 Go to next message
Alessandro Da Rugna is currently offline Alessandro Da RugnaFriend
Messages: 43
Registered: December 2014
Member
I'm missing something about the whole Network configuration in Kura.
1. Where does Kura store/read network configurations?
2. How can I customize the NetworkAdminService?
3. How can I debug network issues?

1. As far as I unterstand, Kura's NetworkConfigurationService implements SelfConfiguringComponent, so it reads its configuration from the system. But the starting "status" is provided by org.eclipse.kura.net.admin.NetworkConfigurationService configuration in the snapshots. Am I right?
Then the actual status is read from /etc/network/interfaces and sometimes from /tmp/.kura/coninfo-$IFACE. Kura installs hooks to system ifup/ifdown to create and delete such file (deletion doesn't work btw - is it intendend behaviour?)
What is the role of kura/data/kuranet.conf? I've stepped through code but it's not very clear to me what is each file's purpose.

2. I'm trying Kura on a different linux machine than raspberry/beaglebone where I'd like to control the network interfaces. I modified some files to call the right command for my system. (e.g., the ones containing OS_VERSION = System.getProperty("kura.os.version"); (A)) but Kura goes crazy and the $IFACEMonitorThreads continue to bring each interface up and down without stopping. I think I'm missing some step somewhere.

I disabled the administration of WiFi from snapshot configuration file
<esf:property name="net.interfaces" array="false" encrypted="false" type="String">
    <esf:value>lo,eth0</esf:value>
</esf:property>

Is this the right place? I also tried disabling it or removing it from kuranet.conf but no luck.

3. I can switch the eth0 from WAN to LAN and enable the dhcp server. When I switch it back to WAN, it gets the address but Kura (and all system) cannot connect to the network anymore. Strangely enough, I can access the machine via SSH or Kura's Web interface but cannot ping it. ifdown says the interfaces is already down, and ifup cannot restore the connectivity correctly.
How do you approach such problems?


(A)
project org.eclipse.kura.linux.net
LinuxNamed.java
LinuxFirewall.java
KuraConstants.java
LinuxNetworkUtil.java

project org.eclipse.kura.net.admin
IfcfgConfigReader.java
IfcfgConfigWriter.java


My project: Kura web log level changer https://github.com/darugnaa/kura-web-log
My blog: http://darugnaa.github.io
Re: Network Admin in Kura - how does it work? [message #1646450 is a reply to message #1645183] Tue, 03 March 2015 01:29 Go to previous messageGo to next message
David Woodard is currently offline David WoodardFriend
Messages: 420
Registered: July 2014
Senior Member
Hello,

The network administration is one of the more complex pieces to Kura. I will try to answer your questions as clearly as possible. Feel free to ask any follow up questions you like.

1. You have correctly identified the files Kura uses to control network settings. Kura first uses a snapshot configuration file to create its internal view of the network settings. If you are trying to add/change/delete network settings, this is where to start. Once Kura has loaded this file, it will attempt to synchronize these setting with the system by writing to the various files (/etc/network/interfaces, /etc/hostapd, etc). Further, each interface has a monitor that attempts to apply the state of the Kura configuration to the system using various utilities (ifup, ifdown, etc.). For example, if you have "eth0" set to enabled but the ethernet cable unplugged, the monitor will continually attempt to bring the interface up. Manually changing network configuration files, particularly while Kura is running, can get the system quite confused. It is best to do all network management through the Kura web UI if possible.

2. There currently is no simple way of ignoring an interface in Kura. This is on our roadmap, but haven't done it yet. The list of interfaces in the snapshot file is indicating the interfaces that have configurations defined. Kura will attempt to manage any interface that appears with the command 'ifconfig -a'. I believe we have some temporary hacks in Kura to avoid USB0 on the BeagleBone for this very reason. At the moment, if you use Kura with network admin, Kura expects to have control over all interfaces.

It is hard to say what was causing the monitors to go crazy without knowing the Linux system you are using. I can tell you the main reason we have switches based on OS are for file I/O. We roughly group all file I/O for network administration into two categories: Debian based or RedHat based. Depending on the OS, we make assumptions about the location of networking files. If your version of Linux is using a different directory structure, it could certainly cause problems. I would also try increasing the log level and examining the log files. It is possible that the commands you are using are returning values that Kura doesn't understand. Instead of throwing an error, it may be giving a warning and entering a loop.

3. Did this happen on the Raspberry or another Linux machine? I tried this on my RPi and it worked. When we have seen this in the past, it is usually caused by either not having the proper route set in the routing table (route -n) or not having a DNS server defined (/etc/resolv.conf). If you can ping an outside address (ex: 8.8.8.8 ) then it is likely a DNS issue. If you can't ping an outside address, it is likely a routing table issue. This likely happened because Kura became confused. I would recommend turning the debug level up (from INFO to DEBUG) and checking for errors in the kura.log. Let me know if this happened on the RPi.

Hopefully I answered some of you questions.

Thanks,
--Dave

[Updated on: Tue, 03 March 2015 01:29]

Report message to a moderator

Re: Network Admin in Kura - how does it work? [message #1648389 is a reply to message #1646450] Tue, 03 March 2015 22:30 Go to previous messageGo to next message
David Woodard is currently offline David WoodardFriend
Messages: 420
Registered: July 2014
Senior Member
It occurred to me I didn't answer your questions about the Kura specific files.

kuranet.conf - This file is used to store information that cannot be obtained from Linux networking files. For example, the status of a interface in Kura may be "netIPv4StatusEnabledWAN", which means nothing to the Linux OS. We will likely move away from this file in the future as all this information is also stored in ConfigAdmin and the snapshot files.

coninfo-* - These files are also used to obtain specific network information, such as DNS and default gateways. This information is not always available if the interfaces are down, so we needed a place on disk to store the information.

Thanks,
--Dave
Re: Network Admin in Kura - how does it work? [message #1654372 is a reply to message #1648389] Fri, 06 March 2015 17:06 Go to previous messageGo to next message
Alessandro Da Rugna is currently offline Alessandro Da RugnaFriend
Messages: 43
Registered: December 2014
Member
Thank you very much for your answers.
David Woodard wrote on Tue, 03 March 2015 23:30

coninfo-* - These files are also used to obtain specific network information, such as DNS and default gateways. This information is not always available if the interfaces are down, so we needed a place on disk to store the information.

Ok, so coninfo-* files are not supposed to be deleted by ifdown-local hook script.


My project: Kura web log level changer https://github.com/darugnaa/kura-web-log
My blog: http://darugnaa.github.io
Re: Network Admin in Kura - how does it work? [message #1695795 is a reply to message #1654372] Tue, 19 May 2015 11:11 Go to previous messageGo to next message
Alessandro Da Rugna is currently offline Alessandro Da RugnaFriend
Messages: 43
Registered: December 2014
Member
Hello David, I'm still working on my customized networking. I'm peeking into org.eclipse.kura.web.server.GwtNetworkServiceImpl method updateNetInterfaceConfigurations(GwtNetInterfaceConfig config) to try to understand how Kura's web interface handles the changes.
This is my method to set up the WiFi as AccessPoint.
Could you please take a look at it and tell me if I'm doing something obviously wrong?
I'm looking forward to Kura 1.2.0 and its many improvements on this part.

private void applyWiFiAccessPoint() throws KuraException {
	try {
		// 1
		// List all used IPs
		IP4Address wifiIpAddress = (IP4Address) IPAddress.parseHostAddress("192.168.1.1");

		IP4Address rangeStart = (IP4Address) IPAddress.parseHostAddress("192.168.1.5");
		IP4Address rangeEnd = (IP4Address) IPAddress.parseHostAddress("192.168.1.20");
		IP4Address subnetMask = (IP4Address) IPAddress.parseHostAddress("255.255.255.0");
		IP4Address subnet = (IP4Address) IPAddress.parseHostAddress("192.168.1.0");						
		short prefix = 24;
		
		// 2
		// Configure static IP for wlan0 interface
		NetConfigIP4 netConfig4 = new NetConfigIP4(NetInterfaceStatus.netIPv4StatusEnabledLAN, true);
		netConfig4.setDhcp(false);
		netConfig4.setAddress(wifiIpAddress);
		netConfig4.setSubnetMask(subnetMask);

		// 3
		// Configure DHCP server
		DhcpServerConfigIP4 dhcpWifiServerConfigIP4 = new DhcpServerConfigIP4("wlan0", true,
				subnet,
				wifiIpAddress,
				subnetMask,
				7200, 7200,
				prefix,
				rangeStart,
				rangeEnd,
				false,
				null);
		
		// 4
		// Configure WiFi Card
		// WifiConfig [mode: MASTER :: ssid: MyAP :: ignoreSSID: false :: driver: nl80211 :: channels: 1, :: security: SECURITY_NONE :: passkey:  :: hwMode: n :: radioMode: RADIO_MODE_80211nHT20 :: broadcast: true :: ]
		WifiConfig wifiConfig = new WifiConfig();
		wifiConfig.setMode(WifiMode.MASTER);	// Access Point mode
		wifiConfig.setSSID("MyAP");
		wifiConfig.setIgnoreSSID(false);
		wifiConfig.setDriver("nl80211");
		wifiConfig.setChannels(new int[] {1});
		wifiConfig.setSecurity(WifiSecurity.SECURITY_NONE);
		wifiConfig.setHardwareMode("n");
		wifiConfig.setRadioMode(WifiRadioMode.RADIO_MODE_80211g);
		wifiConfig.setBroadcast(true);
		wifiConfig.setPingAccessPoint(false);
		
		// 5
		// Add this configuration too, it is required but not used
		// WifiConfig [mode: INFRA :: ssid:  :: ignoreSSID: false :: driver: nl80211 :: channels: 1,2,3,4,5,6,7,8910111213 :: security: SECURITY_NONE :: passkey:  :: hwMode:  :: broadcast: false :: bgscan: ]
		WifiConfig clientWifiConfig = new WifiConfig();
		clientWifiConfig.setMode(WifiMode.INFRA);
		clientWifiConfig.setIgnoreSSID(false);
		clientWifiConfig.setDriver("nl80211");
		clientWifiConfig.setChannels(new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13});
		clientWifiConfig.setSecurity(WifiSecurity.SECURITY_NONE);
		clientWifiConfig.setBroadcast(false);

		// 6
		// Add all NetConfigs to a list to be passed to NAS.
		List<NetConfig> netConfigs = new ArrayList<NetConfig>();
		netConfigs.add(netConfig4);
		netConfigs.add(dhcpWifiServerConfigIP4);
		netConfigs.add(wifiConfig);
		netConfigs.add(clientWifiConfig);
		
		// 7
		// Prepare the AccessPoint
		
		// m_networkAdminService.manageDhcpServer("wlan0", true);
		m_networkAdminService.updateWifiInterfaceConfig("wlan0", true, null, netConfigs);
	} catch (UnknownHostException e) {
		throw KuraException.internalError(e);
	}
}


My project: Kura web log level changer https://github.com/darugnaa/kura-web-log
My blog: http://darugnaa.github.io
Re: Network Admin in Kura - how does it work? [message #1695995 is a reply to message #1695795] Wed, 20 May 2015 23:51 Go to previous messageGo to next message
David Woodard is currently offline David WoodardFriend
Messages: 420
Registered: July 2014
Senior Member
Hello,

It looks okay, but I am not sure what you are trying to do that isn't implemented in Kura. Kura already has methods for setting up a wireless access point. Were they not sufficient for your needs?

Thanks,
--Dave
Re: Network Admin in Kura - how does it work? [message #1696558 is a reply to message #1695995] Wed, 27 May 2015 09:14 Go to previous message
Alessandro Da Rugna is currently offline Alessandro Da RugnaFriend
Messages: 43
Registered: December 2014
Member
I want to control network interfaces programmatically. I am trying to build a custom web interface and I'd like to include networking setup feature.
Using kura's web interface all the networking changes are applied correctly, but mine fails. So I'm trying to understand what kura does exactly.


My project: Kura web log level changer https://github.com/darugnaa/kura-web-log
My blog: http://darugnaa.github.io
Previous Topic:Update a Bundle
Next Topic:OPC UA Implementation
Goto Forum:
  


Current Time: Fri Aug 23 18:39:50 GMT 2019

Powered by FUDForum. Page generated in 0.01697 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top