How to establish ethernet connection between laptop and embedded device - network-programming

I'm designing a device which will be connected to a computer using ethernet. It already has a mac controller built in. When I attach the device, all that happens is the computer broadcasts a bunch of DHCP discover packets and some other packets I guess in an attempt to find the device and establish the connection. I assume I need to make my device respond at this point with some sort of acknowledgement packets but I'm not sure what? Has anyone done something like this before? Thanks
I'm using wireshark to see the packets. The output looks something like this:
time source destination protocol info
1 0.000000 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xc82a69f
2 4.000064 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xc82a69f
3 10.688469 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xb452266b
4 14.690625 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xb452266b
5 22.690576 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xb452266b
6 38.690605 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xb452266b
7 62.652821 my_ip XXX.XXX.255.255 BROWSER Local Master Announcement MYLAPTOP, Workstation, Server, Print Queue Server, NT Workstation, Potential Browser, Master Browser
8 65.555281 my_ip XXX.XXX.255.255 BROWSER Domain/Workgroup Announcement MY, NT Workstation, Domain Enum
9 352.692192 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xa23d42a4
10 356.692376 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xa23d42a4
11 364.692421 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xa23d42a4
12 381.692442 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xa23d42a4
13 665.557507 my_ip XXX.XXX.255.255 BROWSER Domain/Workgroup Announcement MY, NT Workstation, Domain Enum
14 686.724951 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xbe3a7bdb
15 691.724307 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xbe3a7bdb
16 698.724276 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xbe3a7bdb
17 715.724291 0.0.0.0 255.255.255.255 DHCP DHCP Discover - Transaction ID 0xbe3a7bdb
18 783.295682 my_ip XXX.XXX.255.255 BROWSER Local Master Announcement MYLAPTOP, Workstation, Server, Print Queue Server, NT Workstation, Potential Browser, Master Browser
19 908.920831 my_ip XXX.XXX.255.255 BROWSER Get Backup List Request
20 908.920940 my_ip XXX.XXX.255.255 NBNS Name query NB MY<1b>

If your computer is broadcasting DHCP packets it's because it needs a DHCP server to get an address. It is not looking for your device. Did you take the computer off the main network and hook it up on a private network with your device?
Your computer knows nothing about your embedded device and will not try and make a connection with it. The first thing you need to do is decide what the connection will do and then write or obtain software to create the connection. Typically the embedded device will create a server socket and wait for a client (you computer) to connect to it. Telnet is an example of a client/server tcp connection.
It is apparent from your post that you are unsure about what your embedded device is doing. You need to elaborate more about your embedded device and how it should function.

It looks like what is happening is that your device is trying to get an IP number from a DHCP server, but there is no DHCP server responding.
EDIT: I say it is the device because if I am reading the trace right, your computer already has an IP number. It might be instructive to look at the underlying Ethernet frames -- I believe Wireshark lets you do that.

"DHCP Discover" means your PC is asking any device connected to the Ethernet Link for an IP address it could use. Obviously your device is not a DHCP-server. Instead, as a first step, you should assign both your pc and your device static IP addresses, preferably from the private IP ranges like 192.168.x.x.
If your device has a working IP-stack, it should then answer to pings.
You can ignore the BROWSER and NBNS packets. Thats just Windows trying to talk to another Windows.
Correction: It's not completely clear, which device broadcasts the DHCP Discover, it's most likely your PC, but it could as well be the device (if it has a built-in DHCP-Client), or any other device on the same Ethernet link. You need to include the MAC Adresses in the Wireshark dump to be sure.

Related

Use PiHole for Guest Network on OpenWRT router

I followed this tutorial to create a guest wifi, which is working great.
My PiHole is filtering out ads on my main wifi at 192.168.1.1.
However, if I add 6,192.168.1.2 (which is my PiHole's static address) as the DHCP Option to the guest interface's advanced settings under the DHCP tab, none of my devices connected to the guest wifi are able to connect to the internet, e.g. ping google.com.
LAN is setup as 192.168.1.1
GUEST is setup as 192.168.3.1
My current firewall settings look like this:
Guest => WAN: Input (Reject), Output (Allow), Forward (Reject)
I added Traffic Rules according to the tutorial mentioned above, for port 53 and port 67.
I probably need to add some firewall rule but I am not too savvy with OpenWRT's firewall. Possibly there is another solution too?
Here is what I did to solve this issue:
Essentially, I added a traffic rule in the OpenWrt firewall to allow UDP packets from my Guest LAN to my main LAN 192.168.1.2 on port 53.
These are the steps I took, when adding a new Traffic Rule:
Protocol: UDP only
Source Zone: Guest
Destination IP: 192.168.1.2
Destination Port: 53
All other values/options were left untouched
Now, all connected devices to the Guest network are being filtered through PiHole as well.

Pinging www.apple.com ports

I building small utility iOS App with GCDAsyncSocket that will ping ports on www.apple.com: list of ports.
For example, trying to connect on TCP port 80 and 443 I got "connected" status, but when I try 2195 and 2196 I get "timeout".
When trying to connect to ports with GCDAsyncUdpSocket, whichever port I try to connect I get "connected", even though some ports aren't open (tested with nmap which returns "closed").
So, I have couple of questions:
1) Am I doing something wrong when trying to connect to ports 2195, 2196, etc?
2) Is GCDAsyncUdpSocket reliable? Whatever I try with it, it passes.
You have several misconceptions here:
You shouldn't try to connect to a lot of ports on a server that is not yours unless you are authorized to do that. This is called pentesting, and it is at minimum not nice if not illegal.
The list of ports you refer to is not about "www.apple.com", it is about Apple products in general, so like any macOS computers. You can use a computer of your friend to try that. Or a virtual machine on your own computer.
UDP protocol doesn't have a "connected" state. The big difference between UDP and TCP is that TCP has connections support while UDP doesn't. The "connected" state of GCDAsyncUdpSocket is probably fake.
See this about detecting if an UDP port is open or not.

Portforwarding not working

I recently tried to portforward port 80 on my local IP, but as the tutorial said, it should be open on my external IP, which it's not. But it is open on my local ip thought.
I have portforwarded port 80, range 80 UDP and TCP on my local IP: 192.168.1.170
This is the tutorial i followed: https://www.youtube.com/watch?v=RZTYqTGqtjI
I portforwarded my IP in the router settings.
https://image.ibb.co/hGW4fm/Sk_rmbild_345.png
https://image.ibb.co/exWFmR/Sk_rmbild_344.png
IF THE suggested METHOD DOESN'T WORK FOR YOU , DO THIS :-
GOTO -> SECURITY TAB -> REMOTE MANAGEMENT
Enable the Remote Management (or enter 255.255.255.255 in the field) .
This will enable the you to access your LAN from WAN.
For the record :-
Internal Port is the PORT on which the device in your LAN is serving .
External Port is the port which the user enters in the browser . exp :- 127.184.184.19:8080 .
Here 8080 is the external port . And if a device in your LAN runs a http web server at port 80 , then the internal port would be 22.
If the Above methods don't work , then your ISP might be using Carrier NAT which means you would have a different PUBLIC and WAP ip address .
In this case , you should use the WAN ip address shown in your router configuration page to access your LAN from internet. s
Kindly Try to open same URL from different Internet Connection other than LAN

Contiki IPv4 connection to 127.0.0.1 loop back address

I m new to contiki. I used cc2650 sensortag and now i m using cc1310 launchpad. i use beagebone as a edge router and one cc1310 launchpad as a slipradio. everything works fine. i can open Coap and web and also i can get sensors data on web and coap.
now, i want to send sensor data on our own ipv4 cloud using tcp socket. but, i cant create tcp socket to my cloud. Is it possible to create ipv4 tcp socket directly from node?
#g-oikonomou #adamdunkels #farcaller can anyone suggest me how to create ipv4 tcp socket to 127.0.0.1 ip address and 1502 port?

Network Sniffer - I not seeing the TCP traffic which my IP send to the device. I'm using Wireshark Software

I not seeing the TCP traffic which my IP send to the device. I'm using Wireshark Software. I only see the TCP traffic which my IP receive from device.
Please, did many things, and no solution.
- firewall disabled
- antivirus disabled
- Wireshark updated (Version 2.0.3)
- WinPcap (4_1_3)
My IP: 192.168.0.111
Device: 192.168.0.240 Port: 9870
In my PC there is a TCP listening service in the port 9870.
And running a software to communicate with device. It occurs even if I connect others devices

Resources