Browse Source

Merge branch 'master' of ssh://git@gogs.informatik.hs-fulda.de/srieger/git-virl-hs-fulda.git

master
Sebastian Rieger 8 years ago
parent
commit
94ac927285
  1. 12
      GIT-VIRL-HS-Fulda/Advanced Computer Networks (Master AI)/advcompnet-lab3-sdn-lxc.virl
  2. 293
      GIT-VIRL-HS-Fulda/Advanced Computer Networks (Master AI)/advcompnet-lab3-sdn.virl
  3. 336
      GIT-VIRL-HS-Fulda/Kommunikationsnetze und -protokolle (Bachelor AI)/kommprot-lab3-clientserverapp.virl

12
GIT-VIRL-HS-Fulda/Advanced Computer Networks (Master AI)/advcompnet-lab3-sdn-lxc.virl

@ -220,8 +220,16 @@ write_files:
owner: root:root
permissions: '0755'
content: |-
#!/bin/sh -e
mkdir /tmp/d
ebs
#!/bin/bash
# sudo check
if [ ! $UID -eq 0 ] ; then
echo "Root-Berechtigungen erforderlich. Bitte sudo benutzen."
exit -1
fi
rm -rf /tmp/debs
mkdir /tmp/debs
cd /tmp/debs
wget http://mmnet.informatik.hs-fulda.de/opendaylight-dep-debs.tar.gz

293
GIT-VIRL-HS-Fulda/Advanced Computer Networks (Master AI)/advcompnet-lab3-sdn.virl

@ -1,293 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<topology xmlns="http://www.cisco.com/VIRL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="0.9" xsi:schemaLocation="http://www.cisco.com/VIRL https://raw.github.com/CiscoVIRL/schema/v0.9/virl.xsd">
<extensions>
<entry key="management_network" type="String">exclusive</entry>
</extensions>
<node name="client" type="SIMPLE" subtype="server" location="387,214" ipv4="10.10.20.10">
<extensions>
<entry key="config" type="String">#cloud-config&#xD;
bootcmd:&#xD;
- ln -s -t /etc/rc.d /etc/rc.local&#xD;
hostname: client&#xD;
manage_etc_hosts: true&#xD;
runcmd:&#xD;
- start ttyS0&#xD;
- systemctl start getty@ttyS0.service&#xD;
- systemctl start rc-local&#xD;
- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config&#xD;
- echo "UseDNS no" &gt;&gt; /etc/ssh/sshd_config&#xD;
- service ssh restart&#xD;
- service sshd restart&#xD;
users:&#xD;
- default&#xD;
- gecos: User configured by VIRL Configuration Engine 0.15.8&#xD;
lock-passwd: false&#xD;
name: cisco&#xD;
plain-text-passwd: cisco&#xD;
shell: /bin/bash&#xD;
ssh-authorized-keys:&#xD;
- VIRL-USER-SSH-PUBLIC-KEY&#xD;
sudo: ALL=(ALL) ALL&#xD;
packages:&#xD;
- joe&#xD;
- iperf&#xD;
write_files:&#xD;
- path: /etc/init/ttyS0.conf&#xD;
owner: root:root&#xD;
content: |&#xD;
# ttyS0 - getty&#xD;
# This service maintains a getty on ttyS0 from the point the system is&#xD;
# started until it is shut down again.&#xD;
start on stopped rc or RUNLEVEL=[12345]&#xD;
stop on runlevel [!12345]&#xD;
respawn&#xD;
exec /sbin/getty -L 115200 ttyS0 vt102&#xD;
permissions: '0644'&#xD;
- path: /etc/systemd/system/dhclient@.service&#xD;
content: |&#xD;
[Unit]&#xD;
Description=Run dhclient on %i interface&#xD;
After=network.target&#xD;
[Service]&#xD;
Type=oneshot&#xD;
ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease&#xD;
RemainAfterExit=yes&#xD;
owner: root:root&#xD;
permissions: '0644'&#xD;
- path: /etc/rc.local&#xD;
owner: root:root&#xD;
permissions: '0755'&#xD;
content: |-&#xD;
#!/bin/sh -e&#xD;
ifconfig eth1 up 10.10.20.10 netmask 255.255.255.0&#xD;
exit 0&#xD;
</entry>
</extensions>
<interface id="0" name="eth1" ipv4="10.0.0.9" netPrefixLenV4="30"/>
</node>
<node name="server" type="SIMPLE" subtype="server" location="673,214" ipv4="10.10.20.20">
<extensions>
<entry key="config" type="String">#cloud-config&#xD;
bootcmd:&#xD;
- ln -s -t /etc/rc.d /etc/rc.local&#xD;
hostname: server&#xD;
manage_etc_hosts: true&#xD;
runcmd:&#xD;
- start ttyS0&#xD;
- systemctl start getty@ttyS0.service&#xD;
- systemctl start rc-local&#xD;
- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config&#xD;
- echo "UseDNS no" &gt;&gt; /etc/ssh/sshd_config&#xD;
- service ssh restart&#xD;
- service sshd restart&#xD;
users:&#xD;
- default&#xD;
- gecos: User configured by VIRL Configuration Engine 0.15.8&#xD;
lock-passwd: false&#xD;
name: cisco&#xD;
plain-text-passwd: cisco&#xD;
shell: /bin/bash&#xD;
ssh-authorized-keys:&#xD;
- VIRL-USER-SSH-PUBLIC-KEY&#xD;
sudo: ALL=(ALL) ALL&#xD;
packages:&#xD;
- joe&#xD;
- iperf&#xD;
- apache2&#xD;
write_files:&#xD;
- path: /etc/init/ttyS0.conf&#xD;
owner: root:root&#xD;
content: |&#xD;
# ttyS0 - getty&#xD;
# This service maintains a getty on ttyS0 from the point the system is&#xD;
# started until it is shut down again.&#xD;
start on stopped rc or RUNLEVEL=[12345]&#xD;
stop on runlevel [!12345]&#xD;
respawn&#xD;
exec /sbin/getty -L 115200 ttyS0 vt102&#xD;
permissions: '0644'&#xD;
- path: /etc/systemd/system/dhclient@.service&#xD;
content: |&#xD;
[Unit]&#xD;
Description=Run dhclient on %i interface&#xD;
After=network.target&#xD;
[Service]&#xD;
Type=oneshot&#xD;
ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease&#xD;
RemainAfterExit=yes&#xD;
owner: root:root&#xD;
permissions: '0644'&#xD;
- path: /etc/rc.local&#xD;
owner: root:root&#xD;
permissions: '0755'&#xD;
content: |-&#xD;
#!/bin/sh -e&#xD;
ifconfig eth1 up 10.10.20.20 netmask 255.255.255.0&#xD;
exit 0&#xD;
</entry>
</extensions>
<interface id="0" name="eth1" ipv4="10.0.0.5" netPrefixLenV4="30"/>
</node>
<node name="controller" type="SIMPLE" subtype="server" location="506,54" vmFlavor="server-medium [9094074e-b640-4fd7-b296-efa4ddaca4c5]" ipv4="10.10.10.254">
<extensions>
<entry key="config" type="String">#cloud-config&#xD;
bootcmd:&#xD;
- ln -s -t /etc/rc.d /etc/rc.local&#xD;
hostname: controller&#xD;
manage_etc_hosts: true&#xD;
runcmd:&#xD;
- start ttyS0&#xD;
- systemctl start getty@ttyS0.service&#xD;
- systemctl start rc-local&#xD;
- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config&#xD;
- echo "UseDNS no" &gt;&gt; /etc/ssh/sshd_config&#xD;
- service ssh restart&#xD;
- service sshd restart&#xD;
- /tmp/install-odl&#xD;
users:&#xD;
- default&#xD;
- gecos: User configured by VIRL Configuration Engine 0.15.8&#xD;
lock-passwd: false&#xD;
name: cisco&#xD;
plain-text-passwd: cisco&#xD;
shell: /bin/bash&#xD;
ssh-authorized-keys:&#xD;
- VIRL-USER-SSH-PUBLIC-KEY&#xD;
sudo: ALL=(ALL) ALL&#xD;
write_files:&#xD;
- path: /etc/init/ttyS0.conf&#xD;
owner: root:root&#xD;
content: |&#xD;
# ttyS0 - getty&#xD;
# This service maintains a getty on ttyS0 from the point the system is&#xD;
# started until it is shut down again.&#xD;
start on stopped rc or RUNLEVEL=[12345]&#xD;
stop on runlevel [!12345]&#xD;
respawn&#xD;
exec /sbin/getty -L 115200 ttyS0 vt102&#xD;
permissions: '0644'&#xD;
- path: /etc/systemd/system/dhclient@.service&#xD;
content: |&#xD;
[Unit]&#xD;
Description=Run dhclient on %i interface&#xD;
After=network.target&#xD;
[Service]&#xD;
Type=oneshot&#xD;
ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease&#xD;
RemainAfterExit=yes&#xD;
owner: root:root&#xD;
permissions: '0644'&#xD;
- path: /etc/rc.local&#xD;
owner: root:root&#xD;
permissions: '0755'&#xD;
content: |-&#xD;
#!/bin/sh -e&#xD;
ifconfig eth1 up 10.10.10.254 netmask 255.255.255.0&#xD;
ifconfig eth2 up&#xD;
dhclient eth2&#xD;
# set default gateway to VIRL host in flat1 &#xD;
route del -net default&#xD;
route add -net default gw 172.16.1.254&#xD;
# enable routing and NAT for 10.10.0.0/16&#xD;
sysctl -w net.ipv4.ip_forward=1&#xD;
iptables -A POSTROUTING -t nat -s 10.10.0.0/16 -o eth2 -j MASQUERADE&#xD;
exit 0&#xD;
- path: /tmp/install-odl&#xD;
owner: root:root&#xD;
permissions: '0755'&#xD;
content: |-&#xD;
#!/bin/sh -e&#xD;
apt-get update&#xD;
apt-get install -y joe iperf unzip openjdk-7-jre-headless&#xD;
#mkdir /tmp/d&#xD;ebs&#xD;
#cd /tmp/debs&#xD;
#wget http://mmnet.informatik.hs-fulda.de/opendaylight-dep-debs.tar.gz&#xD;
#tar zxvf opendaylight-dep-debs.tar.gz&#xD;
#dpkg -i *.deb&#xD;
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre/&#xD;
echo "export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre/" &gt;/etc/profile.d/Z99-java-home.sh&#xD;
# setup opendaylight controller&#xD;
#################&#xD;
# Hydrogen&#xD;
#################&#xD;
cd /tmp&#xD;
wget http://mmnet.informatik.hs-fulda.de/distributions-base-0.1.1-osgipackage.zip&#xD;
unzip distributions-base-0.1.1-osgipackage.zip&#xD;
#################&#xD;
# Lithium&#xD;
#################&#xD;
#wget http://mmnet.informatik.hs-fulda.de/distribution-karaf-0.3.0-Lithium.tar.gz&#xD;
#tar zxf distribution-karaf-0.3.0-Lithium.tar.gz&#xD;
#echo -e "feature:install odl-restconf odl-l2switch-switch odl-mdsal-apidocs odl-dlux-core odl-dlux-node odl-dlux-yangui\nlogout" | ./distribution-karaf-0.3.0-Lithium/bin/karaf&#xD;
#./distribution-karaf-0.3.0-Lithium/bin/start&#xD;
#&#xD;
#################&#xD;
# LXDE&#xD;
#################&#xD;
# apt-get -y install midori lxde wireshark&#xD;
exit 0</entry>
</extensions>
<interface id="0" name="eth1" ipv4="10.0.0.13" netPrefixLenV4="30"/>
<interface id="1" name="eth2"/>
</node>
<node name="veos-1" type="SIMPLE" subtype="vEOS" location="514,148" ipv4="10.10.10.253">
<extensions>
<entry key="Auto-generate config" type="Boolean">false</entry>
<entry key="config" type="String">! Command: show running-config&#xD;
! device: vEOS-1 (vEOS, EOS-4.14.2F)&#xD;
!&#xD;
! boot system flash:/vEOS.swi&#xD;
!&#xD;
! AdvCompNet Lab 2 SDN&#xD;
!&#xD;
transceiver qsfp default-mode 4x10G&#xD;
!&#xD;
hostname veos-1&#xD;
!&#xD;
openflow&#xD;
description SDN-OpenFlow-Lab&#xD;
controller tcp:10.10.10.254:6633&#xD;
bind interface Ethernet1&#xD;
bind interface Ethernet2&#xD;
!&#xD;
spanning-tree mode mstp&#xD;
!&#xD;
no aaa root&#xD;
!&#xD;
username admin privilege 15 role network-admin secret 5 $1$S4W0XejC$69vFakMKc/k9N.nrrTiIY/&#xD;
username cisco privilege 15 role network-admin secret 5 $1$rQS0W9wP$ZUzVG2XoGCCZCJopFp1aV/&#xD;
!&#xD;
vlan 10&#xD;
!&#xD;
interface Ethernet1&#xD;
!&#xD;
interface Ethernet2&#xD;
!&#xD;
interface Ethernet3&#xD;
switchport access vlan 10&#xD;
!&#xD;
interface Management1&#xD;
! ip of ma1 configured on launch&#xD;
!&#xD;
interface Vlan10&#xD;
ip address 10.10.10.253/24&#xD;
!&#xD;
no ip routing&#xD;
ip route 0.0.0.0 0.0.0.0 10.10.10.254&#xD;
!&#xD;
!&#xD;
end</entry>
</extensions>
<interface id="0" name="Ethernet1" ipv4="10.0.0.10" netPrefixLenV4="30"/>
<interface id="1" name="Ethernet2" ipv4="10.0.0.6" netPrefixLenV4="30"/>
<interface id="2" name="Ethernet3" ipv4="10.0.0.14" netPrefixLenV4="30"/>
</node>
<node name="flat-1" type="ASSET" subtype="FLAT" location="411,38">
<interface id="0" name="link0"/>
</node>
<connection dst="/virl:topology/virl:node[1]/virl:interface[1]" src="/virl:topology/virl:node[4]/virl:interface[1]"/>
<connection dst="/virl:topology/virl:node[2]/virl:interface[1]" src="/virl:topology/virl:node[4]/virl:interface[2]"/>
<connection dst="/virl:topology/virl:node[3]/virl:interface[1]" src="/virl:topology/virl:node[4]/virl:interface[3]"/>
<connection dst="/virl:topology/virl:node[5]/virl:interface[1]" src="/virl:topology/virl:node[3]/virl:interface[2]"/>
</topology>

336
GIT-VIRL-HS-Fulda/Kommunikationsnetze und -protokolle (Bachelor AI)/kommprot-lab3-clientserverapp.virl

@ -9,7 +9,7 @@
<entry key="config" type="String">#cloud-config&#xD;
bootcmd:&#xD;
- ln -s -t /etc/rc.d /etc/rc.local&#xD;
hostname: client&#xD;
hostname: client1&#xD;
manage_etc_hosts: true&#xD;
runcmd:&#xD;
- systemctl start rc-local&#xD;
@ -46,14 +46,37 @@ write_files:&#xD;
#!/bin/sh&#xD;
ifconfig eth1 up 10.0.0.20 netmask 255.255.0.0&#xD;
route add -host 192.168.0.1 gw 10.0.0.1 dev eth1&#xD;
route add -net 10.0.0.0/16 gw 10.0.0.1 dev eth1&#xD;
route add default gw 10.0.0.1&#xD;
echo "nameserver 8.8.8.8" &gt;/etc/resolv.conf&#xD;
chown -R cisco:cisco /home/cisco&#xD;
exit 0&#xD;
- path: /home/cisco/udpserver.py&#xD;
owner: cisco:cisco&#xD;
permissions: '0755'&#xD;
content: |-&#xD;
- path: /home/cisco/udp-client.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
&#xD;
# Server-Adresse und Port&#xD;
serverName = "localhost"&#xD;
serverPort = 17000&#xD;
&#xD;
# Client Socket (IP, UDP) oeffnen&#xD;
clientSocket = socket(AF_INET, SOCK_DGRAM)&#xD;
&#xD;
# Nachricht vom Benutzer erfragen und versenden&#xD;
message = raw_input("UDP Nachricht in Kleinbuchstaben eingeben:")&#xD;
clientSocket.sendto(message,(serverName, serverPort))&#xD;
&#xD;
# Antwort des Server aus Socket lesen und ausgeben&#xD;
modifiedMessage, serverAddress = clientSocket.recvfrom(2048)&#xD;
print "Antwort des Servers: ", modifiedMessage&#xD;
raw_input("Fertig...")&#xD;
&#xD;
# Verbindung schliessen&#xD;
clientSocket.close()&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
- path: /home/cisco/udp-server.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
&#xD;
@ -73,35 +96,35 @@ write_files:&#xD;
# Client zuruecksenden&#xD;
modifiedMessage = message.upper()&#xD;
serverSocket.sendto(modifiedMessage, clientAddress)&#xD;
- path: /home/cisco/udpclient.py&#xD;
owner: cisco:cisco&#xD;
permissions: '0755'&#xD;
content: |-&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
- path: /home/cisco/tcp-client.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
&#xD;
# Server-Adresse und Port&#xD;
# Serveradresse und TCP Port auf den der Server hoert...&#xD;
serverName = "localhost"&#xD;
serverPort = 17000&#xD;
# Socket fuer IP (INET) und TCP (STREAM) konfigurieren&#xD;
clientSocket = socket(AF_INET, SOCK_STREAM)&#xD;
clientSocket.connect((serverName,serverPort))&#xD;
&#xD;
# Client Socket (IP, UDP) oeffnen&#xD;
clientSocket = socket(AF_INET, SOCK_DGRAM)&#xD;
&#xD;
# Nachricht vom Benutzer erfragen und versenden&#xD;
message = raw_input("UDP Nachricht in Kleinbuchstaben eingeben:")&#xD;
clientSocket.sendto(message,(serverName, serverPort))&#xD;
# Nachricht vom Benutzer abfragen und an den Server senden&#xD;
sentence = raw_input("TCP Nachricht in Kleinbuchstaben eingeben:")&#xD;
clientSocket.send(sentence)&#xD;
&#xD;
# Antwort des Server aus Socket lesen und ausgeben&#xD;
modifiedMessage, serverAddress = clientSocket.recvfrom(2048)&#xD;
print "Antwort des Servers: ", modifiedMessage&#xD;
# Antwort des Servers ausgeben&#xD;
modifiedSentence = clientSocket.recv(1024)&#xD;
print "Antwort des Servers:", modifiedSentence&#xD;
raw_input("Fertig...")&#xD;
&#xD;
# Verbindung schliessen&#xD;
clientSocket.close()&#xD;
- path: /home/cisco/tcpserver.py&#xD;
owner: cisco:cisco&#xD;
permissions: '0755'&#xD;
content: |-&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
- path: /home/cisco/tcp-server.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
&#xD;
@ -124,31 +147,61 @@ write_files:&#xD;
connectionSocket.send(capitalizedSentence)&#xD;
# Verbindung schliessen&#xD;
connectionSocket.close()&#xD;
- path: /home/cisco/tcpclient.py&#xD;
owner: cisco:cisco&#xD;
permissions: '0755'&#xD;
content: |-&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
- path: /home/cisco/tcpdownload-client.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
import time&#xD;
&#xD;
# Serveradresse und TCP Port auf den der Server hoert...&#xD;
serverName = "localhost"&#xD;
serverName = "10.0.0.30"&#xD;
serverPort = 17000&#xD;
# Socket fuer IP (INET) und TCP (STREAM) konfigurieren&#xD;
clientSocket = socket(AF_INET, SOCK_STREAM)&#xD;
clientSocket.connect((serverName,serverPort))&#xD;
&#xD;
# Nachricht vom Benutzer abfragen und an den Server senden&#xD;
sentence = raw_input("TCP Nachricht in Kleinbuchstaben eingeben:")&#xD;
clientSocket.send(sentence)&#xD;
&#xD;
# Antwort des Servers ausgeben&#xD;
modifiedSentence = clientSocket.recv(1024)&#xD;
print "Antwort des Servers:", modifiedSentence&#xD;
length = 0&#xD;
start = time.time()&#xD;
while 1:&#xD;
data = clientSocket.recv(1024)&#xD;
if not data:&#xD;
break&#xD;
length += len(data)&#xD;
elapsed = time.time() - start&#xD;
print str(length) + " Bytes geladen in " + str(elapsed) + " secs (" + str(length / elapsed) + " bytes/s)"&#xD;
raw_input("Fertig...")&#xD;
&#xD;
# Verbindung schliessen&#xD;
clientSocket.close()&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
- path: /home/cisco/tcpdownload-server.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
&#xD;
# TCP Port auf dem der Server lauschen soll...&#xD;
serverPort = 17000&#xD;
# Server-Socket als Internet (INET) TCP (STREAM) erzeugen und an o.g. Port binden&#xD;
serverSocket = socket(AF_INET,SOCK_STREAM)&#xD;
serverSocket.bind(("",serverPort))&#xD;
serverSocket.listen(1)&#xD;
downloadSize = raw_input("Download-Groesse: ")&#xD;
print "TCP Server ist bereit fuer den Download..."&#xD;
&#xD;
# Endlosschleife&#xD;
while 1:&#xD;
# Eingehende Nachrichten akzeptieren und von Clients empfangen&#xD;
connectionSocket, addr = serverSocket.accept()&#xD;
# Bytes an Client zuruecksenden&#xD;
connectionSocket.send("a" * int(downloadSize))&#xD;
# Verbindung schliessen&#xD;
connectionSocket.close()&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
</entry>
</extensions>
<interface id="0" name="eth1" ipv4="10.0.0.2" netPrefixLenV4="16"/>
@ -158,7 +211,7 @@ write_files:&#xD;
<entry key="config" type="String">#cloud-config&#xD;
bootcmd:&#xD;
- ln -s -t /etc/rc.d /etc/rc.local&#xD;
hostname: server&#xD;
hostname: server1&#xD;
manage_etc_hosts: true&#xD;
runcmd:&#xD;
- systemctl start rc-local&#xD;
@ -195,20 +248,225 @@ write_files:&#xD;
#!/bin/sh&#xD;
ifconfig eth1 up 10.0.0.30 netmask 255.255.0.0&#xD;
route add -host 192.168.0.1 gw 10.0.0.1 dev eth1&#xD;
route add -net 10.0.0.0/16 gw 10.0.0.1 dev eth1&#xD;
route add default gw 10.0.0.1&#xD;
echo "nameserver 8.8.8.8" &gt;/etc/resolv.conf&#xD;
chown -R cisco:cisco /home/cisco&#xD;
exit 0&#xD;
- path: /home/cisco/udpclient.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
&#xD;
# Server-Adresse und Port&#xD;
serverName = "localhost"&#xD;
serverPort = 17000&#xD;
&#xD;
# Client Socket (IP, UDP) oeffnen&#xD;
clientSocket = socket(AF_INET, SOCK_DGRAM)&#xD;
&#xD;
# Nachricht vom Benutzer erfragen und versenden&#xD;
message = raw_input("UDP Nachricht in Kleinbuchstaben eingeben:")&#xD;
clientSocket.sendto(message,(serverName, serverPort))&#xD;
&#xD;
# Antwort des Server aus Socket lesen und ausgeben&#xD;
modifiedMessage, serverAddress = clientSocket.recvfrom(2048)&#xD;
print "Antwort des Servers: ", modifiedMessage&#xD;
raw_input("Fertig...")&#xD;
&#xD;
# Verbindung schliessen&#xD;
clientSocket.close()&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
- path: /home/cisco/udpserver.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
&#xD;
# UDP Port auf dem der Server lauschen soll...&#xD;
serverPort = 17000&#xD;
&#xD;
# Server-Socket als Internet (INET) UDP (DGRAM) erzeugen und an o.g. Port binden&#xD;
serverSocket = socket(AF_INET, SOCK_DGRAM)&#xD;
serverSocket.bind(("", serverPort))&#xD;
print "UDP Server ist bereit fuer den Empfang von Daten..."&#xD;
&#xD;
# Endlosschleife&#xD;
while 1:&#xD;
# Eingehende Nachrichten von Clients empfangen&#xD;
message, clientAddress = serverSocket.recvfrom(2048)&#xD;
# Alle Buchstaben der Nachricht in Grossbuchstaben umwandeln und an den&#xD;
# Client zuruecksenden&#xD;
modifiedMessage = message.upper()&#xD;
serverSocket.sendto(modifiedMessage, clientAddress)&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
- path: /home/cisco/tcpclient.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
&#xD;
# Serveradresse und TCP Port auf den der Server hoert...&#xD;
serverName = "localhost"&#xD;
serverPort = 17000&#xD;
# Socket fuer IP (INET) und TCP (STREAM) konfigurieren&#xD;
clientSocket = socket(AF_INET, SOCK_STREAM)&#xD;
clientSocket.connect((serverName,serverPort))&#xD;
&#xD;
# Nachricht vom Benutzer abfragen und an den Server senden&#xD;
sentence = raw_input("TCP Nachricht in Kleinbuchstaben eingeben:")&#xD;
clientSocket.send(sentence)&#xD;
&#xD;
# Antwort des Servers ausgeben&#xD;
modifiedSentence = clientSocket.recv(1024)&#xD;
print "Antwort des Servers:", modifiedSentence&#xD;
raw_input("Fertig...")&#xD;
&#xD;
# Verbindung schliessen&#xD;
clientSocket.close()&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
- path: /home/cisco/tcpserver.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
&#xD;
# TCP Port auf dem der Server lauschen soll...&#xD;
serverPort = 17000&#xD;
# Server-Socket als Internet (INET) TCP (STREAM) erzeugen und an o.g. Port binden&#xD;
serverSocket = socket(AF_INET,SOCK_STREAM)&#xD;
serverSocket.bind(("",serverPort))&#xD;
serverSocket.listen(1)&#xD;
print "TCP Server ist bereit fuer den Empfang von Daten..."&#xD;
&#xD;
# Endlosschleife&#xD;
while 1:&#xD;
# Eingehende Nachrichten akzeptieren und von Clients empfangen&#xD;
connectionSocket, addr = serverSocket.accept()&#xD;
sentence = connectionSocket.recv(1024)&#xD;
# Alle Buchstaben der Nachricht in Grossbuchstaben umwandeln und an den&#xD;
# Client zuruecksenden&#xD;
capitalizedSentence = sentence.upper()&#xD;
connectionSocket.send(capitalizedSentence)&#xD;
# Verbindung schliessen&#xD;
connectionSocket.close()&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
- path: /home/cisco/tcpclient-download.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
import time&#xD;
&#xD;
# Serveradresse und TCP Port auf den der Server hoert...&#xD;
serverName = "10.0.0.30"&#xD;
serverPort = 17000&#xD;
# Socket fuer IP (INET) und TCP (STREAM) konfigurieren&#xD;
clientSocket = socket(AF_INET, SOCK_STREAM)&#xD;
clientSocket.connect((serverName,serverPort))&#xD;
&#xD;
# Antwort des Servers ausgeben&#xD;
length = 0&#xD;
start = time.time()&#xD;
while 1:&#xD;
data = clientSocket.recv(1024)&#xD;
if not data:&#xD;
break&#xD;
length += len(data)&#xD;
elapsed = time.time() - start&#xD;
print str(length) + " Bytes geladen in " + str(elapsed) + " secs (" + str(length / elapsed) + " bytes/s)"&#xD;
raw_input("Fertig...")&#xD;
&#xD;
# Verbindung schliessen&#xD;
clientSocket.close()&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
- path: /home/cisco/tcpserver-download.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
&#xD;
# TCP Port auf dem der Server lauschen soll...&#xD;
serverPort = 17000&#xD;
# Server-Socket als Internet (INET) TCP (STREAM) erzeugen und an o.g. Port binden&#xD;
serverSocket = socket(AF_INET,SOCK_STREAM)&#xD;
serverSocket.bind(("",serverPort))&#xD;
serverSocket.listen(1)&#xD;
downloadSize = raw_input("Download-Groesse: ")&#xD;
print "TCP Server ist bereit fuer den Download..."&#xD;
&#xD;
# Endlosschleife&#xD;
while 1:&#xD;
# Eingehende Nachrichten akzeptieren und von Clients empfangen&#xD;
connectionSocket, addr = serverSocket.accept()&#xD;
# Bytes an Client zuruecksenden&#xD;
connectionSocket.send("a" * int(downloadSize))&#xD;
# Verbindung schliessen&#xD;
connectionSocket.close()&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
- path: /home/cisco/tcpdownload-client.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
import time&#xD;
&#xD;
# Serveradresse und TCP Port auf den der Server hoert...&#xD;
serverName = "10.0.0.30"&#xD;
serverPort = 17000&#xD;
# Socket fuer IP (INET) und TCP (STREAM) konfigurieren&#xD;
clientSocket = socket(AF_INET, SOCK_STREAM)&#xD;
clientSocket.connect((serverName,serverPort))&#xD;
&#xD;
# Antwort des Servers ausgeben&#xD;
length = 0&#xD;
start = time.time()&#xD;
while 1:&#xD;
data = clientSocket.recv(1024)&#xD;
if not data:&#xD;
break&#xD;
length += len(data)&#xD;
elapsed = time.time() - start&#xD;
print str(length) + " Bytes geladen in " + str(elapsed) + " secs (" + str(length / elapsed) + " bytes/s)"&#xD;
raw_input("Fertig...")&#xD;
&#xD;
# Verbindung schliessen&#xD;
clientSocket.close()&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
- path: /home/cisco/tcpdownload-server.py&#xD;
content: |&#xD;
#!/usr/bin/python&#xD;
from socket import *&#xD;
&#xD;
# TCP Port auf dem der Server lauschen soll...&#xD;
serverPort = 17000&#xD;
# Server-Socket als Internet (INET) TCP (STREAM) erzeugen und an o.g. Port binden&#xD;
serverSocket = socket(AF_INET,SOCK_STREAM)&#xD;
serverSocket.bind(("",serverPort))&#xD;
serverSocket.listen(1)&#xD;
downloadSize = raw_input("Download-Groesse: ")&#xD;
print "TCP Server ist bereit fuer den Download..."&#xD;
&#xD;
# Endlosschleife&#xD;
while 1:&#xD;
# Eingehende Nachrichten akzeptieren und von Clients empfangen&#xD;
connectionSocket, addr = serverSocket.accept()&#xD;
# Bytes an Client zuruecksenden&#xD;
connectionSocket.send("a" * int(downloadSize))&#xD;
# Verbindung schliessen&#xD;
connectionSocket.close()&#xD;
owner: root:root&#xD;
permissions: '0777'&#xD;
</entry>
</extensions>
<interface id="0" name="eth1" ipv4="10.0.0.3" netPrefixLenV4="16"/>
</node>
<node name="switch1" type="SIMPLE" subtype="Unmanaged Switch" location="446,227">
<node name="switch1" type="SIMPLE" subtype="Unmanaged Switch" location="459,232">
<interface id="0" name="link1"/>
<interface id="1" name="link2"/>
<interface id="2" name="link3"/>
</node>
<node name="router1" type="SIMPLE" subtype="IOSv" location="446,106">
<node name="router1" type="SIMPLE" subtype="IOSv" location="459,111">
<extensions>
<entry key="AutoNetkit.mgmt_ip" type="string"></entry>
<entry key="Auto-generate config" type="Boolean">false</entry>

Loading…
Cancel
Save