#!/bin/bash

if [ ! $3 ]; then echo "Sintaxe: $0 <pub_key_file> <peer_eth0_ip> <peer_msh0_ip>"; exit; fi

my_id=$1
peer_eth0_ip=$2
peer_msh0_ip=$3

count=1

# Enabling LBS_DEBUG_CMD and LBS_DEBUG_HOST
echo 0x6000 > /sys/module/libertas/parameters/libertas_debug

# Creating an ~17MB file for the transfer
if [ ! -e /tmp/arq ]; then
  for i in /lib/*; do
    if [ -f $i ]; then cat $i >> /tmp/arq; fi
  done
fi

# Main loop: alternate transfers via infra and mesh (interval is 1 second)
while true; do
  echo eth0: ${count}
  scp -i ${my_id} /tmp/arq root@${peer_eth0_ip}:/dev/shm
  sleep 1
  echo msh0: ${count}
  scp -i ${my_id} /tmp/arq root@${peer_msh0_ip}:/dev/shm
  sleep 1
  let count=${count}+1
done


