What exactly network implementation has been used in Blockchains? [closed] - blockchain

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I'm already working on a blockchain project, However I have a problem on implementing a peer to peer network between nodes. I found a Udemy course and in that course Redis pub/sub was used for peet to peer network but is it only available in a local network right ? or in another article it says that there are some main nodes that run 24/7 so others first make connection with them. but is it not sort of server-side network ??
my question is how can I actually implement a peer to peer network that many nodes around the world can communicate with each other without any main server ?

Usual implementation of P2P connection is to have one predefined port (for example in case of Bitcoin Core it's 8333) and the applications periodically broadcast their messages on this particular port.
It's also usual to have in your app a preset list of nodes that are likely to be online 24/7, so that the app can listen to their messages right from the startup and doesn't have to wait for other nodes to broadcast their presence.
The app can keep a list of currently active nodes (for example the ping period is 60 seconds, so any node that has pinged within the last 60 seconds is considered active) in case it needs to communicate with the other nodes directly.
But most communication is usually done via broadcasting and listening to messages on the predefined port.

Related

TCP/IP connection over global internet connection (C/C++) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Essentially I've been trying to relay messages between two computers using c/c++ using standard socket programming. Everything works fine on LAN. The issue is making the connection using something like external ip address. I searched online and saw methods that mention ensuring the router is configured for "port forwarding". However, I was wondering how do peer to peer communication apps like qTox overcome this barrier, since they do not require that technical step? To summarize, how can I connect two sockets between two computers that are NOT on the same network?
here is some methods we usually use to solve the problem.
If you can use a server in WLAN as relay or central controller, it's quite simple. The computers connect to the server, the server change messages for them and can do many more operations.
If you don't want to use a server, then here is a problem: NAT devices may drop those packets which haven't established a connection according to their type. Here are four types: full cone NAT, restricted NAT, port restricted NAT and symmetric NAT. And here are some methods for this circumstance
2.1 Use NAT traversal algorithm, but they may not work well in symmetric NAT.
2.2 Use STUN/TURN/ICE to realise NAT traverse, it's quite reliable but need to learn how to use them.

Connection Management in UDP with C++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a client/Server systems implemented by Boost asio in C++ that a client sends a request to server. Then the server registers this client to the list of alive clients and keeps sending data to it over UDP protocol. But, the server should keep track of alive clients and stop sending data to a disconnected or dead client.
I wonder how I can implement the UDP session/socket management here since UDP is a connectionless protocol and cannot provide us any information about alive clients. Should I use another library for UDP session management in C++? Or I should use another protocol in the application layer for UDP session management.
I know there is a library in Java called Verax IPMI https://en.wikipedia.org/wiki/Verax_IPMI which provides this ability. But, how about in C++?
Thanks for reading my question.
Just keep a list of endpoints that you've seen recently (meaning they sent you a datagram). Usually, you allow for a grace time (e.g. 30s) before removing a client from the list.
That way, if some datagrams were dropped you don't immediately forget the "connection".

How to handle a single connection from multiple clients on a single ip using TCP [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to develop a server for an application of mine in C++. I'm not really familiar with networking concepts. This server is going be a simple one and I'll use one of the networking libraries out there. I just couldn't figure out the necessary keywords to research the following issue:
Let's say that there are 100 users on 100 different computers, all sharing the same internet connection, behind the same router. They all decide to open my client to connect to my server. How do you deal with this issue if you want to keep the connections open and on the same port.
For the purposes of your server, it doesn't make any difference whether those 100 connections are all coming from the same computer, from the same router, or from totally separate networks.
While the server side of the connection will use the same port for all of these, each connection will have a different combination of client side IP address and port. In the case you describe, where all 100 are behind the same router using the same IP address, the router will take care of making sure they all have different client side port numbers. You can read about network address translation (NAT) if you want to learn the details about one common way that is done.
This kind of server programming is not easy and requires network skills. You can have a look at this tutorial. It's C and unix, but it shows the function you'll need to use:
socket interface for network access
listening/accepting new connextion
forking new processes to handle the different clients (although in C++ you'd probebly look for multithreading which is more efficient for this kind of task).

Best architectural choice for communication b/w a web client and a TCP server via relay [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Hi, I am a little confused in finalizing the software architecture of 1 of the projects I am planning to build. The solution is something like-
There are 2 devices in separate home network(private addresses) A and B. A acts as the data source and provides access to the data source over TCP to authenticated users. B is used by the user to fetch the data from A via a web browser. Authentication is something which is not the problem at hand now.
There is a central server S with a public IP address, which acts as a relay b/w A and B. S hosts a web application over a web server accessed by B. When the browser requests for the data, web app needs to fetch this data from device A.
There is an application on the same server S which has a TCP connection established with device A. So basically for web app to get the data one of the approach is to request it from this application which in turn fetches it from A. For this I can have a web service exposed from this application which can fetch the data.
First question - Is this approach good enough? or is there a better alternative
Second - As the application with TCP connection might want to talk to device A for updates or other things, I want a thread of execution running in this application which runs parallely to the context of web service, meaning when web app calls the web service, it will perform the job and also might want to do something on its own without being triggered by the web app.
I might have missed something basic as I am new to web services

How to test internet application at local computer (windows-7)? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
This application sends data periodically to a server. What I need to do is setup a testing environment on the local developing machine so that I can check the correct packets are being sent in each situation. I thought a good approach would be a server VM set up on the local computer which would receive the packets and respond just like the real thing, but the problem is how do I route the packets of an application running on windows to a VM machine. I don't want to modify my application code. I just want to have windows pass on the packets it receives from the application to the VM or otherwise another application that will do the testing. Is this possible? If not, please let me know about any other solution(s) to this problem.
If you're running a decent VM you should be able to give it an IP address visible from the host, and configure it so that you can run web servers on it, ssh to it, etc.
Look at the networking features of your VM. Or find a tutorial on how to do this, such as this one for VirtualBox:
http://www.tolaris.com/2009/03/05/using-host-networking-and-nat-with-virtualbox/
Well it's some kind of a hack but you can use ARP Poisoning (man in the middle attack) to sniff packets. There is a tool named Cain & Abel which can do this for you. I've used this tool to sniff packets between two non-pc machines. Use at your own risk and if your anti-virus tool alerts, know that the tool has no virus but what it does is detected as one.
Edit: Please note that my approach doesn't require a VM server.