Giter Site home page Giter Site logo

oufengfang / p2pchat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 7wingfly/p2pchat

0.0 1.0 0.0 141 KB

A Peer-to-Peer chat program that demonstrates the implementation of UDP Hole-Punching, using a server with a known End Point to negotiate a direct connection between two clients behind NAT firewalls. Written in c#.

License: MIT License

C# 100.00%

p2pchat's Introduction

UDP Hole-Punching

Purpose

Have a server negotiate a peer-to-peer connection between two clients in the most direct way possible.

Demonstrate Hole-Punching / NAT traversal using the UDP protocol.

Demonstrate the support of UPnP.

Method

Server:

  • Uses TCP to manage available clients.
  • Uses UDP to learn the public End Point (IP and Port) of clients.
  • Publishes list of connected clients and their End Points.
  • Relays connection requests between clients.

Client:

  • Attempts to use UPnP to forward a port to itself on the router (Optional).
  • Sends the server the following information:
    • Hostname (as a friendly name)
    • Whether UPnP is enabled or not.
    • Local UDP port that the client is listening on.
    • List of local IP addresses.
  • Sends a message to the server that it wishes to connect to another client / Receives a message from the server that another client wishes to connect to it. (Both clients will attempt to connect to each other at the same time)
  • Sends 3 ACK requests to each local IP of other client to determine if clients are on the same LAN.
  • If there was no response, sends 99 ACK requests to public/external End Point.
  • If UDP Hole-Punching is successful, a chat window will be shown and a conversation can begin.

Everything the client attempts is outputted to a textbox for review.

Instructions

  1. Run the GetConnected server executable on a publicly reachable server. (Forward TCP and UDP port to your server on your router.)

  2. Change value 'ServerEndpoint' in Client.cs to your servers public IP.

  3. Run the P2PClient executable on PCs you want to connect.

  4. Click the 'Connect' button in the top left to connect to the server. The server will ensure you always have an updated list of available clients.

  5. Select a client and click 'Connect' in the bottom right to connect to it.

  6. Observe as two clients begin to establish a connect to each other.

p2pchat's People

Contributors

7wingfly avatar

Watchers

 avatar

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.