22 lines
		
	
	
		
			945 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			945 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
| #!/bin/sh
 | |
| 
 | |
| # Example of coding using a (7,4) Hamming code, with transmission through
 | |
| # a Binary Symmetric Channel with error probability of 0.05.
 | |
| #
 | |
| # This example shows how random source messages can be encoded as codewords, 
 | |
| # transmitted through the simulated channel, decoded, and the message bits
 | |
| # extracted from the codewords.  The final result is in ex-ham7b.ext, which can
 | |
| # be compared to ex-ham7b.src.
 | |
| 
 | |
| set -e  # Stop if an error occurs
 | |
| set -v  # Echo commands as they are read
 | |
|   
 | |
| make-pchk ex-ham7b.pchk 3 7 0:0 0:3 0:4 0:5 1:1 1:3 1:4 1:6 2:2 2:4 2:5 2:6
 | |
| make-gen  ex-ham7b.pchk ex-ham7b.gen dense
 | |
| rand-src  ex-ham7b.src 1 4x1000
 | |
| encode    ex-ham7b.pchk ex-ham7b.gen ex-ham7b.src ex-ham7b.enc
 | |
| transmit  ex-ham7b.enc ex-ham7b.rec 1 bsc 0.05
 | |
| decode    ex-ham7b.pchk ex-ham7b.rec ex-ham7b.dec bsc 0.05 enum-bit ex-ham7b.gen
 | |
| verify    ex-ham7b.pchk ex-ham7b.dec ex-ham7b.gen ex-ham7b.src
 | |
| extract   ex-ham7b.gen ex-ham7b.dec ex-ham7b.ext
 | 
