erebus-attack / Bitcoin-Emulator

A comprehensive and accurate emulation of Bitcoin network implementation
MIT License
14 stars 5 forks source link

How to know how the RAP defense worked and print out the log of the RAP defense? #4

Closed oisonan1999 closed 2 years ago

oisonan1999 commented 2 years ago

Hello sir! How do I know how defensively RAP is in the code and print out a log of how RAP works (I have RAP defense enabled as well as the victim being attacked by shadows IPs on day 12) image

akshayeshenoi commented 2 years ago

The main logic for RAP is in the addrman file and is executed when the node tries to open a new connection (as detailed in Section 4.2 of our paper). The code should help explain the logic.

Also note that if RAP is enabled, the attacker also tries to prepare hidden-shadow IPs to exploit the route inference errors (Section 5.1).

oisonan1999 commented 2 years ago

Thank you for replying to me. So how do I edit the cfg.py file to see clearly that the RAP defense is actually working?

akshayeshenoi commented 2 years ago

If you run the emulator with rap_enabled = False, it will be easier for the attacker to successfully carry out the attack, i.e., occupy all outgoing connections. The attack duration will be shorter compared to when RAP was enabled.

This is the baseline scenario (Figure 3.a).

oisonan1999 commented 2 years ago

But when I look at the log printed to the screen before and after enabling RAP, which parameter will best demonstrate that the enemy successfully attacked before turning on RAP and the enemy failed after enabling RAP?

akshayeshenoi commented 2 years ago

We consider the attack to succeed if the attacker has occupied all outgoing connections before the end time of the simulation. That is currently set to approximately 381 days (nStart - nEnd, in seconds). Otherwise, the attack is said to fail.

You will have to wait for the simulation to fully complete. The only two conditions for completion are:

  1. The simulation runs till nEnd.
  2. The attacker occupies all outgoing conditions. Check this line.

We also log the result in the end, you should be able to clearly see the AttackSuccess output in your console.

oisonan1999 commented 2 years ago

Thank you so much! It's help me a lot!!