How to check port is up or down with SNMP - networking

I develop a app which discovers a network topology and draw it programmaticly with java and SNMP4j
I send CDP and LLDP requests to devices and analyze result of this. However there are devices which has not support CDP or LLDP(like Access Point) therefor I cannot discover it. I must show it as unkown device.
Thanks to CDP and LLDP I know which device is on which port. To understand unknown device is on which port,
I need a oid to learn up and down ports of the Switch with SNMP or another method.
I use SNMP4J

The table dot1dTpFdbTable (1.3.6.1.2.1.17.4.3) shows which MAC addresses can be reached on which ports.
Two things to watch out for: it is not supported by all devices and it does not only list the connected devices but also everything connected to those devices.

Related

Possible to make Wifi and 3G dongle network working together?

Hello.
I have recently been trying to mount a home automation station on a raspberry.
I need to communicate with the station via SMS. To do this, I order a 3G dongle (UMTS / GSM / 3G / 4G etc ...) operating on the country's network (verified frequencies). I connect to the network via wifi. But when connecting the 3G dongle, here I am blocked on access to Wifi.
My first question is therefore: is this normal?
And my second is: is it possible to make both work in parallel?
Thx all
It depends on the exact use case or requirement and type of device in hand.
In general, the device will choose/use the wireless connection with better connectivity strength as per its design/specification and also it depends on the support at device.
In case you have the option of WiFi Hotspot tethering enabled, it is possible that most of the devices nowadays allow you to use 3G for the internet communication and at the same time, it allows WiFi hotspot sharing with the help of WiFi from your device.
Also, few devices have support for file sharing between device to device whereby they provide support for wifi direct and wifi sharing while 3G connectivity with internet is still fine. Few devices from Samsung, support an application called "Download Booster" that allows your device to download files using WiFi connection and a mobile data connection simultaneously.
Few devices from Apple starting iOS 7 introduced Multipath TCP enables users to have their streaming music to never get interrupted while on high mobility or in trains and other vehicles with changing connectivity whereby no manual switch from between WiFi and Cellular is required in which case, the device shall stay connected over both cellular and WiFi simultaneously and whenever the WiFi connection fails, the cellular connection shall continue with streaming operation without any interruption.
There is also a app called 'Speedify' in android that uses channel bonding technology to combine multiple Internet connections together for increased throughput & redundancy and thereby it can merge WiFi and Cellular connection simultaneously. Here, a Speedify client software is used to establish a connection to a Speed Server in cloud that acts as a middleman between you and the rest of the internet. The Speedify client software then works together with Speed Server to distribute your internet traffic and deliver the combined speed of all available internet connections.

How can the Android device programatically infer the IP address of the Linux device it's tethered to?

Hi! Asked this question on many forums and nobody could answer me so PLEASE help!
I have Android device connected to Linux device via USB tethering.
On Android device I have front-end(html, js, css) browser app and on Linux device I have back-end(node.js).
There is a socket connection between front-end and back-end with defined IP:PORT.
Androids gateway is Linux device. Linux device is connected to local network.
When Android device is connected to Linux device, Linux device initializes new network interface called usb0 with static IP address.
Sockets are based on that network IP that is same on every instance of front-end+back-end devices.
I have more than 5 instances of same front-end+back-end devices connected to local network.
Is there a way to somehow find the back-end device IP address without setting it static?
My problem starts when starting all devices at the same time. Sometimes Android device in instance 1 connects to Linux device from other instance and I want to prevent that by not connection to usb0 with Android but to eth0 DHCP of Linux device. I can never know which IP address will be on Linux device but front-end app needs a IP:PORT to connect.
PORT is defined so the string for connecting is {IP + ":3000"}
I know I can see all the IP addresses on network with arp or similar but I need to do that automatic in front-end app on app start up.
I want to find first device IP address that android device is connected to. That is always a front-ends pair Linux device.
Or if it is not possible to prevent Android device to be able to connect another instance with IP tables on Linux device.
P.S I know that Android is also Linux but someone who wants to answer will know what I'm talking about.
Here is a solution describing how to listen for tethering state changes:
First you need to be familiar with BroadcastReceiver. You can find a lot of tutorials describing in great detail how this works (try googling how to listen for connectivity changes in Android).
In order to get the Tethering state update, you need to use a hidden filter action of Android (see ConnectivityManager) and in your BroadcastReceiver class:
IntentFilter filter = new IntentFilter("android.net.conn.TETHER_STATE_CHANGED");
then register the filter to your BroadcastReceiver:
myApplicationContext.registerReceiver(this, filter);
In your onReceive(final Context context, final Intent intent) method, the Intent.extras information contains 3 arrays filled with the corresponding tethered network interface:
erroredArray / availableArray / activeArray
It's a little bit tricky but you can get the tethering status information.
In addition, you can do some reflexion on a hidden function of Android code:
Search for getTetherableIfaces() in the Connectivity Manager.
Here is a link: https://github.com/android/platform_frameworks_base/blob/master/core/java/android/net/ConnectivityManager.java#L1604

Is it possible to determine what jack on a switch a computer is connected to?

Is it possible to determine programmatically what jack on a network switch a computer is connected to?
It's either possible or not possible, depending on the switch.
If it's a managed switch, you could query its management interface to determine the MAC addresses behind each port. Then you could match that up with the hardware address on the computer you're interested in.
Some switches have discovery protocols (such as CDP or LLDP) which will broadcast the port's identity to whichever devices are attached. You could sniff the network for these packets to determine the port your computer is connected to.
You can try disonnecting them one by one and each time testing if the network connection goes down.
To identify switch port connected to your pc ; you need to manually access the switch and remove ur rj-45 cable so you can visualize any port having state of disconnection.. dm gui can be used if switch is managable
cdp and lldp wont work for pc as it doesnt support it

Can the MAC address of a mobile device be easily determined?

This is somewhat of a general question, is it realistic to assume that a router can resolve any mobile device's MAC address without being already connected via wifi or bluetooth?
If the device is broadcasting, or if it's connected to another access point, then capturing the wifi data would allow you to capture the device's MAC address. Routers aren't generally set up to listen in that way, and I don't think it would be simple to configure that kind of behavior.
In general, if a device isn't connected to a wireless router/access point, you aren't going to be able to capture its MAC.

Detect all networked devices' types in a home network

I would like to write a software running in a networked device, i.e. PC. It can automatically detect the other network devices' types. For example, it can detect there is a PS3, a Wii, an IPad running in the same network. Any ideas? Thanks,
You have two problems: first, detecting that a device is connected to your network and at 192.168.1.x. Second, somehow detecting what that device is.
The first is easy-ish to accomplish: there's discovery protocols like UPnP and Bonjour. However, in a home networking scenario, the easiest and most reliable way to get a list of connected devices is probably to pull the DHCP reservations from your router. You might have to scrape data from the router's HTML-based management interface—hacky as that may be—but it would work. (If you're using .NET, consider the HTML Agility Pack to accomplish this.)
Once you have a list of IP addresses of connected devices, your next problem is to figure out what each device actually is. This will be more challenging. Some possibilities:
You may be able to use the MAC address to help detect the device's vendor. (Here's a list.)
If you're using UPnP, you can ask the device what it is.
Use IP fingerprinting to determine what the device is.
Couple thoughts. The broadcast IP address - 255.255.255.255 is where devices talk and say "here I am". Should be able to listen to this and find ip addresses and more. Second, if devices are assigned an IP address by a DHCP client (obviously) you can usually find a list on the dhcp device. Devices often have names, this is a higher level protocol, like windows SMB, that you may have to interface with in order to get that information.

Resources