Unable to establish calls with Freeswitch sometimes - sip

I am making video calls from Linphone to linphone on android.Both the mobile apps are successfully registered on Freeswitch server.
But when i make a call it does't get established.It is happening randomly only.When i checked dump on server i found that Freeswitch keeps sending Invite on B leg side but does't get any response for invite.There are also multiple sip uri's in invite.
Can somebody help me with this?
Is there anything related to server configuration?
Thanks

It's frequent, call over UDP doesn't work.
Try with TCP and normally it's must work correctly.
For more information about the difference between TCP and UDP look at:
https://stackoverflow.com/a/5970545/7131120

Related

OpenSIPs + MediaProxy: Cant receive call on 3G

I have a SIP Server running OpenSIPs 1.11.3
configured with built-in STUN module (full mode with 2 IPs)
configured with MediaProxy 2.6.1 to relay RTP (using engage_media_proxy in routing script)
Using IMSDroid from doubango as the SIP client.
Calls between wifi-wifi is good, I do not need to turn on any STUN, ICE, TURN option in the client.
However, calls between 3g-wifi or 3g-3g isn't that good. 3G can make outgoing call but it cannot receive call. Which means 3g-3g call can NEVER happen. All I see in the OpenSIPs logs are repeated retransmissions of INVITE because it cannot reach the 3G side.
I read that TURN server can solve this kind of problem, so I enabled TURN in IMSDroid sip client, but still 3G side cannot receive any call.
The TURN server I am using:
url: 'turn:numb.viagenie.ca'
credential: 'muazkh'
username: 'webrtc#live.com'
Is there any solution / module I can use to solve this problem?
EDIT:
If I use TCP protocol, I am able to receive call! Although the call terminate due to transport error after 30 seconds, but at least the call went through. Any idea what happen here?? Mobile carrier blocking incoming call? But definitely not port blocking because I am able to register whether I use port 80 or 5060.
EDIT 2:
I tried using free SIP accounts to make calls (sip2sip.info and sip.antisip.com), and I have the same problem too! As I know, sip2sip.info is using OpenSIPS too but AntiSip.com is using something like AmSIP. So the problem is with my mobile carrier?
Thank you!
If your UA can't receive calls, it means it is not reachable for signaling. In order for your UA to be reachable, it needs to register and keep the NAT mappings alive. To keep a NAT mapping alive, your UA must send keepalive to the server periodically. Another option is that the server sends keepalives to the UA but some NATs don't refresh mappings for incoming traffic.
When you solve this first issue, comes the media part where technologies like STUN, TURN and ICE will help.

Listen to disconnections of tcp clients in Google Chrome app

In the documentation for chrome.sockets.tcpServer and chrome.sockets.tcp there is nowhere mentioned how to listen to disconnection of clients. How can I do it?
I found out that you get a resultCode == -15 in the callback of the chrome.sockets.tcp.send-function if the client was disconnected. But I really want to get notified if someone disconnects instead of use only the pro-active method of checking that.
It's my understanding that socket disconnection isn't something the underlying OS can detect. There's no socket-level way to tell the difference between a client that is gone and a client that might simply be taking a while to send the next packet. It's possible someone with deeper TCP/IP knowledge will correct me, but this is always the answer I've seen.
You can have clients send an application-level disconnect message, or else a periodic heartbeat without which the server will conclude the client is gone. More detail here: Is TCP Keepalive the only mechanism to determine a broken link?
I thought chrome.sockets gave you an onReceived event with byteLength 0 packet which means they disconnect, right? I mean that's how I would gracefully disconnect, send a payload with 0 bytes.

should I be using sockets or packet capture? perl

I'm trying to spec out the foundations for a server application who's purpose will be to..
1 'receive' tcp and/or udp packets
2 interpret the contents (i.e. header values)
To add more detail, this server will receive 'sip invites' and respond with a '302 redirect'.
I have experience with Net::Pcap and perl, and know I could achieve this by looping for filtered packets, decoding and then using something like Net::SIP to respond.
However, there's a lot of bloat in both of these modules/applications I don't need. The server will be under heavy load, and if I run TCPDUMP on it's own, it loses packets in the kernel due to server load, so worry it wont be appropriate :(
Should I be able to achieve the same thing by 'listening' on a socket (using IO::Socket for example) and decoding a packet?
Unfortunatly by debugging, it's hard to tell if IO::Socket will give me the opportunity to see a raw packet? And instead it automatically decodes the message to a readable format!
tl;dr: I want to capture lots of SIP Invites, analyse the head values, and respond with a SIP 302 redirect. Is there a better way than using tcpdump (via Net::Pcap) to achieve this?
Thanks,
Moose
Is there a better way than using tcpdump (via Net::Pcap) to achieve this?
Yes. Using libpcap (that's what you meant instead of tcpdump in that question) is a bad way to implement a TCP-based service, as you will have to reimplement much of TCP yourself (libpcap gives you raw network-layer packets), and the packets your program gets will also get delivered to the Internet protocol stack on your machine, so:
if there's nothing on your machine listening on the TCP port to which the other machines are trying to connect, the connection requests will get a RST from the TCP code and think the connection attempt failed;
if there is something on your machine listening on that port, it'll probably accept the connection, and it and your program will both try to communicate with the other machine, which will probably confuse its TCP stack and cause various bad and random things to happen.
It's not much better for UDP:
if there's nothing on your machine listening on the UDP port to which the other machines are trying to connect, the connection requests will probably get an ICMP Port Unreachable message from the UDP code, which may make it think the connection attempt failed;
if there is something on your machine listening on that port, it'll probably accept the connection, and it and your program will both try to communicate with the other machine, which will probably confuse its SIP stack and cause various bad and random things to happen.
IO:Socket will probably not give you raw packets, and that's a good thing; you won't have to implement your own IP and TCP/UDP stack. If your goal is to implement a redirect server on your machine, you have no need to receive raw packets; you want to receive SIP INVITEs with all the lower-level processing done for you by your machine's IP/TCP/UDP stack.
If you already have a SIP implementation on your machine, and you want to act as a "firewall" for it, so that, for some INVITEs, you send back a 302 redirect and prevent the SIP implementation on your machine from ever seeing the INVITEs in question, you will need to use the same mechanism that your particular OS uses to implement firewalls. There is no libpcap-like wrapper for those mechanisms, as far as I know.

ARP Requests on iPhone

I'm trying to generate ARP (Address Resolution Protocol) request packets on the iPhone and listen for the associated responses that come back.
Google searches have led me into a dead-end. In order to send logical-layer packets, I'd need something along the lines of a raw socket, but need super-user permissions to create them. I'm trying to avoid jailbreaking my phone.
There's lots of c code out there that can do this, but I can't find anything that can translate to iOS due to the permissions.
I was ready to throw in the towel when I decided to Wireshark a couple network discovery apps I have. Namely "Fing" and "Pinggy" (hats off to Fing and Pinggy btw... awesome apps!)
https://itunes.apple.com/us/app/pinggy/id562201096?mt=8
https://itunes.apple.com/us/app/fing-network-scanner/id430921107?mt=8
Running Wireshark alongside these iPhone apps shows that they do an ARP scan from XXX.XXX.X.0 all the way to XXX.XXX.X.255. I do not see any ICMP packets go out simultaneously with the "ARPs". This leads me to believe that sending and receiving ARP packets are indeed possible on iOS.
I've thought about a ping sweep, assuming that it will generate ARP requests on its own. However, I will still need a raw socket to listen to the responses, correct?
Questions: What's available for sending/receiving packets at the logical layer? Specifically for sending receiving ARP packets? Am I missing anything fundamental?
Thanks in advance!
ARP requests do go out when I attempted to ping the problematic devices. This was seen with a Wireshark session running alongside the ping scanner. I found that I could not reproduce the "missing devices" I was seeing earlier that led me to ask my original question.
So, to answer my own question: ARP requests are sent per IP address when doing a simple ping scan on my subnet. I would see the ARP request go out (using Wireshark) as well as the ping request. If you need to generate an ARP request, simply send out a ping.
Even if the "problematic" device won't respond to ping requests, the ARP table will be notified of its existence.
You can't do what you want to do, and get the app in the AppStore,
since what you are trying to do isn't in the public API.
So one thing you could do, for testing purposes on your own network, or enterprise distributed apps is looking in the private/undocumented APIs.
One such list is maintained at https://github.com/nst/iOS-Runtime-Headers, but I can't vouch for its accuracy.
Good luck!

How to listen on a network port in Objective-C

I am trying to make an application for iPhone that can listen for traffick on a specific network port.
A server on my network is sending out messages (different status messages for devices the server handles) on a specific port.
My problem is that when I make a thread and makePairWithSocket I block the port for others who want to send messages to the server, so I only want to listen to the traffic on a specifyed port and then check for specific heraders and then use those messages.
I know how to make the connection and talk to the server using write and read streams, but then I makePairWithSocket and block the port for all other devices on the network
Any one that has any suggestions on how to listen on a port in Objective-C without pairing with the server?
Thanks in advance
Daniel
Check out CocoaAsyncSocket. It gives you a nice and structured way (with delegates) to send and receive data... also with multiple clients. The documentation is quite good. project link
edit: Have a look at the AsyncUdpSocket class for a stateless UDP connection.
I think this requires network support well below the socket API level, perhaps at the hardware driver level, assuming the packets are even being routed to your device.