Commit 0b43ea6b authored by Pedro Oliveira's avatar Pedro Oliveira

added one more router and a client

parent ffd4afc5
ip addr add dev eth0 10.1.0.1/24
ip link set dev eth0 up
#default route para obter conectividade internet
ip route add 0.0.0.0/0 via 10.1.0.2
# install python
apt-get update && apt-get --assume-yes install python3 python3-pip
nameserver 8.8.8.8
nameserver 8.8.4.4
import socket
import struct
import sys
message = 'very important data'
multicast_group = ('224.3.29.71', 10000)
# Create the datagram socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Set a timeout so the socket does not block indefinitely when trying
# to receive data.
sock.settimeout(10)
# Set the time-to-live for messages to 1 so they do not go past the
# local network segment.
ttl = struct.pack('b', 12)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl)
try:
# Send data to the multicast group
#print >>sys.stderr, 'sending "%s"' % message
print('sending "%s"' % message)
sent = sock.sendto(str.encode(message), multicast_group)
# Look for responses from all recipients
while True:
#print >>sys.stderr, 'waiting to receive'
print('waiting to receive')
try:
data, server = sock.recvfrom(16)
except socket.timeout:
#print >>sys.stderr, 'timed out, no more responses'
print('timed out, no more responses')
break
else:
#print >>sys.stderr, 'received "%s" from %s' % (data, server)
print('received "%s" from %s' % (data, server))
finally:
#print >>sys.stderr, 'closing socket'
print('closing socket')
sock.close()
#########################################
# Router setup
#########################################
router1[0]=A router1[0]=A
router1[1]=B router1[1]=B
router1[2]=tap,192.168.2.1,192.168.2.2 router1[2]=tap,192.168.2.1,192.168.2.2
...@@ -5,4 +8,16 @@ router1[mem]=256 ...@@ -5,4 +8,16 @@ router1[mem]=256
router2[0]=A router2[0]=A
router2[1]=C router2[1]=C
router2[2]=D
router2[mem]=256 router2[mem]=256
router3[0]=B
router3[1]=C
router3[mem]=256
#########################################
# Client setup
#########################################
client1[0]=D
client1[mem]=256
router2: router1 router2: router1
router3: router1
client1: router2
...@@ -9,6 +9,7 @@ password zebra ...@@ -9,6 +9,7 @@ password zebra
! !
router ospf router ospf
network 10.0.0.0/24 area 0 network 10.0.0.0/24 area 0
network 10.0.1.0/24 area 0
network 192.168.2.0/24 area 0 network 192.168.2.0/24 area 0
default-information originate always default-information originate always
! !
......
ip addr add dev eth0 10.0.0.2/24 ip addr add dev eth0 10.0.0.2/24
ip link set dev eth0 up ip link set dev eth0 up
ip addr add dev eth1 10.0.1.2/24 ip addr add dev eth1 10.0.2.2/24
ip link set dev eth1 up ip link set dev eth1 up
ip addr add dev eth2 10.1.0.2/24
ip link set dev eth2 up
#default route para obter conectividade internet #default route para obter conectividade internet
#ip route add 0.0.0.0/0 via 10.0.0.1 #ip route add 0.0.0.0/0 via 10.0.0.1
......
...@@ -9,6 +9,7 @@ password zebra ...@@ -9,6 +9,7 @@ password zebra
! !
router ospf router ospf
network 10.0.0.0/24 area 0 network 10.0.0.0/24 area 0
network 10.0.1.0/24 area 0 network 10.0.2.0/24 area 0
network 10.1.0.0/24 area 0
! !
log stdout log stdout
ip addr add dev eth0 10.0.1.3/24
ip link set dev eth0 up
ip addr add dev eth1 10.0.2.3/24
ip link set dev eth1 up
#default route para obter conectividade internet
#ip route add 0.0.0.0/0 via 10.0.1.1
#ip route del 0.0.0.0/0
# Zebra and OSPF
/etc/init.d/quagga restart
# wait for default route information from OSPF
while ! $(ip route | grep -q "default")
do
sleep 2
done
# install python
apt-get update && apt-get --assume-yes install python3 python3-pip
# This file tells the quagga package which daemons to start.
#
# Entries are in the format: <daemon>=(yes|no|priority)
# 0, "no" = disabled
# 1, "yes" = highest priority
# 2 .. 10 = lower priorities
# Read /usr/share/doc/quagga/README.Debian for details.
#
# Sample configurations for these daemons can be found in
# /usr/share/doc/quagga/examples/.
#
# ATTENTION:
#
# When activation a daemon at the first time, a config file, even if it is
# empty, has to be present *and* be owned by the user and group "quagga", else
# the daemon will not be started by /etc/init.d/quagga. The permissions should
# be u=rw,g=r,o=.
# When using "vtysh" such a config file is also needed. It should be owned by
# group "quaggavty" and set to ug=rw,o= though. Check /etc/pam.d/quagga, too.
#
# The watchquagga daemon is always started. Per default in monitoring-only but
# that can be changed via /etc/quagga/debian.conf.
#
zebra=yes
bgpd=no
ospfd=yes
ospf6d=no
ripd=no
ripngd=no
isisd=no
babeld=no
#
# If this option is set the /etc/init.d/quagga script automatically loads
# the config via "vtysh -b" when the servers are started.
# Check /etc/pam.d/quagga if you intend to use "vtysh"!
#
vtysh_enable=yes
zebra_options=" --daemon -A 127.0.0.1"
bgpd_options=" --daemon -A 127.0.0.1"
ospfd_options=" --daemon -A 127.0.0.1"
ospf6d_options=" --daemon -A ::1"
ripd_options=" --daemon -A 127.0.0.1"
ripngd_options=" --daemon -A ::1"
isisd_options=" --daemon -A 127.0.0.1"
babeld_options=" --daemon -A 127.0.0.1"
#
# Please note that watchquagga_options is an array and not a string so that
# quotes can be used.
#
# The list of daemons to watch is automatically generated by the init script
# from daemons.conf and appended to the watchquagga_options.
# Example:
# watchquagga_options=("-Adz" "-r" '/sbin/service %s restart' -s '/sbin/service %s start' -k '/sbin/service %s stop')
watchquagga_enable=yes
watchquagga_options=(--daemon)
! -*- ospf -*-
!
! OSPFd sample configuration file
!
!
hostname ospfd
password zebra
!enable password please-set-at-here
!
router ospf
network 10.0.1.0/24 area 0
network 10.0.2.0/24 area 0
!
log stdout
!
! Sample configuration file for vtysh.
!
!service integrated-vtysh-config
hostname quagga-router
username root nopassword
!
! -*- zebra -*-
!
! zebra sample configuration file
!
! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $
!
hostname Router
password zebra
enable password zebra
!
! Interface's description.
!
!interface lo
! description test of desc.
!
!interface sit0
! multicast
!
! Static default route sample.
!
!ip route 0.0.0.0/0 203.181.89.241
!
!log file /var/log/quagga/zebra.log
nameserver 8.8.8.8
nameserver 8.8.4.4
rm -rf MulticastRouting/
cp -rf /hosthome/Desktop/pim_code/ MulticastRouting/
cd MulticastRouting
pip-3.2 install -r requirements.txt
python3 Run.py -stop
python3 Run.py -start
python3 Run.py -ai eth0
python3 Run.py -v
topology.png

9.87 KB | W: | H:

topology.png

27.3 KB | W: | H:

topology.png
topology.png
topology.png
topology.png
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment