simple Asterisk setup for LAN - asterisk

I have been going back and forth trying out wanting to find a way for a way to communicate via LAN / WiFi easily, and making a call via LAN network would be great, so i tried asterisk a few times and lost in the way, i cant seem make it work, and the e-book i purchased endorsed me to purchase a Digium hardwares to proceed, it's not possible for me to do so, i live halfway around the world from america and a day's flight from a big city.
I'm willing to learn, but it seems each time i went in it, i got lost somehow. i know basics of linux and virtualbox, but not too much though, and this asterisk felt it's still another level for me.
My question is, is it possible to use asterisk or asterisknow by digium without their hardwares if it's only for LAN usage ? is it even a viable thing to do ?

Of course it is possible.
All you need is one server and two sip phones, SW or HW to make them talk to each other.
so on the server where you installed asterisk set two peers in /etc/asterisk/sip.conf:
(this is just an example)
[101]
disallow=all
host=192.168.1.3 ; IP address of your first phone
;secret=101 ;uncomment if you want to use host=dynamic, less secure, use 'bigger' secret
type=friend
dtmfmode=rfc2833
allow=alaw
qualify=yes
canreinvite=yes
insecure=port
context=dial-local
[102]
disallow=all
host=192.168.1.4 ; IP address of your second phone
;secret=102 ;uncomment if you want to use host=dynamic, less secure, use 'bigger' secret
type=friend
dtmfmode=rfc2833
allow=alaw
qualify=yes
canreinvite=yes
insecure=port
context=dial-local
than in your /etc/asterisk/extensions.conf set context dial-local like:
[dial-local]
exten => _X.,1,n,Dial(SIP/${EXTEN})
Than you need to reload your new configurations from asteriskCLI> dialplan reload and sip relaod or execute in terminal:
asterisk -rx "dialplan reload";
asterisk -rx "sip reload";
all you need to do now is to register your 2 phone to server
You can chose from many free SW phone out there, I recommend 3CX for Win/Android and Linphone for Linux.
On the softphone all you need to configure is username (101 and 102), secret (101 and 102) and server IP (192.168.1.2 in this case).
Now start up server and both phones, and if you see them 'on hock', dial 102 or 101 :)

Your question is a bit difficult to understand, but I'll take a stab at it anyway. Yes, you can use Asterisk via LAN only if what you want to do is "desk to desk" calls. That is the entire concept behind Voice Over IP -- no need for traditional copper pair wires.
The two protocols you will want to look into most are SIP and IAX2. Check the links below for reading material you'll need to study up on.
https://en.wikipedia.org/wiki/Voice_over_IP
https://en.wikipedia.org/wiki/Session_Initiation_Protocol
https://en.wikipedia.org/wiki/IAX2
http://www.jkl5group.com/index.php?page=emg-vs-fud
http://www.rohitmenon.com/index.php/howto-connect-2-phones-and-make-a-simple-call-using-asterisk/
If you're familiar with "LAMP" server environments, you should have no serious difficulties in getting an Asterisk PBX set up and able to make a call between two SIP phones.
Good luck with it!

Asterisk is an open source project - you can run calls through it without paying Digium a penny. They offer great value extensions e.g. telephones, phone cards and asterisk turnkey systems - it is a balance between how much effort you wish to spend.
There are free sip providers out there too - so Asterisk + a SIP gateway + a SIP client will allow you to make and receive calls without spending a penny / cent!

Related

Real-world cross-platform decentralized asynchronous peer-to-peer communication

My knowledge about network programming is limited, so, all the comments are more than welcome. Essentially my question boils down to the following question:
Q1. Is there really such a thing as decentralized asynchronous cross-platform peer-to-peer communication?
Let me explain myself.
If we have two http servers running on computers with actual IP addresses, then clearly the answer is yes, assuming one writes a protocol for the interaction.
To go one step further, if one of them (or both) is (are) behind a router, then, with port forwarding the communication can still be established. However, here the problems start because if someone wants to run such a server on the background, say in a mobile phone, the app that is relying on this server really works when one is at home (we can not really expect to request port forwarding everywhere we go).
But even beyond that,
Q2. do mobile phones obtain an actual IP address from telecommunication companies when someone is not using a wi-fi?
If this is true, then clearly one can have cross-platform asynchronous peer-to-peer communication at the expense of not using wi-fi by running an http server on a smartphone. (I understand that this is not convenient, but it is certainly doable.)
Concluding, the two (perhaps there are more) relevant questions that I can think of are:
Q3. How does Skype really work?
Q4. How does Viber really work?
Based on the answer for Skype, it says: If one of the callee or both of them do not have a public IP, then they send voice traffic to another online Skype node over UDP or TCP.
So, it appears that there is no direct communication in Skype, because they have to use a man-in-the-middle for such a scenario.
Regarding Viber, I could not find a good-thorough answer to this particular question. Do people talk to each other through a Viber centralized server, or, do they establish a direct connection? Of course if they do establish a direct connection, then I really want to know how they manage such a thing since a mobile phone may or may not have a physical address. How is a Viber message routed to my cell phone from a friend of mine even when Viber is not running and I am behind a router?
I guess the answer to Viber is really push notifications, but as far as I can understand, all the variations of push notifications rely on open connections, and then the servers of the applications send the notifications to the clients through such connection(s). So, this approach gives us the feeling that it is asynchronous, but essentially it is not. We are cheating, in the sense that there is a constantly open connection to a server, and moreover, as far as I can understand, the application server has to push the notification through that server. Schematically:
A > Central App Server > Central Server w/ open connection to my cellphone > me
So, this seems to be once again a centralized approach.
Honestly, the only approach that I can think of that is both decentralized and asynchronous (on mobile phones as well) is to run an http server on every platform/device, but this comes at the expense of not using Wi-Fi and assuming that a telecommunication company really assigns a physical IP address to every mobile phone (which I do not know if it is true, do you?).
What about WASTE, darknets, F2Fs, etc? Do they offer advantages in the sense of a more direct asynchronous communication between some interested parties? Are there real-world applications (also including mobile phones) using such approaches for communication.
Really, this is not the actual problem that I would like to work on, but I would like to know what the state of the art is so that I can figure out how I can proceed from there. So, all comments are really more than welcome. If you have references for the state of the art I would like to know about them as well, but a brief description would also be nice.
I appreciate all your time and effort in advance.
You asked many questions, here is the beginning of the answers:
Q1: Yes. For example, take BitTorrent's very successful 10 million+ node network. Aside from the bootstrapping process, the protocol is entirely decentralized and asynchronous. See here for more info.
Q2: Yes! Go to www.whatismyip.com on your mobile telephone, and you will see your assigned IP. However, you are likely to be very filtered (e.g: incoming traffic on port 80 is likely to be blocked).
Q3: It has elements of P2P and clever tricks to get around NAT issues - see here for more info.
Q4: I don't know.

How to detect router?

I am trying to write a program that scan an ip range and detect if an ip is address of a router or not.
Currently i used traceroute from my computer to all host in the network. However, i believe there must be some way to directly "ask" a host at an ip if it is a router or not?
by the way, do you know any program/ opensource already does this?
Routers are supposed to talk couple of protocols (actually a neat bunch) that regular IP nodes do not, and then there are some which are more common (i.e. even non-router nodes do).
Router-only protocols:
VRRP
IGRP / EIGRP
OSPF
BGP
RIP
You could do active-probing on those, i.e. send a packet (behaving as if you are another router, or an end-node) and checking to see what kind of response the router (if at all) sends.
Alternatively you could do passive-probing, like 'sniffing', i.e. watching out for the kind of IP packets being sent out by various nodes. There are some which are usually sent out by Routers only (again, mostly from the above list).
Common protocol, but that can actually tell you a lot:
SNMP (esply the unsecure one's like v1/v2, are easy to deal with, without having to establish a secure session)
Other ways:
Portscanning (actually can tell you a real lot), for example all routers have some management ports (although, often they are locked down due to security concerns)
What you want to do is often what many 'Network Management' software do, to "discover" capabilities / functionality of other nodes in the network. And, there isn't a single size-fits all solution. They use bunch of different methods, heuristics to finally figure out what the other node is.
Any node which is hopped to and not just an endpoint is a router. However, this doesn't allow you to detect routers with no reachable devices hooked up. (Any input as to whether my answer has merit would be great!)

Scanning LAN game servers using winsock

I'm trying to figure out how to use winsockets to be able to turn my game into a LAN-playable game. I've read some winsockets documentation but I can't figure out how a client can get all the games that were created on LAN.
Does it have to try to 'connect' to each IP on LAN, like trying to connect to 192.168.0.1, then 192.168.0.2, etc? Is there a better way?
You would use broadcasting to advertise your servers on the LAN. Clients can then listen for these broadcasts to 'find' servers.
See here for more info:
http://tangentsoft.net/wskfaq/intermediate.html#broadcast
Typically these game servers use the local UDP broadcast, which is something that all clients receive and can process so long as they are listening to it.
Here is some sample client and server code I found that may be of interest to you: http://visual-c.itags.org/visual-c-c++/29424/
I think there are two possible ways to do this.
Make a "lobby" that clients and servers connect to so they can find each other through it.
Servers broadcast UDP packets. Clients listen and update a list of servers.
If you need a quick and easy way, the 2nd option would be great but remeber most of UDP packets will be wasted as they are used only once for each client.
The 1st option is more general and extensile solution to this problem. However, it might need more time to design and implement.
First off, I suggest that you get wireshark for any networking development. It will show you what packet goes through the wire. It will allow you to see how other games do it since there are many ways of doing this.
Using the UDP broadcast is one way of doing it. Simply change the target ip's last byte to 255 and you should be ok.

Asterisk & IVR & provider

I'm trying to setup an IVR or to be more specific an automated attendant using Asterisk. I don't want anything fancy besides the simple automated menu system, and instead of dialing an extension (for now) just ring the same phone line (POTS) if pressed 1 or play a recording if pressed 2. The server running Asterisk will be in a remote location.
My questions are:
Is this setup doable?
Do I need to sign up with a IAX VOIP
provider? (no VOIP calls will be
made/received) Only normal POTS calls will be made. (possible in other country)
What hardware do I
need? Remote server side and client-wise
(POTS phone line)
Any comments will be appreciate it.
Thanks
This is definitely doable, however, it seems that your specifications need to be modified a bit. Here are some things to consider:
What type of PSTN connectivity will your remote Asterisk server have? (SIP / POTS / T1 / PRI / etc.)
If your remote Asterisk server is going to be using a physical medium, do you have the connectors and hardware in place? EG: If you are using a T1 line, do you have a channel bank or T1 card?
Are you comfortable with Asterisk dialplan / AGI / AMI, or are you going to use an Asterisk distribution like trixbox, AsteriskNOW, Elastix, etc?
Will your client location (with the POTS line you wish to ring) have a PBX, or will it just be a typical POTS line hooked up to an analog handset?
My recommendation to you:
Get a cheap server (any 1U with a dual core processor and 512MB of RAM will do), and put it at your remote location.
Load Asterisk 1.6+ onto your server. I recommend 1.6+ as it can use the dahdi_dummy driver as a reliable software timing source (it will ensure that your audio quality is not choppy and broken).
Get a SIP account with a reliable SIP provider. My personal favorites are: flowroute and voipms.
Set up your new SIP account in Asterisk, and purchase a DID (phone number). This phone number will be your business phone number, the one that you give out to clients and put on business cards.
Configure your Asterisk dialplan to receive calls from your SIP account to your IVR menu.
Your IVR menu logic should be something like:
a. Play the IVR menu.
b. Wait for a keypress.
c. If the user dialed '1', then make an outgoing SIP call to the POTS line phone number you want to reach. If the user dialed '2', then playback the recorded message.
Now, if you are looking to save money, and have the most cost-effective setup for your remote IVR, I would recommend throwing up a second Asterisk server on site at your client location (where the POTS line comes in), and throw away the pots line and just setup an IAX2 trunk between your client location and your hosted server location. This way, when calls come in to your remote Asterisk server via your SIP provider, you can route the calls (when the user hits option 1) over your IAX2 trunk, directly to the client location for free!
Depending on your skill level, and comfort with Asterisk, this could be either a really fun learning experience or a confusing nightmare. If you would like to learn more about telephony and Asterisk, especially if you are going to use it for your business, you may want to use a simple (free) Asterisk distribution like: trixbox CE, Elastix, or AsteriskNOW.
You could code up a simple IVR in less time than it takes to install Asterisk if you use a hosted service like Twilio or Tropo. I'm partial to Twilio myself.
Edit: here's an example of a simple phone menu.
Quick answers to your simple questions:
this setup is doable.
no, IAX is not neccessary
some hardware setups are listed in wiki
I think you should start with wiki and free Asterisk book

P2P network games/apps: Good choice for a "battle.net"-like matching server

I'm making a network game (1v1) where in-game its p2p - no need for a game server.
However, for players to be able to "find each other", without the need to coordinate in another medium and enter IP addresses (similar to the modem days of network games), I need to have a coordination/matching server.
I can't use regular web hosting because:
The clients will communicate in UDP.
Therefore I'll need to do UDP Hole Punching to be able to go through the NAT
That would require the server to talk in UDP and know the client's IP and port
afaik with regular web hosting (php/etc) I can only get the client's IP address and can only communicate in TCP (HTTP).
Options I am currently considering:
Use a hosting solution where my program can accept UDP connection. (any recommendations?)
UDPonNAT seems to do this but uses GTalk and requires each client to have a GTalk account for this (which probably makes it an unsuitable solution)
Any ideas? Thanks :)
First, let me say that this is well out of my realm of expertise, but I found myself very interested, so I've been doing some searching and reading.
It seems that the most commonly prescribed solution for UDP NAT traversal is to use a STUN server. I did some quick searches to see if there are any companies that will just straight-up provide you with a STUN hosting solution, but if there even were any, they were buried in piles of ads for simple web hosting.
Fortunately, it seems there are several STUN servers that are already up and running and free for public use. There is a list of public STUN servers at voip-info.org.
In addition, there is plenty more information to be had if you explore SO questions tagged "nat".
I don't see any other choice than to have a dedicated server running your code. The other solutions you propose are, shall we say, less than optimal.
If you start small, virtual hosting will be fine. Costs are pretty minimal.
Rather than a full-blown dedicated server, you could just get a cheap shared hosting service and have the application interface with a PHP page, which in turn interfaces with a MySQL database backend.
For example, Lunarpages has a $3/month starter package that includes 5gb of space and 50gb of bandwidth. For something this simple, that's all you should need.
Then you just have your application poll the web page for the list of games, and submit a POST request in order to add their own game to the list.
Of course, this method requires learning PHP and MySQL if you don't already know them. And if you do it right, you can have the PHP page enter a sort of infinite loop to keep the connection open and just feed updates to the client, rather than polling the page every few seconds and wasting a lot of bandwidth. That's way outside the scope of this answer though.
Oh, and if you're looking for something absolutely free, search for a free PHP host. Those exist too! Even with an ad-supported host, your app could just grab the page and ignore the ads when you parse the list of games. I know that T35 used to be one of my favorites because their free plan doesn't track space or bandwidth (it limits the per-file size, to eliminate their service being used as a media share, but it shouldn't be a problem for PHP files). But of course, I think in the long run you'll be better off going with a paid host.
Edit: T35 also says "Free hosting allows 1 domain to be hosted, while paid offers unlimited domain hosting." So you can even just pay for a domain name and link it to them! I think in the short term, that's your best (cheapest) bet. Of course, this is all assuming you either know or are willing to learn PHP in order to make this happen. :)
There's nothing that every net connection will support. STUN is probably good, UPnP can work for this.
However, it's rumored that most firewalls can be enticed to pass almost anything through UDP port 53 (DNS). You might have to argue with the OS about your access to that port though.
Also, check out SIP, it's another protocol designed for this sort of thing. With the popularity of VOIP, there may be decent built-in support for this in more firewalls.
If you're really committed to UDP, you might also consider tunneling it over HTTP.
how about you break the problem into two parts - make a game matcher client (that is distinct from the game), which can communicate via http to your cheap/shared webhost. All gamers who wants to use the game matching function use this. THe game matcher client then launches the actual game with the correct parameters (IP, etc etc) after obtaining the info from your server.
The game will then use the standard way to UDP punch thru NAT, etc etc, as per your network code. The game dont actually need to know anything about the matcher client or matcher server - in the true sense of p2p (like torrents, once you can obtain your peer's IPs, you can even disconnect from the tracker).
That way, your problems become smaller.
An intermediate solution between hosting your own dedicated server and a strictly P2P networking environment is the gnutella model. In that model, there are superpeers that act like local servers, having known IP addresses and being connected to (and thus having knowledge of) more clients than a typical peer. This still requires you to run at least one superpeer yourself, but it gives you the option to let other people run their own superpeers.

Resources