|
|
Comments and Discussions
|
|
 |

|
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
|
|
|
|

|
Hi,
This is standard soulution, so it must work nice with VS 2008 and 2005
|
|
|
|

|
i'm sorry it's not cannot run actually cannot open it
why?
|
|
|
|

|
I don't know to suggest something. There must be something wrong with your VS installation.
|
|
|
|

|
hye...i have a problem..my UDP Server-Client only work on LAN environment but not on WAN..can i apply this STUN concept to solve my problem...coz on WAN the receiver cannot receive anything from the sender..please help me..i already run out of idea..tq
|
|
|
|

|
Hi,
Yes you can use STUN to get public IP:port.
|
|
|
|

|
mmmm...i'm sorry but how can i apply this STUN concept to my project..plz help me..this is my receiver source code..
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
aa = IPAddress.Parse(ip.Text)
SocketNO = Val(portno.Text)
RemoteIpEndPoint = New System.Net.IPEndPoint(aa, SocketNO)
Me.Show()
Public Sub ReceiveMessages()
On Error Resume Next
'Try
receivingUdpClient.Connect(RemoteIpEndPoint)
receiveBytes = receivingUdpClient.Receive(RemoteIpEndPoint)
'txtIP.Text = RemoteIpEndPoint.Address.ToString
tmp = Encoding.ASCII.Unicode.GetChars(receiveBytes)
test.Text = tmp
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
If method = "UDP" Then
Timer1.Enabled = False
ReceiveMessages()
Timer1.Enabled = True
End If
End Sub
Dim mystreamReader As StreamReader
Dim udpClient As New UdpClient
Dim arBlocks() As String
mystreamReader = File.OpenText("C:\Documents and Settings\Administrator\Desktop\SIMPLEMASA\SIMPLEMASA\ipadress.txt")
arBlocks = Split(mystreamReader.ReadToEnd(), vbCrLf)
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(Msg.Text)
udpClient.Send(sendBytes, sendBytes.Length, arBlocks(0), 11000)
udpClient.Close()
End Sub
|
|
|
|

|
i saw the code of stun client.It's so valuable.
i have a difficulty of finding the of turn client and server which is another way to traverse nat.so i would to know could you help me?or do you know where can i find such code?Thank you very much.
|
|
|
|

|
Hi,
I dont get what you mean, probably you dont too if you read your text.
|
|
|
|

|
sorry,my english is poor.I mean that I want to know could you help me to find the code about TURN client or TURN server.And thank you very much.
|
|
|
|

|
I dont have turn code, only STUN.
|
|
|
|

|
I dont use c# but i am looking for this client program. I downloaded but i cant find any executable file to run. Can anyone send me an executable file??. My email is hoanglinh9466@yahoo.com. Thanks a lot.
|
|
|
|

|
Hi,
Just downloaded zip, all there, example application binary also there.
|
|
|
|

|
Thanks, I found it. It show "UdpBlocked", i 've tried some other server such as stun.xten.com, stun.fwd.org, stun.voipbuster.com, stun01.sipphone.com... but it always show "udpblocked". I also go to http://sourceforge.net/projects/stun/ to get the stun client but it still show: "blocked or could not reach stun server". Do you know why ???
|
|
|
|

|
Yes i know, the mysterious thing causing it is called "firewll"
|
|
|
|

|
Can you explain more clearly ? This is a normal UDP transportation with a server, why firewall block this ??? And what must i do to work with stun ?
|
|
|
|

|
>why firewall block this ???
You shuld ask it from your administrator ...
It can be router firewall or windows software fire wall, it depends what conf you have, one thing is sure that firewall block UDP.
|
|
|
|

|
I turned off my computer's firewall and firewall in the router, but it still don't work. I think stunserver.org is down, can you test this server again ?
|
|
|
|

|
Just tried, all works. May be your antivirus soft or something like that has firewall too.
|
|
|
|

|
Hi,
Its really a good article. It makes the Idea pretty clear.
Well i'm developing an application in which i need p2p Udp streaming. Could you just provide me small sample client server application demonstrating How to use STUN.
I wud be really greatfull to you for it and also make sure that ur name is displayed on contributors list.
Please help me out.
Thanx in advance
|
|
|
|

|
Hi,
I dont get why included sample app wont suit.
Also stun server not implemented, client only.
|
|
|
|

|
Well there are lots of articles explaining UDP traversal though NAT using STUN, TURN, UPNP etc. but there are least samples available to give a quick understanding.
Why I'am asking for a sample is just to enable Beginners on Network application like me to understand and give a quick start as implementation is diffcult and may require more knowledge.
And as you have worked a lot on VOIP applications it may not be difficult for you to provide a small sample application.
Thanx again for a quick reply.
|
|
|
|

|
How many times i must tell example app is included in stun.zip, and also copy paste example is provided in article.
|
|
|
|

|
Hello,
Great work!! People like you make CP so good.
Thanks.
Best Regards,
Hitesh
|
|
|
|

|
It is great software, so simple to use and understand.
It will also be fine to have a STUNT (TCP) version
There are some projects on codeplex about this, but not completed ! (SharpSTUNT)
Krys
|
|
|
|

|
Hi
Just curious what tcp gives you more than udp ?
|
|
|
|
 |
|
|
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 | 96,434 |
| Downloads | 4,279 |
| Bookmarked | 52 times |
|
|