How to send a packet from device A, but make it seem as if the packet came from device B? - packet

I have two devices on my Wifi, a laptop running windows 7, 32-bit, and an iPhone 6 plus. How can I send a packet from my laptop to a target, but make it look as if (from the targets view) that the iPhone sent the packet? If I am wrong about how the packet system works, could you please point out my mistakes? Also, if this is on the wrong site, please point that out and I will fix it.
Thanks in advance

Related

HTC One with java.net.Socket stuck in DataInputStream.read when on HSDPA. Work fine on 3G and Wifi

It's on Android. I have a chat tool that sends/receives packets. On the client side I parse the packets and display the message to users. A traditional chatting tool.
The problem is the tool works quite well on other devices on wifi, Edge and 3G, except the HTC One. On HSDPA (3G) we notice that the client cannot receive the packets as usual. It's stuck there until we reset the socket.
I debug and found that the DataInputStream.read() method (in the while loop to listen to the incoming data) is stuck there. I attached Android source to go deeper but not until the java.libcore package of Oracle.
I guess the issue is because of the Sleep mode of the HTC One. But on foreground, the app cannot receive the message too, until we open a new socket (with a long timeout, about 4 minutes, which is too long for a chatting tool).
As I researched, I try to install the SmartSync Disabler for HTC and the situation seems to be better. When I decompile the tool, it only sets 2 parameters: sleep_mode_mode to off and data_on_wifi to off, which means on the sleep mode, SmartSync does not disconnect wifi.
My question is has anyone encountered this situation before on HTC One in particular? What could be the reason?
Many thanks!
We have just got the same problem.
Try to play with this methods
void setReceiveBufferSize(int size)
void setSendBufferSize(int size)
I.e. make it much smaller.

How do I detect iPhone on network?

I am trying to detect if my iPhone is in the same network as my Raspberry Pi. I would like to execute a script when I am at home and my iPhone's presence is registered in my LAN.
It seems that when the phone is in standby not even the iphone-sync port (6207/tcp) is found. "/usr/bin/nmap -n -sT -p62078 [my phone's local IP]" shows no host. I wonder what else I could scan for. Obviously the phone is online and ready to accept facetime calls (data via 3G is deactivated). Could I accomplish something with avahi which I am using on my Raspberry Pi, or are there other ways.
I've just spent a week beating on this problem so I can refrain from sending SMS home alarms to my wife when she's at work.
Pinging won't work because the iPhone won't respond to ICMP when asleep. Reading the ARP cache won't work because a sleeping iPhone will come and go (check it every 30 seconds for a few minutes).
The only way I have found to 'reliably' determine when my two iPhones are on my local (home) network is to use the PCAP dotnet library to look for any packets originating from either of the phones' MAC addresses. For example, if you run Wireshark with the capture filter
ether src <iphone-mac-address>
you will see a surprising amount of network discovery/announcement traffic from the phone. It still has quiescent states, but so far the longest interval I have seen between captured packets is around 10 minutes. You would have to wait until you have not heard from the phone for some interval (I use 15 minutes) before declaring it not-home.
With this technique you will find a phone quickly when it rejoins the home network, assuming your phone is configured for DHCP. I also use port mirroring on my main Ethernet switch to include traffic from my wireless access points.
I don't have a Raspberry Pi solution for this, because my linux expertise is very limited, but someone else may be able to help you along those lines. I have a Windows Service using the PCAP library and so far it works reliably, with the limitation of waiting 15 minutes before deciding an iPhone has left the network.
* update 2-3-2018 *
I have this detection algorithm down to about 5 minutes, using a combination of ping/arp messages directed to each phone, about once per minute. Seems to work great.
You can find a list of devices on your network by investigating your arp cache.
arp -a
Simply write a bash script to run arp -a at a regular interval, and search for the mac address of your phone.
You could go even further with this and perform different actions depending on what brand of device is connected.
The first 3 hexadecimal digits of a mac address are the vendor id.
Take the following mac address:
00:19:E3:AB:CD:EF
00:19:E3: is one of the registered mac address for apple devices.
By comparing the devices on your network with this list, you could detect when for example a '3com' device, or a 'dell' device attaches to your network.
http://www.coffer.com/mac_find/?string=apple
You can do "arp-scan -l -r10" for that (tested this myself), but the problem is if mobile data enabled the iphone will go and suspend wifi if screen is locked to safe battery. so you need to disable mobile data .. then arp-scan will work.

Ethernet connection to iPhone simulator

I am trying to make a program that receives UDP data on a port that the user can choose. For this i am using asyncUdpSocket.
I could not find it but i believe there is a way to send data from your mac to the simulator. Can anybody tell me how to do this?
Thanks!
It seems that you can just call the simulator on the ip adress of the mac you are running on.
Sorry for bothering everybody.

PJSIP. Outgoing call cut off at 20 sec at certain Wi-Fi networks

What steps will reproduce the problem?
Startup application with PJSIP at iPhone 3G with iOS 4.
Make outgoing call. Start conversation.
Wait 20 seconds.
What is the expected output? What do you see instead?
Actual result: Outgoing call cut off at 20 sec. The call breaks on the phone on which I have called. And the call ends normally according to the log-file.
What version of the product are you using? On what operating system?
I use iPhone 3g with iOS 4, iPhone 2g with iOS 3, iPhone 3gs with iOS 4, iPhone 4 with iOS 4
I tried to use PJSIP 1.0.3, PJSIP 1.6, PJSIP 1.7
I have tried another sip clients at this Wi-Fi network:
Fring - the problem reproduce
Nimbuzz - the problem NOT reproduce
Please help me to solve this problem.
Sounds like you need a keepalive mechanism on the SIP connection. PJSIP supports this. Maybe you will have to enable it.
Use a packet sniffer to see what is actually going on.
You'll probably have more luck at SuperUser. Having said that, if one SIP client doesn't have this problem, while the other does, your first step should be to look at what's different between working and non-working clients.
When you say the call cuts off do you mean that media just stops flowing? Does something send you a BYE? (If the media stops flowing, and you terminate your end of the call, does the BYE go out and do you get a 200 OK back?)
Is it possible to use something like Wireshark on the far side of your wireless access point? In other words, can you see media traffic on the first hop past the Wifi network? When the call's cut off, what do you see?

Debugging an iOS app with an external accessory connected via Dock

Am I missing something glaringly obvious or is there no way to debug an iOS app which uses an external accessory that's connected via the 30-pin dock without using a bucket load of logs etc. I want to be able to use things such as breakpoints and Instruments.
Is there a way to remote debug perhaps, over Wi-Fi, Bluetooth?
Note: Yes, I asked this very recently and I deleted it because I thought I found the answer.. but the answer was only Instruments has support over Wi-Fi.. not Xcode debugging. So the question still remains...
And so...: Given that I've had no real luck finding the answer, and no one has given me an answer as yet - I take it that it is a big fat NO. :(
Makes me wonder are we just expected to magically guess where bugs occur, or log the crap out of everything while wearing out our dock connectors by continuously moving it back and forth between the device and accessory?
Time to file a bug report I guess.
At CES today, I talked to a developer from Wahoo Fitness that makes an ANT+ accessory for iPhone. They had this same problem, but found a solution.
They found a pass-through dock extender that has a mini-USB port. They used the mini-USB port for debugging while the accessory was connected.
The product they were using is http://www.cablejive.com/products/dockStubz.html
This blog talks about remote debugging iOS with a dock accessory attached
You could connect the external accessory to another iOS device (not the one tethered to the Mac running the Xcode debugger). Then tunnel all your EA framework messages from the accessory connected device to the device running the app being debugged over a pair of wifi sockets. Look at the code for tunneling accelerometer messages from a device to the iOS Simulator (a common trick for debugging game code on the Simulator) for one example of how this could be done.
After further researching, and having seen that people had to do sending strings over Wi-Fi to get around this, I'm concluding the answer is no.
I have filed a bug request for this.
In the mean time, it seems like the Wi-Fi logging, and on-device text logging will be the way to go for now.
Here's my understanding for why just the USB protocol works for some external accessories and doesn't for other external accessories. Looks like a fundamental problem, without an arbitrator, two masters can't talk to a single slave over USB, a serial Master/Slave protocol. So XCode is one master, the iPhone is the slave device. If the external accessory is a master too, one won't be able to connect the iPhone (Xcode slave) to the second master (the external accessory).
Probably the Wahoo Key for iPhone" is a slave device and that's why the dockStubz solution works for such an external accessory.
I have tested the dockStubz. It doesn't work for my external accessory. As suspected, the USB protocol can't be used to have two Master devices controlling a single slave device. Trying to hook up a Mac (Master) (via the mini USB ) & an external accessory (Master) (via the 30 pin connector) to the iPhone 4 (Slave) causes the iPhone to go in loop of connect & re-connect.
Following looks promising too, though expensive: digi.com/support/kbase/kbaseresultdetl.jsp?id=485.
Has any one tried to use USB to Ethernet connectors and use a router to route requests from two masters (XCode & External Accessory) to the slave (iPhone)? I am off to Best Buy to purchase USB to Ethernet cables and hook all three on to my IP router. Will report if it works.
This is what will be needed :
http://www.bestbuy.com/site/IOGEAR+-+USB+Ethernet+Extender/9614781.p?id=1218131339965&skuId=9614781&st=USB%20to%20Ethernet&cp=1&lp=1
http://www.frys.com/product/6103339
So connect XCode mac using the male end into the USB slot of your computer. . Use a ethernet cable to connect this to a router.
Connect the iPhone to the female part of the IO gear connector. Connect it to the router via ethernet cable.
Connect the external accessory with the male connector (Sabrent USB to Fast Ethernet Network Adapter.) Connect it to router.
I am still researching if this will work. Just ordered the parts. Will get it by Friday & will report back then.
Update:
The IOGear male end draws too much current when connected to router. Also, the female end can't charge iPhone when connected to the router even when 5V USB current supplied.
So tried to directly connect the iPhone to the USB slot of the router (used for printers). It does charge the iPhone. Also used USB to Fast Ethernet Network Adapter (BestBuy had one to connect Wii via USB) to connect the Mac to the router. It did connect to internet but couldn't find the iPhone. In the router client list I don't see any login entires for the iPhone. So this experiment was a failure unless someone have other pointers.