Giter Site home page Giter Site logo

How does stun - http work? about natmap HOT 1 CLOSED

vavrecan avatar vavrecan commented on August 24, 2024
How does stun - http work?

from natmap.

Comments (1)

MikeWang000000 avatar MikeWang000000 commented on August 24, 2024 1

Thank you for your interest in NATMap.

This stun - http method was originally designed by me at Natter, a similar project written in Python, so it might be appropriate for me to explain it.


Let's say we have local IP:PORT A:B. Before we reach STUN server C:D, address A:B will be translated to public address X:Y.

[A:B <--NAT--> X:Y] ---(short)---> C:D (STUN server)

STUN server will tell you your public address X:Y.


However, this is not enough. When we finish the STUN query, the TCP connection closes and the A:B to X:Y translation soon expires.

So we introduce the HTTP connection. This connection also binds to local address A:B, but lasts longer, by sending header Connection: Keep-Alive.

[A:B <--NAT--> X:Y] ---(long)---> E:F (HTTP server)

Up to this point, we have a persistent address mapping A:B to X:Y.

Port A:B can have many outgoing and incoming connections simultaneously by setting flags SO_REUSEADDR and SO_REUSEPORT.

So the third socket also listens to address A:B but accepts incoming connections. People on the Internet visiting port X:Y will finally reach A:B.

[A:B <--NAT--> X:Y] <------ incoming connections

from natmap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.