首页 > > 详细

讲解 CNIT 17600 - Intro Computer Architecture Raspberry Pi Networking Lab讲解 数据库编程

CNIT 17600 - Intro Computer Architecture - RPi Networking

Raspberry Pi Networking Lab

Getting Started

It is important that you read the lab manual and do not just try to type in commands. This is a learning experience through the reading and the doing - so read AND do, please.

Assumptions in this Document

Please note, these instructions are written based on the assumption that the personal machine you are using is running Windows with some instructions given for macOS. If you are using a different operating system, your procedures might change. These instructions also use the assumption that you are wanting to connect to the Pi with a laptop, but it could just as easily be a workstation. You may just have to translate the instructions in that case to apply to you.

Connecting to Wi-Fi

The Raspberry Pi has some limitations in which Wi-Fi networks it is able to connect to. It will not, for example, connect to PAL 3.0 (Purdue’s campus network) due to the way that PAL handles logins. Any network which only requires a password and does not require a login name will work. This appears to be changed in some versions of the Pi’s networking software, so it’s possible you will have success where it used to be impossible. Almost everyone’s home router will be set up this way (called WPA2-PSK for “Wireless Protected Access - Pre-Shared Key”). PAL 3.0 uses WPA2-Enterprise.

The network we can use for this in the lab is the CIT-PI network. The password for this network is ”CNIT176Pi!”.

You must be connected to the same network on your Pi and your laptop for this lab.

If you have successfully connected your Raspberry Pi to Wi-Fi already, you are done with this step. Sometimes, the Pi is capable and willing to connect to Wi-Fi without manual configuration, and sometimes it takes a little fiddling and manual configuration to get it to cooperate. Ask for help troubleshooting if you get stuck.

Lab Tasks: Connecting to the Pi Over SSH

SSH (Secure Shell) is a networking protocol that allows for one computer to connect to the command line of another computer (also called the terminal or shell) with all network traffic being cryptographically secured. In order to be able to use the Raspberry Pi using your laptop’s display, keyboard, and mouse, we can create such a connection and you will have command line access to your Raspberry Pi from your laptop. We would ideally like to be able to use the other (GUI - Graphical User Interface) applications on the Pi also, so we will do some extra steps, called “X Forwarding,” in order to make that possible.

First, you will need to obtain the IP address of your Pi. The command to display IP address information on a Linux system (like the Pi) is ifconfig or ip a. You will need this information both for the actual connection and some of the preparations.

Preparing to make SSH connections

First, we need a couple of programs that make the SSH connection and the “X Forwarding” possible. It is not yet necessarily important to know exactly what X Forwarding is.

• For Windows, do the following on your personal computer that you plan to use to connect to the Pi:

– Download and install PuTTY (make sure you choose the right version for your Windows Operating system. You probably want the 64-bit one, but be sure). Download link: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

– Download and install XMing. Download link: https://sourceforge.net/projects/xming/

– Download and install XMing-fonts. Download link: https://sourceforge.net/projects/xming/files/Xming-fonts/7.7.0.10/Xming-fonts-7-7-0-10-setup.exe/download

– Add the IP address of your Pi that you obtained earlier to the X0.hosts file. This file (on a default install) can be found at C:/ProgramFiles(x86)/Xming/X0.hosts and can be edited with Notepad.

• If you use a Mac, download a program called XQuartz and use the XQuartz terminal to type in the ssh commands (rather than using PuTTY as described for Windows users). After you install it, you will need to fully reboot your Mac in order to have it act as the role of X Server (described below).

Starting the X Server

X11 is a display protocol for providing a remote graphical user interface that is meant to be architecture independent - to run in multiple operating systems on any type of hardware.

Recall that in a client-server architecture, a client requests information or services from a server that provides the requested information or services. That information might be HTTP web requests, SQL database requests, or in this case the X server accepts requests for graphical *output* to a display not from a user but from an application, it also accepts user input from I/O devices and peripherals such as keyboards, mice, or touchscreens and sends them to the client application.

We installed Xming because Windows doesn’t have an easy native way to handle the X11 protocol and needs a way to accept X requests and send user input to an application. We need to launch the Xming application to create an Xming server on our Windows machine. XQuartz will act as the X server for the Mac users.

• Launch the Xming program and confirm that the Xming server is running by finding the icon in the tray (typically near your Wi-Fi connection icons and such). You can tell it is running by hovering over it and seeing it display information about itself.

On the Pi Side - Setting up the Client Applications

In your terminal window on the Raspberry Pi, run the following commands in this order. The first two will take a few minutes - go make yourself some tea or something. The third will take long enough for you to drink your tea probably. The fourth package is the letter x and the number eleven (x11).

sudo apt update

sudo apt upgrade

sudo apt dist-upgrade

sudo apt install x11-apps

sudo apt install xbase-clients

sudo apt install firefox-esr

Read the output after you run these commands to make sure they ran successfully.

===============================================

(1) Include in your lab report a screenshot of your terminal window at this point in the lab. The output at the end of the last command will help us to verify the other commands ran successfully.

================================================

The Advanced Package Tool (APT) is used to update software on several different Linux operating systems, but is largely associated with the Debian Linux flavors - such as the Raspberry Pi OS that you run on your Raspberry Pis. It uses something called a repository to find source code and source code dependencies. Dependencies are the programs or the libraries that one program’s code references but does not package within itself redundantly - linked libraries as an example. APT finds the source code files typically (but not always) over a network connection to obtain source code from network repositories.

In your terminal window, issue the following command:

cat /etc/apt/sources.list

==========================================

(2) Include in your lab report a screenshot of your terminal window at this point in the lab. This information shows the sites your Raspberry Pi is configured to visit to update packages (the process you just went through). Reading the output here, what URLs is your Pi looking to access? Note, the # character shows a commented line in a Linux configuration file.

================================================

The last thing that needs to be done to get the Raspberry Pi all set up is to make sure it has SSH running. In Linux, a shell is a terminal window (displayed to the GUI or not); SSH is all about creating a connection to a remote machine and obtaining a shell/terminal window.

In the terminal window, issue the following commands:

sudo systemctl start ssh

systemctl status ssh

=======================================

(3) Include in your lab report a screenshot of your terminal window at this point in the lab. Note, to exit the status screen, type the letter q. If status does not indicate that ssh is running, you will need to troubleshoot to get it started.

========================================

Back to the X Server, let’s create an SSH Connection

To connect over ssh using XQuartz on a Mac, type the following command in the XQuartz terminal window:

ssh -Y [email protected]

where xxx.xxx.xxx.xxx is the IP address of your Raspberry Pi, and username is the user-name you use on your Pi.

To create an SSH connection in Windows, PuTTY is an excellent and trusted applica-tion. Launch PuTTY and you will get a window such as the one below.

Figure 1: Example Session Config for PuTTY

The menu to the left of the window has information about Session, Terminal, and down below under Connection, there is a Category called SSH.

1. In the Session window, as shown above, enter the IP address of your Raspberry Pi and leave the port set to 22.

2. Enter a name in the “Saved Sessions” field for your SSH connection to your Pi.

3. In the left menu, click on the SSH Category to expand it, then click on X11. You will obtain something that looks like the image below.

Figure 2: Enabling X11 Forwarding in PuTTY

4. Be sure that Enable X11 forwarding has a check mark next to it and that the MIT Magic-Cookie-1 radio button is selected.

5. For X authority file for local display, browse to the Xming.exe program (probably in C:\ProgramFiles (x86)\Xming\Xming.exe)

6. Click back on the Session option in the menu.

7. Click on Save now so that your connection information to the Raspberry Pi will include the X11 forwarding configuration.

8. Finally, click on Open.

=========================================

(4) Include in your lab report a screenshot of your PuTTY window at this point in the lab.

==========================================

Forwarding X

At the terminal prompt that opened upon hitting Open in PuTTY, type in your Rasp-berry Pi username and password. At this point in the lab, you no longer need a separate keyboard, mouse, and display for the Raspberry Pi, however this is command line only.

There is one more thing we need to do in order to run GUI applications; we need to tell the Pi which display to use. This can be done by running the following command in your SSH terminal:

export DISPLAY=’IP:0.0’

Note that for IP, you will want to specify the IP address of your personal computer that you are using to connect to the Pi. This can be found on Windows easily by opening Com-mand Prompt and running ipconfig (note the similarity to the command used earlier for the Pi). Everything should now be ready.

To demonstrate that your X server is working properly and that you can run GUI programs over the SSH connection, type in the following command:

xeyes&

================================================

(5) Include in your lab report a screenshot of your Windows machine dis-playing the xeyes application.

Then, write a sentence or two to answer each of the following questions:

1. What does xeyes appear to do?

2. Where is xeyes executing? To confirm that xeyes is executing where you believe it is, bring up the process list on the host machine you have identified. If that is Windows, you can do this with Task Manager by hitting control + alt + delete. If that is your Raspberry Pi, you can type ps aux | grep xeyes in the terminal window and this will list all the processes and search for the name xeyes in the process list. Include a screenshot of your process list that provides evidence for where xeyes is executing.

3. How does the X server work to display xeyes on the monitor and to have the application use the mouse input from your Windows machine?

===========================================

While that program is a fun one, let’s also use something slightly more useful. To help make the results of this more clear, if your laptop is running Firefox, shut it down before you type in the following command.

firefox&

=======================================

(6) Include in your lab report a screenshot of your personal machine displaying the Firefox application. Be sure your screenshot shows your taskbar at the top or bottom of your desktop.

Then, write a sentence or two to answer each of the following questions:

1. Does the taskbar at the bottom of the screen show that Firefox is running after you type in that command? Why or why not?

2. What did the “&” character do at the end of the xeyes& and firefox& commands do? If you are not sure, you can always try to run the command without it and see what’s different.

3. Bonus Question: 10 points extra credit

In order for it to be possible to browse the internet using the keyboard and monitor of your Windows machine through an application running on your Raspberry Pi, we have several client server relationships being created. There is the X-server and the X-client, the SSH server and the SSH client, and also the web server and the web client (HTTP or HTTPS traffic).

Given a Windows laptop, a Raspberry Pi, and a Web Server, describe which of those three machines is playing which role as client or server (or not involved) with each of the three protocols. Identify what port each server is using to “listen” for protocol requests. Display this information in a concise way using a table or a diagram.

=========================================

Submission

Submit your lab report which should consist of the screenshots described above. It should answer the listed questions as complete sentences. Include the answers to the Xeyes ques-tions directly below the labeled Xeyes screenshot, and the Firefox ones below the labeled Firefox screenshot. This lab manual demonstrates for you how to properly label screen-shots. Optionally, your report may contain the answer to the bonus question. It is a little bit of a challenge, but give it a shot. Maybe you’ll get some partial credit.






联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!