receive packet from device is not working as expected [closed] - c

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
Here is my configuration
my PC IP :192.168.1.57 subnetmask : 255.255.255.0
my device IP :73.83.1.57 subnetmask : 255.255.255.0
i am successfully able to send packet from my pc to device but not able to send packet from device to pc (have checked in wire shark but it show only PC->device packet transmission flow )
Now i have added one more IP like device ip family in PC (73.83.1.60) then successfully able to two way communication.same works in reverse order means i have set my device IP as 192.168.1.58.
So is there any rules like both IP must belongs to same IP family?
because sub net mask in both are same. so issue is IP.
Any one have idea? is it correct network behavior? can i solve it without making same IP family.?

If you are using both IPs on the same LAN they should be on the same subnet ex:
11.1.1.1/24 can ping 11.1.1.44/24 but it can't ping 11.1.2.2/24 ( different subnets)
In WAN not necessary, for example 192.168.1.1 can ping 72.1.1.1 ,, but 72.1.1.1 can't ping 192.168.1.1 because this ip is private and when it leaves the LAN it becomes real ip because of NAT (Network Address Translation)

Related

Tap device in linux not properly passing ARP/IP packets? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
There seem to be some other people who have similar questions to mine, but I think they're particularly specific. I think I may be running into a general problem.
I have a TAP device in Linux (created in C) that is connected to another network, and I want my computer to be able to communicate to the other network through this TAP device.
I can see arp packets coming in clearly with wireshark, but my kernel will not respond to them. I have tried configuring a bridge and setting the bridge's IP address to no avail. I've also tried bridging to physical hardware and for some reason, Linux doesn't seem to pass the data through to the other nic.
If I set up static ARP routes, it seems that this Linux box doesn't respond to pings to devices on it.
# ifconfig tap0 up
# brctl addbr br0
# brctl addif br0 tap0
# brctl addif br0 eth9
# ifconfig br0 up
I can try setting br0, eth9, or tap0 to an IP, but none reply to pings or arps. Even if I destroy the bridge, no nothing.
I feel like what I want is a "pretend" interface. Like "this is a fake ethernet card" and to talk over that. I feel like that should be possible with tap.
Similar issues:
Linux TUN/TAP: Unable to read data back from TAP devices
Why aren't ARP or ICMPv6 packets processed by a Linux TAP device
I regret that this was unrelated to the way tap/tun devices work in Linux. In fact, this mechanism will work.
The issue was in that I was using "send" and "recv" to talk to the raw tap device. Wireshark can't tell the difference, but the Linux OS will refuse to use the data coming from the socket.
Use this guy's example: http://www.cis.syr.edu/~wedu/seed/Labs/VPN/files/simpletun.c

Send huge (approx 40K bytes) data through UDP protocol, how it was possible? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am working on Ethernet module, in which I am using IPv4 and UDP to transmit data over Ethernet.
I know, as per theory Ethernet can transmit 65K bytes of data.
But in single frame as per MTU, we can transmit only 1518 bytes(approx) of data including header, addresses.
After 1518 bytes of data, Is Ethernet module will take care of transfer for remaining data or the programmer need to write any logic for that.
In Internet i found that large data can be fragmented using IP fragmentation.
So the fragmentation procedure stack is provided by vendor or not?
Is vendor have their won Ethernet stacks to transfer huge data?
Help is appreciated.
Your application can transmit the entire payload of approx. 40K bytes as a single UDP message. This is because, internally, the IP protocol can fragment and re-assemble datagrams of up to 64KBytes for their transmission into smaller packets. Since your payload is under this limit, and IP datagram can carry your intended payload.
As the MTU in ethernet is 1518 bytes, the IP stack will fragment the message into multiple IP packets at the sending side. On receiving side, the IP stack will re-assemble the IP fragments into single IP packet having 40K bytes payload. The application on the receiving side would be able to read the 40Kbytes message only after IP stack successfully reassembles the message.
You can refer to Linux kernel UDP code at http://lxr.free-electrons.com/source/net/ipv4/udp.c.
The explanation of an IP datagram and how it can tag sub-packets for re-assembly can be found here: http://www.freesoft.org/CIE/Course/Section3/7.htm

Chat server and client implementation? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I've been dying to implement a chat server in C and Winsock for a long time now, but I haven't taken the time. Partly, because I'm still unsure of some of the conceptual ideas about building a server on Windows OS'es for something like chat.
Here are some of the issues I've been thinking about :
How will user x connect to my server over a generic LAN
without me relying on them to type in a network address( e.g. address
could be invalid, redirected to a different server, etc. )
If I use broadcasting to solve the above problem, will that be reliable enough for chat?
Will that potentially DDos a LAN since the packets will be be forcibly handled on every machine and may take a lot of bandwidth if enough people join?
What is the difference between multicasting and broadcasting? Is multicasting truly superior?
Etc.
Per request, my definition of reliability would be that I can get most of the data consistently in sent packets. In other words, I don't mind a few dropped packets, but I do mind if the data gets messed up quite a lot along the way.
Currently, I have a lot more questions than answers, but the main point I'm getting at is this :
What is the safest and most reliable way of implementing a chat over a LAN in C and Winsock?
How will user x connect to my server over a generic LAN without me relying
on them to type in a network address( e.g. address could be
invalid, redirected to a different server, etc. )
Use a closed list of known servers, or use some broadcast based autodiscovery system.
If I use broadcasting to solve the above problem, will that be reliable
enough for chat?
Define your requirements for reliability.
Will that potentially DDos a LAN since the packets will be be forcibly
handled on every machine and may take a lot of bandwidth if enough
people join?
It's a chat... the amount of generated packets will be comparatively short and small.
What is the difference between multicasting and broadcasting? Is
multicasting truly superior?
Search the web. There are lots of resources and information about multicasting, most precisely, IP multicasting. In short:
Broadcast delivers to all hosts on a broadcast domain. Multicast delivers to all hosts that have explicity joined a multicast group, which may not be in the same broadcast domain (see last point).
Broadcast forces a switch to forward broadcast packets to all its interfaces. Intelligent switches can benefit from peeking at IGMP packets to know which interfaces multicast packets have to be forwarded to.
Broadcast cannot treepass a broadcast domain. Multicast packets can traverse a router, if it's configured to route multicast (search for M-bone)

New virtual network adapters being assigned randomly [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have a setup where I clone virtual machines, therefore changing their mac addresses.
When each machine boots up, it gets assigned to a Local Area Connection x interface.
I then run a batch script that changes the IPs of the interfaces:
netsh interface ip set address name="Local Area Connection 1" static 192.168.1.50 255.255.255.0 192.168.1.254
netsh interface ip set address name="Local Area Connection 2" static 172.16.5.50 255.255.255.0 172.16.5.254
The problem is that the adapters gets assigned randomly - the first NIC sometimes gets Local Area Connection 1 and sometimes Local Area Connection 2. Therefore I can't assign the IP addresses.
The NICs are ordered correctly by their MAC addresses. I've thought about getting the MAC addresses of the two active interfaces, sort them, and find out the assigned adapter names, and only then run netsh interface ip set, however I'm not sure how can I do it.
Any ideas?
I used the getmac util to get the MAC addresses along with their assigned connection names:
getmac /V /FO LIST
There is also a solution with Powershell:
http://www.ddls.net.au/blog/2012/08/renaming-network-connections-using-powershell-and-wmi/

simple server in C [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I created a simple TCP/IP server in c and it runs smoothly from my Linux machine. I can connect as localhost:80 as well as from different machines, but I obviously have to use the lab computer's IP.
My question is: how do I run a server form my own Mac OS X machine, let's say, and connect to it form outside? Not sure how to properly ask the question... how to assign a specific IP to my server? Sorry, I am still exploring this field!
Thanks!
If your local proxy or box is configured to allow entering connections, the easiest is to assign a fixed name that will be mapped to your (dynamic) IP.
There are a lot of dynamic DNS free solutions on the web (ex : http://www.no-ip.com/)
If you just want to make a one time test, you can see what IP you have with a service like this one : http://www.whatismyip.com/
All you need is a machine that has globally routable static ip address. And run your server on that machine.
Running it on your Mac laptop is okay but as you hop from one wifi network to other your server is no longer available.
Best way is to find a machine , a desktop in your lab or ar home connected to say comcast isp that has a static globally rout able ip and run your server on there.

Resources