Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
git-virl-hs-fulda
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Rieger
git-virl-hs-fulda
Commits
3fb8b72e
Commit
3fb8b72e
authored
8 years ago
by
Sebastian Rieger
Browse files
Options
Downloads
Patches
Plain Diff
sample python socket app
parent
fca47d9e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
GIT-VIRL-HS-Fulda/Kommunikationsnetze und -protokolle (Bachelor AI)/kommprot-lab3-clientserverapp.virl
+315
-0
315 additions, 0 deletions
...otokolle (Bachelor AI)/kommprot-lab3-clientserverapp.virl
with
315 additions
and
0 deletions
GIT-VIRL-HS-Fulda/Kommunikationsnetze und -protokolle (Bachelor AI)/kommprot-lab3-clientserverapp.virl
0 → 100644
+
315
−
0
View file @
3fb8b72e
<?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.95"
xsi:schemaLocation=
"http://www.cisco.com/VIRL https://raw.github.com/CiscoVIRL/schema/v0.95/virl.xsd"
>
<extensions>
<entry
key=
"management_network"
type=
"String"
>
exclusive
</entry>
<entry
key=
"AutoNetkit.enable_cdp"
type=
"Boolean"
>
true
</entry>
</extensions>
<node
name=
"client1"
type=
"SIMPLE"
subtype=
"lxc"
location=
"340,301"
>
<extensions>
<entry
key=
"config"
type=
"String"
>
#cloud-config

bootcmd:

- ln -s -t /etc/rc.d /etc/rc.local

hostname: client

manage_etc_hosts: true

runcmd:

- systemctl start rc-local

- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config

- echo "UseDNS no"
>>
/etc/ssh/sshd_config

- service ssh restart

- service sshd restart

users:

- default

- gecos: User configured by VIRL Configuration Engine 0.23.9

lock-passwd: false

name: cisco

plain-text-passwd: cisco

shell: /bin/bash

ssh-authorized-keys:

- VIRL-USER-SSH-PUBLIC-KEY

sudo: ALL=(ALL) ALL

write_files:

- path: /etc/systemd/system/dhclient@.service

content: |

[Unit]

Description=Run dhclient on %i interface

After=network.target

[Service]

Type=oneshot

ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease

RemainAfterExit=yes

owner: root:root

permissions: '0644'

- path: /etc/rc.local

owner: root:root

permissions: '0755'

content: |-

#!/bin/sh

ifconfig eth1 up 10.0.0.20 netmask 255.255.0.0

route add -host 192.168.0.1 gw 10.0.0.1 dev eth1

route add -net 10.0.0.0/16 gw 10.0.0.1 dev eth1

route add default gw 10.0.0.1

echo "nameserver 8.8.8.8"
>
/etc/resolv.conf

exit 0

- path: /home/cisco/udpserver.py

owner: cisco:cisco

permissions: '0755'

content: |-

#!/usr/bin/python

from socket import *


# UDP Port auf dem der Server lauschen soll...

serverPort = 17000


# Server-Socket als Internet (INET) UDP (DGRAM) erzeugen und an o.g. Port binden

serverSocket = socket(AF_INET, SOCK_DGRAM)

serverSocket.bind(("", serverPort))

print "UDP Server ist bereit fuer den Empfang von Daten..."


# Endlosschleife

while 1:

# Eingehende Nachrichten von Clients empfangen

message, clientAddress = serverSocket.recvfrom(2048)

# Alle Buchstaben der Nachricht in Grossbuchstaben umwandeln und an den

# Client zuruecksenden

modifiedMessage = message.upper()

serverSocket.sendto(modifiedMessage, clientAddress)

- path: /home/cisco/udpclient.py

owner: cisco:cisco

permissions: '0755'

content: |-

#!/usr/bin/python

from socket import *


# Server-Adresse und Port

serverName = "localhost"

serverPort = 17000


# Client Socket (IP, UDP) oeffnen

clientSocket = socket(AF_INET, SOCK_DGRAM)


# Nachricht vom Benutzer erfragen und versenden

message = raw_input("UDP Nachricht in Kleinbuchstaben eingeben:")

clientSocket.sendto(message,(serverName, serverPort))


# Antwort des Server aus Socket lesen und ausgeben

modifiedMessage, serverAddress = clientSocket.recvfrom(2048)

print "Antwort des Servers: ", modifiedMessage

raw_input("Fertig...")


# Verbindung schliessen

clientSocket.close()

- path: /home/cisco/tcpserver.py

owner: cisco:cisco

permissions: '0755'

content: |-

#!/usr/bin/python

from socket import *


# TCP Port auf dem der Server lauschen soll...

serverPort = 17000

# Server-Socket als Internet (INET) TCP (STREAM) erzeugen und an o.g. Port binden

serverSocket = socket(AF_INET,SOCK_STREAM)

serverSocket.bind(("",serverPort))

serverSocket.listen(1)

print "TCP Server ist bereit fuer den Empfang von Daten..."


# Endlosschleife

while 1:

# Eingehende Nachrichten akzeptieren und von Clients empfangen

connectionSocket, addr = serverSocket.accept()

sentence = connectionSocket.recv(1024)

# Alle Buchstaben der Nachricht in Grossbuchstaben umwandeln und an den

# Client zuruecksenden

capitalizedSentence = sentence.upper()

connectionSocket.send(capitalizedSentence)

# Verbindung schliessen

connectionSocket.close()

- path: /home/cisco/tcpclient.py

owner: cisco:cisco

permissions: '0755'

content: |-

#!/usr/bin/python

from socket import *


# Serveradresse und TCP Port auf den der Server hoert...

serverName = "localhost"

serverPort = 17000

# Socket fuer IP (INET) und TCP (STREAM) konfigurieren

clientSocket = socket(AF_INET, SOCK_STREAM)

clientSocket.connect((serverName,serverPort))


# Nachricht vom Benutzer abfragen und an den Server senden

sentence = raw_input("TCP Nachricht in Kleinbuchstaben eingeben:")

clientSocket.send(sentence)


# Antwort des Servers ausgeben

modifiedSentence = clientSocket.recv(1024)

print "Antwort des Servers:", modifiedSentence

raw_input("Fertig...")


# Verbindung schliessen

clientSocket.close()

</entry>
</extensions>
<interface
id=
"0"
name=
"eth1"
ipv4=
"10.0.0.2"
netPrefixLenV4=
"16"
/>
</node>
<node
name=
"server1"
type=
"SIMPLE"
subtype=
"lxc"
location=
"584,301"
>
<extensions>
<entry
key=
"config"
type=
"String"
>
#cloud-config

bootcmd:

- ln -s -t /etc/rc.d /etc/rc.local

hostname: server

manage_etc_hosts: true

runcmd:

- systemctl start rc-local

- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config

- echo "UseDNS no"
>>
/etc/ssh/sshd_config

- service ssh restart

- service sshd restart

users:

- default

- gecos: User configured by VIRL Configuration Engine 0.23.9

lock-passwd: false

name: cisco

plain-text-passwd: cisco

shell: /bin/bash

ssh-authorized-keys:

- VIRL-USER-SSH-PUBLIC-KEY

sudo: ALL=(ALL) ALL

write_files:

- path: /etc/systemd/system/dhclient@.service

content: |

[Unit]

Description=Run dhclient on %i interface

After=network.target

[Service]

Type=oneshot

ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease

RemainAfterExit=yes

owner: root:root

permissions: '0644'

- path: /etc/rc.local

owner: root:root

permissions: '0755'

content: |-

#!/bin/sh

ifconfig eth1 up 10.0.0.30 netmask 255.255.0.0

route add -host 192.168.0.1 gw 10.0.0.1 dev eth1

route add -net 10.0.0.0/16 gw 10.0.0.1 dev eth1

route add default gw 10.0.0.1

echo "nameserver 8.8.8.8"
>
/etc/resolv.conf

exit 0

</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"
>
<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"
>
<extensions>
<entry
key=
"AutoNetkit.mgmt_ip"
type=
"string"
></entry>
<entry
key=
"Auto-generate config"
type=
"Boolean"
>
false
</entry>
<entry
key=
"config"
type=
"String"
>
! IOS Config generated on 2016-12-05 08:28

! by autonetkit_0.23.5

!

hostname router1

boot-start-marker

boot-end-marker

!

vrf definition Mgmt-intf

!

address-family ipv4

exit-address-family

!

address-family ipv6

exit-address-family

!

!

!

no aaa new-model

!

!

ip cef

ipv6 unicast-routing

ipv6 cef

!

!

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

no service config

enable password cisco

ip classless

ip subnet-zero

no ip domain lookup

ip domain name virl.info

crypto key generate rsa modulus 768

ip ssh server algorithm authentication password

username cisco privilege 15 secret cisco

line vty 0 4

transport input ssh telnet

exec-timeout 720 0

password cisco

login local

line con 0

password cisco

!

cdp run

!

!

interface Loopback0

description Loopback

ip address 192.168.0.1 255.255.255.255

!

interface GigabitEthernet0/0

description OOB Management

vrf forwarding Mgmt-intf

! Configured on launch

no ip address

cdp enable

duplex full

speed auto

no shutdown

!

interface GigabitEthernet0/1

description to Internet

no ip address

ip nat outside

cdp enable

duplex full

speed auto

no shutdown

!

interface GigabitEthernet0/2

description to switch1

ip address 10.0.0.1 255.255.0.0

ip nat inside

cdp enable

ip ospf cost 1

duplex full

speed auto

no shutdown

!

! NAT stuff

!

ip nat inside source list 1 interface GigabitEthernet0/1 overload

ip route 0.0.0.0 0.0.0.0 172.16.1.1

access-list 1 permit 10.0.0.0 0.0.255.255

!

end
</entry>
</extensions>
<interface
id=
"0"
name=
"GigabitEthernet0/1"
/>
<interface
id=
"1"
name=
"GigabitEthernet0/2"
ipv4=
"10.0.0.1"
netPrefixLenV4=
"16"
/>
</node>
<node
name=
"Internet"
type=
"ASSET"
subtype=
"FLAT"
location=
"337,55"
>
<interface
id=
"0"
name=
"link0"
/>
</node>
<annotations/>
<connection
dst=
"/virl:topology/virl:node[4]/virl:interface[1]"
src=
"/virl:topology/virl:node[5]/virl:interface[1]"
/>
<connection
dst=
"/virl:topology/virl:node[3]/virl:interface[1]"
src=
"/virl:topology/virl:node[4]/virl:interface[2]"
/>
<connection
dst=
"/virl:topology/virl:node[1]/virl:interface[1]"
src=
"/virl:topology/virl:node[3]/virl:interface[2]"
/>
<connection
dst=
"/virl:topology/virl:node[2]/virl:interface[1]"
src=
"/virl:topology/virl:node[3]/virl:interface[3]"
/>
</topology>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment