Lab 2: Wi Fi and Cellular
Lab 2: Wi Fi and Cellular
NetID: <Please fill in>
Link to published notebook: <You have to publish first to get the link, then add it here, and then print as PDF to submit to Gradescope>
Part 1: Attenuation
Part 1: Attenuation
In this part, we will visualize the signal of our message, and see how a received signal changes when with distance from the transmitter.
Visualize a signal
Visualize a signal
Let's start with plotting your favorite binary message (containing only ten bits).
Specify the bits:
In[]:=
someBits={0,1,1,1,0,0,0,1,0,1}
Plot the signal:
In[]:=
ListStepPlot[someBits,Left]
Visualize the location of a device and strength of received signal
Visualize the location of a device and strength of received signal
Let's say we have a router WiFi router that needs to send a signal and a phone that needs to receive it.
Specify the bits, location of the router and location of the phone:
In[]:=
transmittedBits={1,0,0,1,1,0,1,0,1,1};
For locations of the router and phone we will use the Cartesian co-ordinate system and provide x and y values:
In[]:=
(*xcoordinate0,ycoordinate0*)routerLocation={0.,0.};
In[]:=
(*xcoordinate2,ycoordinate0*)phoneLocation={2.,0.};
Visualize the location of the phone with respect to the router:
In[]:=
ListPlot{{routerLocation},{phoneLocation}},
Distance between device (receiver) and router (transmitter)
Distance between device (receiver) and router (transmitter)
Calculate the distance between the router and the phone (r):
In[]:=
r=EuclideanDistance[routerLocation,phoneLocation]
Signal Attenuation
Signal Attenuation
There is a formula to compute how much the signal strength reduces as the distance between the phone and the router increases.
◼
If the strength of the signal is s
◼
and the distance of the phone from the router is r,
◼
then the attenuated (reduced) strength of the signal at the phone can be computed as:
s
2
r
If I tell you the strength of the signal, when transmitted was 10 units, can you compute what was the strength of the received signal?
Use the formula from above to compute strength of received signal (rs) :
In[]:=
s=10;
In[]:=
rs=s/r^2
Visualize Transmitted and Received Signal
Visualize Transmitted and Received Signal
Visualize the transmitted signal at the router and the received signal at the phone together:
In[]:=
ListStepPlot{transmittedBits*s,transmittedBits*s/EuclideanDistance[routerLocation,phoneLocation]^2},
Now we will try to move the phone to a different location to see how the strength of the received signal changes.
We keep the transmitted bits the same:
In[]:=
transmittedBits={1,0,0,1,1,0,1,0,1,1};
We keep the transmitted signal strength same as before:
In[]:=
s=10;
We keep the location of the router same as before:
In[]:=
routerLocation={0.,0.};
We change the location of the phone (it was previously at {2., 0.}):
In[]:=
phoneLocation={1.,-4.};
Now visualize the transmitted signal at the router and the received signal at the phone’s new location:
In[]:=
ListStepPlot{transmittedBits*s,transmittedBits*s/EuclideanDistance[routerLocation,phoneLocation]^2},
Part 2: Noise
Part 2: Noise
Time to add noise to the signal
Time to add noise to the signal
In the real world, the received signal will contain noise. Let’s add some noise to our plots (as well as signal attenuation due to distance) for a more more realistic representation of the received signal.
Specify a sequence of bits and create a signal out of the bits (this is done a little differently than before for ease of visualization):
In[]:=
signalBits={1,0,0,1,1,0,1,0,1,1};signal=Flatten[signalBits*ConstantArray[1,{10,25}]];
Generate some random noise:
In[]:=
noise=RandomReal[{-.15,.15},10*25];
Visualize the signal by itself as well as when combined with noise:
In[]:=
ListPlot{noise+signal,signal},
Part 3: Corrupting the Signal Beyond Recognition
Part 3: Corrupting the Signal Beyond Recognition
We’ll try to move the phone away from the router and see how it affects the received signal, now that we’ve added noise. (Instead of worrying about coordinates for location of the router and phone, we’ll directly set the distance between them.)
Set the distance between router and device:
In[]:=
r=1.;
Compute the strength of the attenuated at distance r:
In[]:=
attSignal=signal/r^2;
Compute the actual received signal with the effects of attenuation and noise combined:
In[]:=
receivedSignal=attSignal+noise;
Visualize the transmitted signal along with the received signal:
In[]:=
ListPlot{receivedSignal,signal},
Problem 1
Problem 1
Can you still decode the signal manually?
Answer:
Answer:
Problem 2
Problem 2
Try changing the distance r (to values like 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5) and report at what distance does the signal start to get corrupted?
In[]:=
r=1.5;attSignal=signal/r^2;receivedSignal=attSignal+noise;ListPlot{receivedSignal,signal},
Answer:
Answer:
Part 4: Making the computer decode the signal
Part 4: Making the computer decode the signal
Now, let’s see if a computer can decode the signal.
We will average the signal received for the time of transmission of one bit, and then plot this averaged signal.
We will average the signal received for the time of transmission of one bit, and then plot this averaged signal.
Compute the average signal from the noisy signal:
In[]:=
averagedReceivedSignal=Flatten[Mean/@Partition[receivedSignal,25]*ConstantArray[1,{10,25}]];ListLinePlot{receivedSignal,averagedReceivedSignal},
Set a threshold for decoding signals and use it to get zeros and ones from the averaged signal (so that anything greater than a threshold value is decoded as 1 and anything below it is a 0):
In[]:=
threshold=0.2;decodedSignal=averagedReceivedSignal/.{x_/;x>threshold->1,y_/;y<=threshold->0};
Visualize transmitted signal, noisy signal and decoded signal:
In[]:=
ListPlot{signal,(*signaltransmitted*)receivedSignal,(*signalreceived*)averagedReceivedSignal,(*signalaveragedduringdurationofabit*)decodedSignal(*signaldecodedbycomparingaverageagainstathreshold*)},
Problem 3
Problem 3
Using this averaging technique, do you think a computer will be able to decode the signal?
Answer
Answer
Problem 4
Problem 4
Evaluate the following code code to answer the questions:
◼
What is the decoded signal?
◼
What is the maximum distance of your device from the transmitter (router or cell tower) for which the decoding works?
◼
How would you change the threshold for decoding the signal as 1s and 0s?
◼
How would you change the strength of the signal you are transmitting?
Answer
Answer
Part 3: Interference
Part 3: Interference
Visualize interfering signals
Visualize interfering signals
Next, we will observe the effect of interference on the received signal.
Set the location of your WiFi router that is transmitting your favorite binary signal to your device .
There are also two neighboring WiFi routers (neighbor1 in green and neighbor2 in red) that are transmitting, causing interference . Set the signals and locations for each router.
Set the signal strength (all three routers are transmitting at same strength):
Finally, set the location of your device located at a specific point with respect to the 3 routers:
Evaluate the code below to see the location of the phone w.r.t. the routers and the signals received at the device:
Problem 5:
Problem 5:
Try changing the location of the device and see how the signal graphs change.
Enter a coordinate (x, y) for the device such that the neighbor's signal becomes stronger than the signal from your own router. You can also adjust the strength of the transmitted signal.
Report the location of your device and the strength of the transmitted signal.
Enter a coordinate (x, y) for the device such that the neighbor's signal becomes stronger than the signal from your own router. You can also adjust the strength of the transmitted signal.
Report the location of your device and the strength of the transmitted signal.
Answer
Answer
Part 4: The Big Picture
Part 4: The Big Picture
Calculate SINR
Calculate SINR
Set the signal strength, noise strength and interference strength:
Compute the SINR:
Visualize SINR around the router
Visualize SINR around the router
But remember we have to adjust the strength of both the real signal from your router and the interference from the neighbors according to the distance from the routers!!!
Set locations of your router and your neighbors’ routers as before and visualize the SINR for the signal received from your router in the area surrounding your router:
Problem 6
Problem 6
Try moving your router and the neighbors’ routers to see how the coverage area changes.
Make it so that the coverage area becomes a very non-circular blob, and save your notebook with that configuration.
Make it so that the coverage area becomes a very non-circular blob, and save your notebook with that configuration.
Answer
Answer
Submitting your work
Submitting your work
1
. Publish your notebook
1
.1
.From the cloud notebook, click on “Publish” at the top right corner.
1
.2
.From the desktop notebook, use the menu option File -> Publish to Cloud
2
.Copy the published link
3
.Add it to the top of the notebook, below your netID
4
.Print to PDF
5
.Upload to Gradescope
6
.Just to be sure, maybe ping your TA Sattwik on Slack that you have submitted.