# Building a local network of spam-protected chat2 clients
This document is a tutorial on how to locally set up a small network of chat2 clients in a spam-protected mode using the waku-RLN-Relay protocol.
In the provided test scenario, you will set up three chat2 clients.
For ease of explanation, we will refer to them as `Alice`, `Bob`, and `Carol`.
`Bob` and `Carol` are directly connected to `Alice` so that their message will be routed via `Alice`.
In this setting, if `Bob` or `Carol` attempts to spam the network by violating the message rate limit then `Alice` will detect their spamming activity, and does not relay the spam messages.
The message rate is one per epoch.
At the time of this tutorial, the epoch duration is set to `10` seconds.
You can inspect its current value by checking the following [constant variable](https://github.com/waku-org/nwaku/blob/44c543129ee4149255a00a05f1e7d21f8fa28626/waku/v2/waku_rln_relay/constants.nim#L51) in the nim-waku codebase.
Next, set up the following three chat2 clients in order.
As `Alice` is going to be the only connection point between `Bob` and `Carol`, you need to set it up first before `Bob` and `Carol`.
**Alice setup**:
Run the following command to set up the first chat2 client. In this command, the `rln-relay` flag is set to true to enable RLN-Relay protocol for the spam protection.
The `rln-relay-membership-index` is used to pick one RLN key out of the 100 available hardcoded RLN keys.
We use the first RLN key of the list for `Alice` i.e., `--rln-relay-membership-index:1`.
Now that the network is formed, you can start chatting.
For a better illustration of spam protection, use `Bob` and `Carol` clients for chatting and let `Alice` act only as a router.
Once you type a chat line and hit enter, you will see a message that indicates the epoch at which the message is sent e.g.,
```
>> Hi!
--rln epoch: 164495684
<Feb15,12:27> Bob: Hi!
```
The numerical value `164495684` indicates the epoch of the message `Hi!`.
You will see a different value than `164495684` on your screen.
If two messages sent by the same chat2 client happen to have the same RLN epoch value, then one of them will be detected as spam and won't be routed (by Alice in this test setting).
At the time of this tutorial, the epoch duration is set to `10` seconds.
Thus, if you send two messages less than `10` seconds apart, they are likely to get the same `rln epoch` values.
After sending a chat message, you may experience some delay before the next chat prompt appears.
The reason is that under the hood a zero-knowledge proof is being generated and attached to your message.
Once you are done with the test, make sure you close all the chat2 clients by typing `/exit` command.
```
>> /exit
quitting...
```
# Sample test output
In the following sample test, `Bob` sends three messages namely, `message1`, `message2`, and `message3`.
The two messages `message2` and `message3` have identical RLN epoch value of `164504930`, so, one of them will be discarded by `Alice` as a spam message.
You can check this fact by looking at the `Alice` console, where `A spam message is found and discarded : <Feb 16, 14:08> Bob: message3` is presented.
`Alice` does not relay `message3` further, hence `Carol` never receives it.