The AETHER routing layer consists of three concurrent loops: (i) the per-packet forwarding decision, (ii) the on-device PPO policy update, and (iii) the federated weight aggregation across the mesh.
function selectNextHop(packet, neighbors):
candidates = []
for n in neighbors:
score = w1 * signalQuality(n)
+ w2 * batteryHeadroom(n)
+ w3 * trustScore(n)
+ w4 * bandwidthAvailable(n)
+ w5 * (1 / predictedLatency(n))
+ w6 * mobilityAlignment(n, packet.dst)
- w7 * congestion(n)
- w8 * sybilRisk(n)
candidates.push({ n, score })
// Top-K multi-path forwarding with softmax probabilities
topK = candidates.sortByScore().take(K = 2)
p = softmax([c.score for c in topK])
return weightedSample(topK, p)
function ppoUpdate(trajectory):
advantages = computeGAE(trajectory.rewards, trajectory.values, gamma=0.99, lambda=0.95)
for epoch in 1..K_epochs:
for batch in trajectory.minibatches(size=64):
ratio = pi(batch.action | batch.state) / pi_old(batch.action | batch.state)
clipped = clip(ratio, 1 - epsilon, 1 + epsilon)
policy_loss = -min(ratio * advantages, clipped * advantages).mean()
value_loss = mse(V(batch.state), batch.return)
entropy_bonus = beta * entropy(pi(batch.state))
loss = policy_loss + 0.5 * value_loss - entropy_bonus
optimizer.step(loss)
pi_old <- pi
function federatedUpdate(localGradient, peers):
// Each peer encrypts its gradient under a homomorphic threshold key
encShare = encrypt(localGradient, thresholdKey.shares[selfId])
publish(encShare to gossip topic "ppo-grads")
// Aggregator collects encrypted shares, sums them, threshold-decrypts
if isAggregator():
agg = encryptedSum(collectShares(quorum = 2/3))
global = thresholdDecrypt(agg)
broadcast(global, topic = "ppo-weights")
// Each node applies the global update with trust weighting
if onMessage("ppo-weights", weights, sender):
if verifySignature(weights, sender) and reputation(sender) > tau:
pi.weights = (1 - alpha) * pi.weights + alpha * weights
| Weight | Feature | Sign | Why |
|---|---|---|---|
| w1 | signal quality (RSSI, SNR) | + | Avoid lossy links |
| w2 | battery headroom | + | Don't drain dying devices |
| w3 | trust score | + | Prefer attested peers |
| w4 | available bandwidth | + | Avoid saturated links |
| w5 | 1 / predicted latency | + | Prefer fast paths |
| w6 | mobility alignment | + | Move toward destination |
| w7 | congestion | − | Penalize ECN-marked queues |
| w8 | Sybil risk | − | Penalize unattested clusters |