|
|
Comments and Discussions
|
|
 |

|
The servers won't accept my request unless the time out is set to max. And then the server times out my connection. Any suggestions?
|
|
|
|

|
Hi,
First try different STUN server, see if it does same.
Then you you can try different computer.
Once you see what causes it, you can debug more easely.
|
|
|
|

|
i want this coding in ios can u provide source code for this c/C++ library
|
|
|
|

|
Sorry no c++ code available, you should google for some c++ version of STUN.
|
|
|
|

|
Really makes a 'UDP hole punch' solution much easier.
|
|
|
|

|
Hi
Thanks for writing a very good article on Stun client.
I get the public ip and port using your code, but i don't understand yet how to connect with other machine.
can i use the returned socket from stun to coonect with other machine or i have to do something else ?
Pls help me
Thanks in advance
|
|
|
|

|
Hi,
Stun not related to remote computer or connecting. Stun kust gets your computer public ip:port.
|
|
|
|

|
Hey I am facing same problem.If any body tell how to connect to machine one you get public IP address.
|
|
|
|

|
As said STUN not related to connecting. So connecting is as normal TCP or UDP connecting.
Normally you can connect UDP only, because for TRCP remote host must have port forwarding.
|
|
|
|

|
Hello,
STUN only helps you to determine your own public IP and UDP port. To connect clients directly via UDP you need 'UDP hole punching'. The best article I found on this is here: http://www.brynosaurus.com/pub/net/p2pnat/
No matter what, you'll additionally need a rendezvous server, which assists in establishing a direct connection between to UPD clients. However, the public STUN servers are still very helpful. In my case I have a hosted website, where I can deploy HTTP web services. However, I cannot connect to the web server via UDP. So the solution is that clients use a public STUN server to determine their public IP and UDP port, then use an HTTP-based web service to transmit rendezvous information (public IP and port), and finally connect to each other directly via UDP again using the UDP hole punching technique.
Hope this helps, Christoph
|
|
|
|

|
Hi,
Another option is to use UPnP to open router ports, in case of router has UPnP enabled.
Then UDP/TCP communication possible.
|
|
|
|

|
Thanks for the nice article.
few seconds after I run the client ,the internet connection disconnects.
I am connected with adsl modem through windows xp firewall.
Do you have any idea why this happens?
thanks
|
|
|
|

|
Hi,
Dont know, so far havent got any troubles.
I suspect that your router had buggy firmware. Some time ago some zyxel ruoters rebooted on some http sites for example.
|
|
|
|

|
Dear sir,
Your post is great but do you have any ideal about WCF? Does anyone know how to make this work with WCF?
|
|
|
|

|
Hi,
It should run on CF or then need only minmal changes.
|
|
|
|

|
Thanks for quick ans!
Could you please explain more about this and how to use it with WCF?
I've looked for this solution in a long time and really need this!
|
|
|
|

|
If you just need stun, it probably wiser to compile to new dll.
I dont see what your problems using in CF, odes it use some method what isnt supported in CF ?
|
|
|
|

|
My problems is that when i've got a global & local mapped address and the next step is to open a communication channel, but i don't know how to do it! Could you please give me a simple example of message transfer between node through STUN?
|
|
|
|
|

|
Check out my answer under 'How i connect to remote machine using Stun'. You'll have to figure out how to use UDP under WCF and use the hole punching technique to make it work. STUN only helps you to find out the necessary info, public IP and port, to do hole punching. You'll also need an additional rendezvous server.
Christoph
|
|
|
|

|
I was unable to build the release configuration on Windows XP machine. Can someone post Windows XP executable of STUN Client?
|
|
|
|

|
Hi,
I tried testing your code with the folowing servers:
stun.xten.net it gives me RestrictedCone while it should give FullCone.
stunserver.org give me FullCone
jstun.javawi.de it gives udpblocked
how can I know assure it is working properly? normally it gives me
|
|
|
|

|
Hi,
It only can depend on server answers, because STUN packets should be always same.
|
|
|
|

|
I tried testing with JSTUN client, it gives the expected result in terms of response FullCone, RestrictedCone.. But it does not give the IP address and the mapped port. May be there is problem with the flow of the algorithm implemented in your client?
|
|
|
|

|
Does jstun gives different results for same LAN with diferent stun servers ?
|
|
|
|

|
Hi,
would this project work fine if I try to recompile for compact framework ?if not what modifications do I need. I understand that the forms are not the same since WM5 is based on WinCE but would the client work fine?
|
|
|
|

|
Hi,
STUN client must work, at first look it doesnt uses classes what CF wont support.
|
|
|
|

|
The NAT server only let us know about our server-side ip and port. But when each peer know its server-side ip and port, they need to send that information to each other, right ? And they cannot send directly to each other, so do u know any server do that (we can connect to that server, send our information, and server send that information to the other peer...) ?
Thank you very much !
|
|
|
|

|
I have STUN server and running the stun client demo program from outside the firewall. I get the NAT type as UdpBlocked but I have Wireshark running on the firewall machine and it shows UDP is transmitted. What do you think the problem? Thanks for the excellent program
|
|
|
|

|
Transmited won't mean not blocked, like response packet never reaches, so firewall wont allow resonses back from server.
|
|
|
|

|
I want to make a file transfer program using STUN to pass through NAT, but I think UDP protocol isn't suitable for this, right ? And I can't find any STUN for TCP. So do you have any suggestion for me ? Do I have to build a protcol like TCP based on UDP ???
Thanks.
|
|
|
|

|
TCP cant be used behind NAT ....
You must use UDP. The only way it packetize file in to UDP chunks and add checksum for each chunk. SO you only need to make some logixc what keeps track what chucks not reaced ant retransmit them. md5 chek sum quarrantees that chunk data not corrupt.
|
|
|
|

|
Hi,
I want to transfer audio and text to the clients over the internet,with STUN can it make this for me to do port mapping behind a LAN between two machines ?
Thank you.
Bigbermusa
|
|
|
|

|
Hi,
Yes, thats the main usage of STUN.
|
|
|
|

|
OK,thanks.
Can it also support for sending/receiving video packet ?
How long that stunserver will be site situation on the net ?
Thanks,
Bermusa
|
|
|
|

|
>Can it also support for sending/receiving video packet ?
Seems you have get wrong idea about stun. stun is just for discovering pubic ip and port of NAT behind IP endpoint.
Most common video transport is RTP.
>How long that stunserver will be site situation on the net ?
I think if you reread your question, then even you dont get what you mean by this.
|
|
|
|

|
Ivar Lumi wrote: >Can it also support for sending/receiving video packet ?
Seems you have get wrong idea about stun. stun is just for discovering pubic ip and port of NAT behind IP endpoint.
Most common video transport is RTP.
OK,i see,but let me ask you that if port of NAT is discovered and mapped by stun,can i use it to transport video stream over the internet ?
If i'm wrong understanding,please suggest.
Thanks,
Bigbermusa
|
|
|
|

|
Theoretically you can when both computers start sending data each other. Otherwise NAT won't pe opened !!!
Normally some kind of signalling protocol is used to setup session. For example voip phones use SIP + SDP for that.
|
|
|
|

|
That's mean only port mapping by stun but NAT won't be opened to point correctly,like you said.
Is it right ?
|
|
|
|

|
NAT is opened(only for remote target) after you send out initial request to target.
And from there: if both endpoints behind NAT, both must send data to each other to make actual data flow.
(computerA - NAT - INTERNET - NAT - computerB)
|
|
|
|

|
Let me know again,if stun client run on both that mean they're the remote target where NAT is also opened by stun for each remote (that's incoming host)after that if they need to communicate both must send data ie. external ip and port to each other then they can make actual data flow on the network.
Is i right understanding ?
Thanks,
Bigbermusa
|
|
|
|

|
stun is not related to data sending.
For example if you know your remote end point and remote end poiny knows yours, you both start sending, then NAT opened.
For example you make stun request what happens ony:
yourStunRequest -> NAT(nat is opened for stun server response) -> STUN
Sedning data by alone, data bever reaches, remote NAT holds it.
yourData -> NAT(nat opened for remote end point only) -> NAT --- xxxx remote
But if both send, then both nats will open.
|
|
|
|

|
Ok,that mean stun make a road or bridge for my data communication if both send to each other and NAT is ok ,right ?
|
|
|
|
|
|

|
Section:
Nice work, but you made a little mistake regarding the retransmit time.
9.3 Formulating the Binding Request
Clients SHOULD
retransmit the request starting with an interval of 100ms, doubling
every retransmit until the interval reaches 1.6s. Retransmissions
continue with intervals of 1.6s until a response is received, or a
total of 9 requests have been sent. If no response is received by 1.6
seconds after the last request has been sent, the client SHOULD
consider the transaction to have failed. In other words, requests
would be sent at times 0ms, 100ms, 300ms, 700ms, 1500ms, 3100ms,
4700ms, 6300ms, and 7900ms. At 9500ms
Here is my proposal:
private static STUN_Message DoTransaction(STUN_Message request,Socket socket,IPEndPoint remoteEndPoint)
{
byte[] requestBytes = request.ToByteData();
// Retransmition table : 9500ms sound that the transaction has failed
int[] retransList = { 0, 100, 300, 700, 1500, 3100, 4700, 6300, 7900, 9500 };
int retransPos = 0;
DateTime startTime = DateTime.Now;
// We do it only 2 sec and retransmit with 100 ms.
while (retransPos < retransList.Length)
{
TimeSpan diffTime = DateTime.Now - startTime;
try
{
if (diffTime.TotalMilliseconds > retransList[retransPos])
{
// It's time for a retransmition
retransPos++;
socket.SendTo(requestBytes, remoteEndPoint);
}
// We got response.
if (socket.Poll(20, SelectMode.SelectRead))
{
byte[] receiveBuffer = new byte[512];
socket.Receive(receiveBuffer);
// Parse message
STUN_Message response = new STUN_Message();
response.Parse(receiveBuffer);
// Check that transaction ID matches or not response what we want.
if (request.TransactionID.Equals(response.TransactionID))
{
return response;
}
}
}
catch(Exception exception)
{
Console.WriteLine("Exception : " + exception.Message);
exception = null;
}
}
// Timeout detected or exception
return null;
}
|
|
|
|

|
Hi,
Thats not typo, thats simplified solution.
Normally retransit wont happend in reallife, so if you retransmit 200mx,200ms , ... i dont see any problem about that.
But though it's not 100% RFC comilant ... .
Your approach is almost RFC comiplant, but if to splitting hair- -- except:
If no response is received by 1.6
seconds after the last request has been sent, the client SHOULD
consider the transaction to have failed.
|
|
|
|

|
Ivar, you're very good with all these protocols. Great code!
I would like to use your STUN Client in combination with the Microsoft RealTime Communications (RTC) API, because I'm working on a VoIP applicaton. This RTC API provides a number of hooks for plugging in some kind of portmapping functionality.
I found out that, with the help of your STUN Client class, I can create the required portmappings. But the RTC code doesn't seem to be able to use the mapped ports.
The reason could be that I create a socket, which I handover to your STUN Client to get the mapped address and port, but which I have to close before returning the control to the RTC code. Otherwise the RTC code generates an error (which I can understand, since it tries to open a socket on an address and port where another one is open already).
But could it be that the portmapping, created by your STUN Client, is removed from the NAT, the moment I close the socket that I used for creating the portmapping (by calling your STUN Client)?
modified on Sunday, February 17, 2008 2:09 AM
|
|
|
|

|
Hi,
Bat keeps same port, if you close socket and re create it, as long as you use same IP endpoint for socket.
|
|
|
|

|
i cannot run net.sln why?
i already install microsoft C# 2008 but still failed
please any advice
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
STUN client C# implementation with sample application
| Type | Article |
| Licence | CPOL |
| First Posted | 20 Apr 2007 |
| Views | 94,896 |
| Downloads | 4,196 |
| Bookmarked | 52 times |
|
|