ccisco 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/audio/exp1 ADDED
@@ -0,0 +1,39 @@
1
+ import numpy as np
2
+ # Walsh codes / orthogonal codes
3
+ c1 = [1, 1, 1, 1]
4
+ c2 = [1, -1, 1, -1]
5
+ c3 = [1, 1, -1, -1]
6
+ c4 = [1, -1, -1, 1]
7
+ rc = []
8
+ print("Enter the data bits:")
9
+ d1 = int(input("Enter D1: "))
10
+ d2 = int(input("Enter D2: "))
11
+ d3 = int(input("Enter D3: "))
12
+ d4 = int(input("Enter D4: "))
13
+ # Multiply each data bit with its code
14
+ r1 = np.multiply(c1, d1)
15
+ r2 = np.multiply(c2, d2)
16
+ r3 = np.multiply(c3, d3)
17
+ r4 = np.multiply(c4, d4)
18
+ # Combined channel signal
19
+ resultant_channel = r1 + r2 + r3 + r4
20
+ print("Resultant Channel:", resultant_channel)
21
+ # Select receiver station
22
+ channel = int(input("Enter the station to listen for C1=1, C2=2, C3=3, C4=4: "))
23
+ if channel == 1:
24
+ rc = c1
25
+ elif channel == 2:
26
+ rc = c2
27
+ elif channel == 3:
28
+ rc = c3
29
+ elif channel == 4:
30
+ rc = c4
31
+ else:
32
+ print("Invalid channel selected")
33
+ exit()
34
+ # Decode using inner product
35
+ inner_product = np.multiply(resultant_channel, rc)
36
+ print("Inner Product:", inner_product)
37
+ res1 = sum(inner_product)
38
+ data = res1 / len(inner_product)
39
+ print("Data bit that was sent:", data)
package/audio/exp2 ADDED
@@ -0,0 +1,40 @@
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+
4
+ # Inputs
5
+ total_channels = 10 + 10
6
+ R, N, cells = 15, 7, 21
7
+ users_per_channel = 30
8
+
9
+ # Calculations
10
+ D = np.sqrt(3 * N) * R
11
+ capacity = total_channels * users_per_channel * cells
12
+
13
+ print("Total Channels =", total_channels)
14
+ print("Reuse Distance = %.2f km" % D)
15
+ print("Channels per Cell = %.2f" % (total_channels / N))
16
+ print("Estimated Capacity =", capacity, "users")
17
+
18
+ # Traffic Simulation
19
+ traffic = np.random.randint(50, 101, cells)
20
+ allocated = np.minimum(traffic, total_channels * users_per_channel)
21
+
22
+ # Graphs
23
+ plt.figure()
24
+ plt.bar(range(1, cells + 1), traffic)
25
+ plt.title("Traffic Demand per Cell")
26
+
27
+ plt.figure()
28
+ plt.bar(range(1, cells + 1), allocated)
29
+ plt.title("Allocated Users per Cell")
30
+
31
+ # Call Drop
32
+ drop_rate = np.maximum(0, (traffic - allocated) / traffic)
33
+
34
+ plt.figure()
35
+ plt.plot(drop_rate, linewidth=2)
36
+ plt.title("Call Drop Rate")
37
+
38
+ print("Average Call Drop Rate = %.4f" % np.mean(drop_rate))
39
+
40
+ plt.show()
@@ -0,0 +1,68 @@
1
+ clc;
2
+ clear;
3
+ close all;
4
+ %% Parameters
5
+ N = 1e6; % Number of bits
6
+ EbN0_dB = -3:10; % Eb/N0 range in dB
7
+ EbN0 = 10.^(EbN0_dB/10); % Linear scale
8
+ %% Transmitter
9
+ ip = rand(1,N) > 0.5; % Random bits {0,1}
10
+ s = 2*ip - 1; % BPSK mapping: 0->-1, 1->+1
11
+ %% AWGN Noise
12
+ n = 1/sqrt(2) * (randn(1,N) + 1i*randn(1,N));
13
+ %% Theoretical BER
14
+ ber_awgn_theory = 0.5 * erfc(sqrt(EbN0));
15
+ ber_rayleigh_theory = 0.5 * (1 - sqrt(EbN0 ./ (1 + EbN0)));
16
+ %% Simulation BER initialization
17
+ ber_awgn_sim = zeros(1,length(EbN0_dB));
18
+ ber_rayleigh_sim = zeros(1,length(EbN0_dB));
19
+ %% BER Simulation Loop
20
+ for ii = 1:length(EbN0_dB)
21
+ %% ---- AWGN Channel ----
22
+ y_awgn = s + 10^(-EbN0_dB(ii)/20) * n;
23
+ ipHat_awgn = real(y_awgn) > 0;
24
+ ber_awgn_sim(ii) = sum(ip ~= ipHat_awgn) / N;
25
+ %% ---- Rayleigh Channel ----
26
+ h = (randn(1,N) + 1i*randn(1,N)) / sqrt(2);
27
+ y_ray = h .* s + 10^(-EbN0_dB(ii)/20) * n;
28
+ y_eq = y_ray ./ h;
29
+ ipHat_ray = real(y_eq) > 0;
30
+ ber_rayleigh_sim(ii) = sum(ip ~= ipHat_ray) / N;
31
+ end
32
+ %% ================= GRAPH 1 =================
33
+ % BER comparison: AWGN vs Rayleigh
34
+ figure
35
+ semilogy(EbN0_dB, ber_awgn_theory, 'b-o','LineWidth',1.5); hold on;
36
+ %semilogy(EbN0_dB, ber_awgn_sim, 'b--','LineWidth',1.5);
37
+ semilogy(EbN0_dB, ber_rayleigh_theory, 'r-s','LineWidth',1.5);
38
+ semilogy(EbN0_dB, ber_rayleigh_sim, 'r--','LineWidth',1.5);
39
+ grid on;
40
+ legend('AWGN Theory', ...
41
+ 'Rayleigh Theory','Rayleigh Simulation', ...
42
+ 'Location','southwest');
43
+ xlabel('E_b/N_0 (dB)');
44
+ ylabel('Bit Error Rate');
45
+ title('BER Performance of BPSK over AWGN and Rayleigh Channels');
46
+ axis([-3 10 1e-5 1]);
47
+ %% ================= GRAPH 2 =================
48
+ % Bit Error Probability Curve for BPSK (AWGN ONLY)
49
+ % (Same style as lab manual)
50
+ figure
51
+ semilogy(EbN0_dB, ber_awgn_theory, 'b.-');
52
+ hold on
53
+ semilogy(EbN0_dB, ber_awgn_sim, 'mx-');
54
+ axis([-3 10 10^-5 0.5]);
55
+ grid on
56
+ legend('theory', 'simulation');
57
+ xlabel('Eb/No, dB');
58
+ ylabel('Bit Error Rate');
59
+ title('Bit error probability curve for BPSK modulation');
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
package/audio/exp8 ADDED
@@ -0,0 +1,33 @@
1
+ 1. Client.py
2
+ import socket
3
+ Server_ip="localhost"
4
+ Server_host=8002
5
+ FORMAT="utf-8"
6
+ CS=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
7
+ CS.connect((Server_ip,Server_host))
8
+ file = open("data/abc.txt","r")
9
+ data=file.read()
10
+ CS.send("abc.txt".encode(FORMAT))
11
+ msg=CS.recv(1024)
12
+ print( msg)
13
+ CS.send(data.encode(FORMAT))
14
+ msg=CS.recv(1024)
15
+ print(msg)
16
+ 2. Server.py
17
+ import socket
18
+ Server_ip="localhost"
19
+ Server_host=8002
20
+ FORMAT="utf-8"
21
+ SS=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
22
+ SS.bind((Server_ip,Server_host))
23
+ SS.listen(5)
24
+ s1, addr=SS.accept()
25
+ file_name = s1.recv(1024).decode(FORMAT)
26
+ print(file_name)
27
+ file=open(file_name,"w")
28
+ s1.send("File name received".encode(FORMAT))
29
+ data=s1.recv(1024).decode(FORMAT)
30
+ print("File data received")
31
+ s1.send("File data received".encode(FORMAT))
32
+ file.write(data)
33
+ file.close()
package/audio/mc_5.pkt ADDED
Binary file
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "ccisco",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "keywords": [],
9
+ "files": ["audio"],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "description": ""
13
+ }