Question
1 Learning Outcome: Project/Lab (2) By the end of this project, the students will: Learn how to use Mininet. Become familiar with client-server systems. Be
1 Learning Outcome:
Project/Lab (2)
By the end of this project, the students will: Learn how to use Mininet.
Become familiar with client-server systems. Be able to develop a client-server IM system.
IM Application
In this project you are asked to develop a python based instant messenger (IM).
The design of your IM system is an important aspect of this assignment. We provide a functional description of an IM system that your design should conform to. However, we will leave the pre- cise details of the design up to you. But please think about the design before diving into coding it will help. Feel free to look at some of the IM references presented at the end of this assignment, on the web, existing specs (always cite sources (no use of any existing code base of course but you can look at other open source code for sure, for inspiration, ideas, etc.). Be a detective. If you use any ideas, techniques, please cite sources, again.
When you do begin to implement your IM system we recommend you start with a basic set of fea- tures and proceed incrementally start simply and keep it simple. Perhaps start with just two clients exchanging messages and build up from there. Test each feature as you proceed, build confidence, and keep working towards the design specification that you developed.
Please create a single zip file that contains all of the files for your submission and upload this file to blackboard by the due date.
2 Blueprint for a Simple IM System
Many of you are familiar with IM from a users perspective but may not have given much consider- ation to its operation. The precise operation of an IM system will vary between different systems (e.g., AIM, MSN, iChat) but the essential functions remain the same. For the purposes of this assignment we require your simple IM system to incorporate the following functionality:
1. IM clients are able to join and leave the IM network. Every client has a user name and at any one particular time no two clients connected to the IM network can have the same user name. So some name checking is required in your code.
When IM clients join the network other connected clients are made aware of this change within the network the presence component. Similarly, the reverse should be true; that is, when clients leave the network other connected clients should be informed. So you need notification and state management a consistent view.
Connected IM clients are able to send messages to any other connected IM client. Messages are addressed to particular IM clients using their user name.
It is perfectly acceptable to adopt the following simplifications:
Please note that the figure below is just a sample. On the right hand side of the figure, the client can see the other clients as begin online (denoted in green) or being offline (denoted in red).
You are not required to maintain buddy lists specific to each IM client. It is fine to as- sume everyone in the IM network is part of a single universal buddy list. For instance all IM clients should be notified when any IM client joins or leaves the network. Fur- thermore, all IM clients should be able to exchange messages with any other IM client.
Your design only needs to support a single IM server. Although, this is not a scalable approach it simplifies the task of building your IM system. You may assume all clients are aware of this single well- known IM server. So your server will sit on a known host and have a known port. Clients simply connect using sockets. By only having a single server you do not need to be concerned with maintaining consistent state between multiple servers, so essential in a real system.
However, feel free to provide any additional functionality if you wish, it will be rewarded as extra- credit. But completing the base line system with no extras would be outstanding. See how things go.
The objective of this assignment is for you to design and implement an IM system that conforms to the description outlined above. It is a fairly high level description, so the details are up to you.
The server should perform operations, such as:
monitor clients that join and leave the IM network.
maintain a log file of all the chats between different clients.
maintain a reasonably consistent view of clients currently connected to the network and provide this state information to all the currently connected clients.
Figure 1: A sample IM interface (Photo attached at bottom)
4. facilitate the exchange of messages between clients.The clients should perform operations, such as:
1. display to the user that is currently connected IM clients; and 2. allow the user to send and receive messages to and from any of these clients, respectively.
2.1 Running Mininet
You will be using Mininet to develop and test your IM application.
We will be using 64-bit Mininet 2.2.2. To run Mininet, you will need a virtual machine (VM). We will be using VirtualBox, which is a free and open-source hypervisor.
You need to:
Download and setup Virtualbox.
Download Mininet 2.2.2 and import it to your Virtualbox. You can follow the step here to upload the image to your Virtualbox.
When you boot up the VM, youll have to log in using mininet and mininet as username and password.
2.1.1 GUI in MininetVM
Details can be found at Option 2: Native Installation from Source, but you can follow this basic set of instructions to setup a working GUI:
Update: sudo apt-get update Install the lxde desktop environment: sudo apt-get install xinit lxde InstallVirtualBoxguestadditions:sudo apt-get install virtualbox-guest-dkms Restart the VM: sudo reboot Start the GUI using startx
To avoid having to startx every time you boot, you can add the following snippet to the end of your /.bashrc:
if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then exec startx
fi Youcanreload.bashrcbytypingsource /.bashrc
To transfer files to/from your VM you should use the scp (secure copy) command. See the scp man page, or find a tutorial online, for instructions on how to use scp.
Dr. K., 2018 3
CPSC 4550: Computer Networks Fall 20182.2 Mininet Walkthrough
Once you have a Mininet VM, you should complete the following sections of the standard Mininet walkthrough:
3
All of Part 1, except the section Start Wireshark
The first four sections of Part 2 Run a Regression Test, Changing Topology Size and Type, Link variations, and Adjustable Verbosity
All of Part 3 You do not need to submit anything for this part of the project.
Setting up the topology
A python script to run Mininet with the topology described below (see Fig. 2 is provided here. To get the python script you can run the following command:
wget http://cecs-leda.utc.edu/files/Mininet/TopologyCS.py
OR:
curl -o Topology.py wget http://cecs-leda.utc.edu/files/Mininet/TopologyCS.py
To run Mininet with the provided topology, run the Python script TopologyCS.py using sudo:
sudo python TopologyCS.py
If you have trouble launching the script, a common fix is to first try running
sudo mn -c
and then try launching the script again.
Hosts (h1 to h5) are represented by squares where one of the host is to be designated as a server and switch (s1) is represented by circle; the names in the diagram match the names of hosts and switches in Mininet. The hosts are assigned IP addresses 10.0.0.1 through 10.0.0.5; the last number in the IP address matches the host number.
3.1 Sample Client-Server script
After your design is complete and you start the implementation of your design we suggest you first consult the example client/server application provided here. The example provides a description (and source code) of two python applications using socket programming.
To get the python script for the Server you can run the following command:
Figure 2: IM project topology
wget http://cecs-leda.utc.edu/files/Mininet/Server.py
OR:
curl -o Topology.py wget http://cecs-leda.utc.edu/files/Mininet/Server.py
To get the python script for the Client you can run the following command:
wget http://cecs-leda.utc.edu/files/Mininet/Client.py
OR:
curl -o Topology.py wget http://cecs-leda.utc.edu/files/Mininet/Client.py
Upload the Server.py script on one host and run it using the following format:python Server.py [Server IP] [Port]
Once the server is running, upload the Client.py script on another host and run it using the follow- ing format:
python Client.py [Server IP] [Port]
These two scripts serve as a classic client-server model where the server python script will run a server on the given IP address and port. It will then continue to listen for new connections with a default max of 100 hosts.
The client python script will attempt a connection on the given IP and port combination. Once the
handshake is complete both scripts will output a connected message. This process binds the scripts
to the Server IP and port using sockets to easily send data between the hosts.
During the design process you will determine that your server needs to be multi-threaded so that it can concurrently service more than one IM client at a time multithreading might be a new concept to you; it allows a software process to deal with concurrent events and operations. If you lack ex- perience in threaded programming you will find this tutorial on the subject an excellent resource. Your IM system requires threads to concurrently access state that is shared between all thread instances. To ensure the correct operation of your server you will be required to perform some form of synchronization between these threads when they access shared data they need mutual exclusion. Python provides support for threading and the necessary synchronization primitives. So this assignment brings in a lot of concepts that are important, one being shared state and the issue of concurrent access. You will come across these ideas in the software industry as designers and programmers.
=============TopologyCS.py script below=========
#!/usr/bin/env python from mininet.cli import CLI from mininet.net import Mininet from mininet.link import TCLink from mininet.topo import Topo from mininet.log import setLogLevel class AssignmentNetworks(Topo): def __init__(self, **opts): Topo.__init__(self, **opts) h1 = self.addHost('h1') h2 = self.addHost('h2') h3 = self.addHost('h3') h4 = self.addHost('h4') h5 = self.addHost('h5') h6 = self.addHost('h6') h7 = self.addHost('h7') h8 = self.addHost('h8') h9 = self.addHost('h9') h10 = self.addHost('h10') s1 = self.addSwitch('s1') s2 = self.addSwitch('s2') s3 = self.addSwitch('s3') s4 = self.addSwitch('s4') s5 = self.addSwitch('s5') s6 = self.addSwitch('s6') self.addLink(h1, s1) self.addLink(h2, s1) self.addLink(h3, s1) self.addLink(h4, s2) self.addLink(h5, s3) self.addLink(h6, s4) self.addLink(h7, s5) self.addLink(h8, s6) self.addLink(h9, s6) self.addLink(h10, s6) self.addLink(s1, s2, bw=20, delay='40ms') self.addLink(s2, s3, bw=40, delay='10ms') self.addLink(s2, s5, bw=30, delay='30ms') self.addLink(s4, s5, bw=25, delay='5ms') self.addLink(s3, s6, bw=25, delay='5ms') if __name__ == '__main__': setLogLevel( 'info' ) # Create data network topo = AssignmentNetworks() net = Mininet(topo=topo, link=TCLink, autoSetMacs=True, autoStaticArp=True) # Run network net.start() CLI( net ) net.stop()
==========END of TopologyCS.py=======
Client Window-client.ui Your Hey Bob> Hey USER LIST: Bob Alice Tim Tom James Your Type message here Send Figure 1: A sample IM interface er. Client Window-client.ui Your Hey Bob> Hey USER LIST: Bob Alice Tim Tom James Your Type message here Send Figure 1: A sample IM interface erStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started