|
| 1 | + |
| 2 | +NetJam 🕸️ |
| 3 | +=============== |
| 4 | + |
| 5 | +> Network congestion simulator for TCP connections. |
| 6 | +
|
| 7 | + |
| 8 | +Usage |
| 9 | +----- |
| 10 | + |
| 11 | + |
| 12 | +```sh |
| 13 | +user@host:~$ npx netjam --help |
| 14 | + |
| 15 | +netjam - Network (TCP) traffic jam simulator. |
| 16 | + |
| 17 | +SYNTAX: npx netjam <remoteHost> <remotePort> [listenPort] |
| 18 | +Where: |
| 19 | + <remoteHost> Network name or IP of remote host. |
| 20 | + <remotePort> Destination port number |
| 21 | + [ListenPort] Sourece port number to forward (default = 5000 |
| 22 | +``` |
| 23 | +
|
| 24 | +
|
| 25 | +Example |
| 26 | +------- |
| 27 | +
|
| 28 | +Create a *jamable* TCP tunnel to local PostgreSQL Server listening in its |
| 29 | +default port (5432): |
| 30 | +
|
| 31 | +```sh |
| 32 | +user@host:~$ npx netjam localhost 5432 |
| 33 | +Server listening on port 5000 |
| 34 | + |
| 35 | +STATUS: |
| 36 | +┌─────────────┬────────────────────────────┐ |
| 37 | +│ (index) │ Values │ |
| 38 | +├─────────────┼────────────────────────────┤ |
| 39 | +│ remoteHost │ 'localhost' │ |
| 40 | +│ remotePort │ '5432' │ |
| 41 | +│ listenPort │ 5000 │ |
| 42 | +│ timestamp │ '2024-08-06T18:52:11.042Z' │ |
| 43 | +│ waiting │ 0 │ |
| 44 | +│ open │ 0 │ |
| 45 | +│ closed │ 0 │ |
| 46 | +│ withError │ 0 │ |
| 47 | +│ tx │ 0 │ |
| 48 | +│ rx │ 0 │ |
| 49 | +│ iputDelay │ 0 │ |
| 50 | +│ outputDelay │ 0 │ |
| 51 | +│ logInterval │ '0 (Disabled)' │ |
| 52 | +└─────────────┴────────────────────────────┘ |
| 53 | + |
| 54 | +AVAILABLE COMMANDS: |
| 55 | + inputDelay - Sets input delay to specified value |
| 56 | + outputDelay - Sets output delay to specified value |
| 57 | + delay - Sets overall balanced delay to specified value |
| 58 | + logInterval - Show/Set status (stderr) logging interval in msecs |
| 59 | + quit - Quit the program |
| 60 | + |
| 61 | +> |
| 62 | +``` |
| 63 | +
|
| 64 | +> 📌 Now, every time you hit the `Enter` key, you will get an updated *Status |
| 65 | +> Report* and a list of available commands. |
| 66 | +> |
| 67 | +> Additionally, if you set logInterval to a non zero value, it will start |
| 68 | +> periodically logging status data in JSON format to *stderr*. You can use below |
| 69 | +> command instead of the previous one to keep it apart to a file: |
| 70 | +> |
| 71 | +> ```sh |
| 72 | +> user@host:~$ npx netjam localhost 5432 2> netjam_log.json |
| 73 | +> ``` |
| 74 | +
|
| 75 | +
|
| 76 | +Now you can open another terminal and connect to your local Postgres database |
| 77 | +throug port 5000: |
| 78 | +
|
| 79 | +```sh |
| 80 | +user@host:~$ psql -h localhost -p 5000 |
| 81 | +Contraseña para usuario user: |
| 82 | +user@constructor:~/112/mnt (master)$ LANG=C psql -h localhost -p 5000 |
| 83 | +Password for user user: |
| 84 | +psql (15.7 (Ubuntu 15.7-1.pgdg22.04+1)) |
| 85 | +SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off) |
| 86 | +Type "help" for help. |
| 87 | +
|
| 88 | +user=> |
| 89 | +``` |
| 90 | +
|
| 91 | +This is a fully working conection with almost no penalty. |
| 92 | +
|
| 93 | +Now, at netjam console, you can, for instance, set a 1 second delay for every |
| 94 | +round-trip (tx+rx) connection: |
| 95 | +
|
| 96 | +
|
| 97 | +
|
| 98 | +``` |
| 99 | +> delay 1000 |
| 100 | +STATUS: |
| 101 | +┌─────────────┬────────────────────────────┐ |
| 102 | +│ (index) │ Values │ |
| 103 | +├─────────────┼────────────────────────────┤ |
| 104 | +│ remoteHost │ 'localhost' │ |
| 105 | +│ remotePort │ '5432' │ |
| 106 | +│ listenPort │ 5000 │ |
| 107 | +│ timestamp │ '2024-08-06T19:02:33.886Z' │ |
| 108 | +│ waiting │ 0 │ |
| 109 | +│ open │ 3 │ |
| 110 | +│ closed │ 3 │ |
| 111 | +│ withError │ 0 │ |
| 112 | +│ tx │ 20 │ |
| 113 | +│ rx │ 21 │ |
| 114 | +│ iputDelay │ 0 │ |
| 115 | +│ outputDelay │ 500 │ |
| 116 | +│ inputDelay │ 500 │ |
| 117 | +│ logInterval │ '0 (Disabled)' │ |
| 118 | +└─────────────┴────────────────────────────┘ |
| 119 | +
|
| 120 | +AVAILABLE COMMANDS: |
| 121 | + inputDelay - Sets input delay to specified value |
| 122 | + outputDelay - Sets output delay to specified value |
| 123 | + delay - Sets overall balanced delay to specified value |
| 124 | + logInterval - Show/Set status (stderr) logging interval in msecs |
| 125 | + quit - Quit the program |
| 126 | +
|
| 127 | +> |
| 128 | +``` |
| 129 | +
|
| 130 | +Now your PostgreSQL connection still works, but a little bit slower... 😉 |
| 131 | +
|
| 132 | +
|
| 133 | +<a name="contributing"></a>Contributing |
| 134 | +--------------------------------------- |
| 135 | +
|
| 136 | +If you are interested in contributing with this project, you can do it in many ways: |
| 137 | +
|
| 138 | + * Creating and/or mantainig documentation. |
| 139 | +
|
| 140 | + * Implementing new features or improving code implementation. |
| 141 | +
|
| 142 | + * Reporting bugs and/or fixing it. |
| 143 | + |
| 144 | + * Sending me any other feedback. |
| 145 | +
|
| 146 | + * Whatever you like... |
| 147 | + |
| 148 | +Please, contact-me, open issues or send pull-requests thought [this project GIT repository](https://github.com/bitifet/netjam) |
| 149 | +
|
| 150 | +
|
| 151 | +License |
| 152 | +------- |
| 153 | +
|
| 154 | + [GPLv3](LICENSE) |
0 commit comments