next up previous
Next: 4 Conclusions Up: 3 Example Models Previous: 3.6 Computer Graphics


3.7 Computer Networking

The final example is a model of the crc16 which is often built into data communications hardware.

crc16 =. monad define
bcc =. 16 $ 0
while. 0 ~: $ y. do.
  ser_quo =. (1 {. bcc) ~: 1 {. y.
  bcc =. (0 { bcc),(ser_quo ~: 1 { bcc),(2 3 4 5 6 7 8 9 10 11 12 13 { bcc),(ser_quo ~: 14 { bcc),15 { bcc
  bcc =. (1 }. bcc), ser_quo
  y. =. 1 }. y.
end.
bcc
)

   msg =: 1 1 0 1 0 1 1 0 1 1 0 0 0 0
   crc16 msg
0 0 1 1 1 1 0 1 1 0 1 0 0 0 1 1
      crc16 msg,crc16 msg
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

next up previous
Next: 4 Conclusions Up: 3 Example Models Previous: 3.6 Computer Graphics
2003-12-20