This repository was archived by the owner on Jan 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
This repository was archived by the owner on Jan 27, 2021. It is now read-only.
error in generation of random bytestream data from a custom datatype #79
Copy link
Copy link
Open
Description
I'm trying to create a random packet of a particular datatype arbit_data defined as follows
#lang ivy1.7
include ip_codec
# define a new data-type
type packetload
interpret packetload -> bv[16]
object arbitdata = {
object datagram = {
type this = struct{
load : packetload
}
}
instance packet_codec : bv_codec(packetload,2)
action decode(raw:stream) returns (dgram:datagram) = {
require raw.end = 2;
dgram.load := packet_codec.decode(raw,0);
}
action encode(dgram:datagram) returns (raw:stream) = {
raw := raw.resize(2,0);
raw := packet_codec.encode(raw,0,dgram.load);
}
}
After defining the above data-type, I attempt to send randomly generated data through the UDP socket using the following script.
#lang ivy1.7
include udp_host
include udp_spec
parameter client_addr : ip.addr = 0x7f000001
parameter server_addr : ip.addr = 0x7f000001
parameter client_port : udp.port = 8008
parameter server_port : udp.port = 8585
instance udp_intf : udp_host(udp.endpoint,stream)
var udp_endpoint : udp.endpoint
var udp_sock : udp_intf.socket
after init {
udp_endpoint := udp.endpoint.make(client_addr,client_port);
udp_sock := udp_intf.open(udp_endpoint)
}
include arbitdata_codec
action client_send_data(src:udp.endpoint,dst:udp.endpoint,pkt:arbitdata.datagram)
#action client_send_data(pkt:arbitdata.datagram)
implement client_send_data(src:udp.endpoint,dst:udp.endpoint,pkt:arbitdata.datagram){
#implement client_send_data(pkt:arbitdata.datagram){
if _generating{
# obtain the byte-stream payload
var pyld := arbitdata.encode(pkt);
if src.addr = client_addr & src.port = client_port {
call udp_sending_pkt(dst,pyld);
call udp_sock.send(dst,pyld);
}
}
}
export client_send_data
import action udp_sending_pkt(dst:udp.endpoint,pyld:stream)
I however, end up with the following error, which I do not know how to resolve.
# ivyc target=test udp_networkingref_echoclient.ivy
stream.ivy: line 49: error: cannot determine an iteration bound for loop over pos
Could you please help resolve this issue? Is there something wrong in the way I'm implementing this?
Metadata
Metadata
Assignees
Labels
No labels