Stormworks: Build and Rescue

Stormworks: Build and Rescue

评价数不足
Pony Net (Supporting Pony OS)
   
奖励
收藏
已收藏
取消收藏
标签: v1.1.12
文件大小
发表于
更新日期
7.402 MB
2020 年 7 月 25 日 上午 2:41
2021 年 3 月 13 日 上午 7:15
3 项改动说明 ( 查看 )

订阅以下载
Pony Net (Supporting Pony OS)

在 CrazyFluffyPony 的 1 个合集中
Pony Net
3 件物品
描述
Special thanks to "Daddy Daddy Do!"
He was interested in the project, and has fixed some bugs (see latest update).

Content
Pony Net
  1. How packets work (ports, MAC)
  2. Switches
  3. IPs and nets
  4. Routers
  5. Ports
  6. Cellular network
  7. Multiplayer warnings

Pony OS

Pony OS
You can create your own apps for Pony OS.
Please look at the description over here


Pony Net
Pony Net is the system that allows communication between multiple devices.
It is based on the IPv4 internet we all know or use. Some parts are a little bit different though.


EACH INDIVIDUAL PART OF THE SYSTEM INCLDUING A MANUAL WILL BE UPLOADED SOON

How packets work
A packet is a complete composite signal, for one tick. So one package includes 32 numbers (the 32 booleans are ignored).
A packet contains information about the source of the packet (sender) and the destination (receiver). This information is called MAC adress.
It must be a unique identifier and can range from 1-65535. Only 1-65534 can be used by devices, 65535 is a special adress which means "broadcast to everyone in the network". -1 is also a special adress, it means "switch please look up the MAC for a specified IP" (more about that later). the MAC adress 65534 is used by the network testing device, you better do not use that MAC.

IMPORTANT NOTE: because of multiplayer sync, you are ONLY allowed to use MACs between 1-255 for devices!!!

Composite channel
32
sender MAC (source)
31
receiver MAC (destination)
1-30
data

Switches
Switches exchange data between multiple devices. Pony Net offers a 4 connection switch and a 5 connection switch. They behave exactly the same: to every connection you connect one device (a host, a switch or a router).
The switch contains one lua script for every connection (queues up incoming packets at the input) and a master script that controls which packets to pop from which queue and to which output it should be sent.
The master script keeps track of which devices are connected on which connection. All devices broadcats an empty packet from time to time, so those tables have up to date information on connected devices.
Switches can be chained, but please make sure you do not create a round about!

A switch will also function as an ARP table (in real life this is not the job of a switch). He is able to translate IPs into MACs. This is necessary when transfering packets between different networks (more on that later).

IPs and nets
An IP adress identifies a device (similar to a MAC) but it also identified a network. This allows to split up the internet into many seperated networks. Communication inside networks can happen without blocking bandwith for devices of a different network.
If you send a packet to a device in the same network, it will travel to the next switch and then to destination device. If the destination device is in a different network, you have to first send the packet to the "gateway" (=router) of your network, this happens by choosing the gateways MAC as receiver MAC. This gateway then forwards the packet to the destination network via routers (currently Pony Net only supports static routing). Once it reaches its final destination router, this one will replace the receiver MAC with -1 and forward it to the local switch. This switch has the ARP table and can replace the -1 with the MAC of the destination IP.

IP adresses are made of 3 bytes:
the first 2 bytes is the network adress (e.g. 1.2) the third byte is the host adress (e.g. 230).
Network adresses range from 0.1 to 255.255, host adresses range from 1 to 254. 255 is a special IP, it means broadcast to the full network (a router will replace the receiver MAC with a 65535 = broadcast MAC).
This means you can have a maximum of 65534 networks, and a maximum of 254 devices per network.

If the receiver IP is 0, the packet will be dropped by routers.

Composite channel
32
sender MAC (source)
31
receiver MAC (destination)
30
sender IP (source)
29
receiver IP (destination)
28
port (which app should receive the data)
1-30
data


Routers
Routers connect/split networks. Once they receiver a packet, they check if the receiver IP is in a different network. If that is the case, and the router knows a route to that network, he will send it to the connection that has that route, otherwise it drops the packet. They work the same as switches in terms of queuing incoming packets and controling outgoing packets.

Ports
A port defines more or less an application that you want to receive the packet. An application can be a system application (e.g. DHCP) or your own application (e.g. chat system).
The network manager of PonyOS filters incoming packets and forwards them to the apps, depending on the ports (more on that later).

Used ports:
  • 999 (network testing device)
  • 888 (cellular network)
  • 67 (DHCP)
  • 53 (reserved for DNS)




Cellular Network
A cellular network is replacing the cable connection between a device and a switch with radio antennas. Every base station has sends on the same frequency. A receiver cecks that frequency and will get the configuration for that base station. The configuration includes 3 frequencies: reqgister, uplink, downlink. These frequencies should be different for every base station. Once the receiver notices that he connected to a new base station, he will register himself in the cell. Multiple receivers can be connected to a single cell, the cell will tell the receivers when they are allowed to send packets via the uplink. The downlink is sent to all receivers and they need to filter the packets for ones that are meant to be received by them.

Downlink & Uplink Composite
Composite channel
32
sender MAC (source)
31
receiver MAC (destination)
30
sender IP (source)
29
receiver IP (destination)
28
port (which app should receive the data)
1-30
data

Info Composite
Composite channel
1
mac adress who should send now
2
cell id of base station
3
register frequency of base stations


Multiplayer warnings
The packets themselves work fine in multiplayer.
Configurations are also multiplayer proof.
When a new player joins a server, it will take a couple of seconds until "his internet" synchronized the configuration for switches, celullar etc.

Desync can still happen because of Pony OS (more on that later).
26 条留言
CrazyFluffyPony  [作者] 2023 年 9 月 8 日 下午 12:50 
You can create a network with world wide coverage if you want. All the required devices are prepared.
пися 2023 年 9 月 6 日 下午 12:09 
Sorry for stupid question, is it internet with full map coverage, or simply lan and networks implementation example?
C-Corgi 2022 年 4 月 3 日 上午 8:35 
ok thanks
CrazyFluffyPony  [作者] 2022 年 4 月 3 日 上午 4:35 
@SCP-173

Globally:
info frequency = 5000

And then for every cell (cellID starts at 1):
registration frequency = 5000 + cellID * 3
downlink frequency = 5001 + cellID * 3
uplink frequency = 5002 + cellID * 3






Example with one cell:
5000, 5003 - 5005

Example with two cells
5000, 5003 - 5008
C-Corgi 2022 年 4 月 2 日 下午 9:40 
what radio channel do you use
CrazyFluffyPony  [作者] 2021 年 3 月 9 日 上午 10:48 
"Local" just uses the ip network the computer is in (e.g. if the computer has the ip address 12.0.1 then it will broadcast the chat messags to all computers in the net 12.0.0).

If you want to chat with the computer of a different net, enter the net ip of that computer (e.g. if the other computer has the up 13.0.1, then you have to insert 13.0.0)
CrazyFluffyPony  [作者] 2021 年 2 月 4 日 上午 8:52 
Hey, i am not playing the game anymore. But i might be able to help you. Just send me a private message on discord, that'll make it easier.
CrazyFluffyPony#0587
Kito 2021 年 2 月 4 日 上午 3:45 
hello, i am currently working on an communication system with your pony net but it seems that i need some help setting servers up, can you help?
CrazyFluffyPony  [作者] 2020 年 11 月 29 日 下午 12:37 
Take a look at the PC microcontroller. One of the lua scripts is the messaging app.
It takes the text, splits it up in characters and then sends 26 (or 25 or so?) characters per packet.
The same lua script (but running on other pcs) will receive those packets, and build the original string again.
Rad. Ballbearing 2020 年 11 月 29 日 上午 1:52 
Sorry for mistakes