Tuesday, October 28, 2025

Simulasi VPN dengan Packet Tracert


-----------------------------------------------------------------------
      R1
-----------------------------------------------------------------------
Router>enable 
Router(config)#hostname R1
R1(config)#interface fa0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown 
R1(config-if)#exit

R1(config)#interface fa0/1
R1(config-if)#ip address 1.0.0.1 255.0.0.0
R1(config-if)#no shutdown 
R1(config)#exit

R1#copy running-config startup-config 
Destination filename [startup-config]? 
Building configuration...
[OK]
-----------------------------------------------------------------------
Routing
-----------------------------------------------------------------------
R1(config)#ip route 0.0.0.0 0.0.0.0 1.0.0.2
R1(config)#exit
========================
R2
========================
Router>enable 
Router#configure t
Router(config)#hostname R2
R2(config)#int fa0/0
R2(config-if)#ip address 1.0.0.2 255.0.0.0
R2(config-if)#no shutdown 
R2(config-if)#exit

R2(config)#int fa0/1
R2(config-if)#ip address 2.0.0.1 255.0.0.0
R2(config-if)#no shutdown 
R2(config-if)#exit
R2(config)#exit

R2#copy running-config startup-config 
Destination filename [startup-config]? 
Building configuration...
[OK]
R2#
-----------------------------------------------------------------------
    Routing
-----------------------------------------------------------------------
R2(config)#ip route 0.0.0.0 0.0.0.0 1.0.0.1
R2(config)#ip route 0.0.0.0 0.0.0.0 2.0.0.2
R2(config)#exit
R2#show ip route 
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is 1.0.0.1 to network 0.0.0.0

C    1.0.0.0/8 is directly connected, FastEthernet0/0
C    2.0.0.0/8 is directly connected, FastEthernet1/0
S*   0.0.0.0/0 [1/0] via 1.0.0.1
               [1/0] via 2.0.0.2

R2#copy running-config startup-config 
R2#ping 192.168.1.2

-----------------------------------------------------------------------
R3
-----------------------------------------------------------------------
Router>enable 
Router#configure terminal 
Router(config)#hostname R3
R3(config)#int fa0/0
R3(config-if)#ip address 2.0.0.2 255.0.0.0
R3(config-if)#no shutdown 

R3(config-if)#exit
R3(config)#int fa0/1
R3(config-if)#ip address 192.168.2.1 255.255.255.0
R3(config-if)#no shutdown 

R3(config-if)#exit
R3(config)#exit
R3#copy running-config startup-config 

-----------------------------------------------------------------------
Routing
-----------------------------------------------------------------------
R3(config)#ip route 0.0.0.0 0.0.0.0 2.0.0.1
R3(config)#exit
R3#
R3#copy running-config startup-config 

-----------------------------------------------------------------------
PC0
-----------------------------------------------------------------------
PC>tracert 192.168.2.2

Tracing route to 192.168.2.2 over a maximum of 30 hops: 

  1   0 ms      0 ms      0 ms      192.168.1.1
  2   *         0 ms      *         Request timed out.
  3   0 ms      0 ms      0 ms      2.0.0.2
  4   0 ms      0 ms      0 ms      192.168.2.2

Trace complete.

-----------------------------------------------------------------------
CREATE INTERFACE TUNNEL R1 dan R3
-----------------------------------------------------------------------
R1(config)#interface tunnel ?
  <0-2147483647>  Tunnel interface number
R1(config)#interface tunnel 10

R1(config-if)#ip address 172.16.1.1 255.255.0.0
R1(config-if)#tunnel source fa0/1
R1(config-if)#tunnel destination 2.0.0.2
R1(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel10, changed state to up

R1(config-if)#no shutdown 
R1(config-if)#exit
R1(config)#exit
R1#copy running-config startup-config 
----------------------------------------------------------------------
R3(config)#interface tunnel 20
R3(config-if)#
%LINK-5-CHANGED: Interface Tunnel20, changed state to up

R3(config-if)#ip address 172.16.1.2 255.255.0.0
R3(config-if)#tunnel source fa0/0
R3(config-if)#tunnel destination 1.0.0.1

R3(config-if)#no shutdown 
R3(config-if)#exit
R3(config)#exit
R3#copy running-config startup-config 

R3#ping 172.16.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms

R1#ping 172.16.1.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/0 ms

R1#

-----------------------------------------------------------------------
vpn routing R1 & R3
-----------------------------------------------------------------------
R1(config)#ip rout?
route  routing  
R1(config)#ip route 192.168.2.0 255.255.255.0 172.16.1.2
R3(config)#ip route 192.168.1.0 255.255.255.0 172.16.1.1

-----------------------------------------------------------------------
  Cek koneksi dari PC2
-----------------------------------------------------------------------
PC>tracert 192.168.1.2

Tracing route to 192.168.1.2 over a maximum of 30 hops: 

  1   1 ms      0 ms      0 ms      192.168.2.1
  2   0 ms      0 ms      0 ms      172.16.1.1
  3   0 ms      0 ms      0 ms      192.168.1.2

Trace complete.
-------
PC1
-------
PC>tracert 192.168.2.2

Tracing route to 192.168.2.2 over a maximum of 30 hops: 

  1   0 ms      0 ms      0 ms      192.168.1.1
  2   0 ms      0 ms      0 ms      172.16.1.2
  3   0 ms      0 ms      0 ms      192.168.2.2

Trace complete.

PC>

======================
R1#show interfaces tunnel 10
Tunnel10 is up, line protocol is up (connected)
  Hardware is Tunnel
  Internet address is 172.16.1.1/16
  MTU 17916 bytes, BW 100 Kbit/sec, DLY 50000 usec,
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation TUNNEL, loopback not set
  Keepalive not set
  Tunnel source 1.0.0.1 (FastEthernet0/1), destination 2.0.0.2
  Tunnel protocol/transport GRE/IP
    Key disabled, sequencing disabled
    Checksumming of packets disabled
  Tunnel TTL 255
  Fast tunneling enabled
  Tunnel transport MTU 1476 bytes
  Tunnel transmit bandwidth 8000 (kbps)
  Tunnel receive bandwidth 8000 (kbps)
  Last input never, output never, output hang never
  Last clearing of "show interface" counters never
  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 1
  Queueing strategy: fifo
  Output queue: 0/0 (size/max)
  5 minute input rate 0 bits/sec, 0 packets/sec
 --More-- 

Saturday, April 20, 2024

Menulis Source Code Latex

 \usepackage{verbatim} %menulis sourcecode
\usepackage{listings} %menulis sourcecode
\usepackage{xcolor}%menulis sourcecode
%---
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
%===
\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}
\lstset{style=mystyle}
%---

\begin{lstlisting}[language=python, caption=Regresi Linier HP dan Kamera]
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression

df = pd.DataFrame([[8,7],[2,3],[6,7],[4,2],[7,8],[3,3]])
df.columns = ['x', 'y']

x_train = df['x'].values[:,np.newaxis]
y_train = df['y'].values

lm = LinearRegression()
lm.fit(x_train,y_train) # fase training

print('Coefficient : ' + str(lm.coef_))
print('Intercept : ' + str(lm.intercept_))

x_test = [[170],[171]] # data yang akan diprediksi
p = lm.predict(x_test) # fase prediksi
print(p) # hasil prediksi

# prepare plot
pb = lm.predict(x_train)
dfc = pd.DataFrame({'x': df['x'],'y':pb})

plt.scatter(df['x'],df['y'])
plt.plot(dfc['x'],dfc['y'],color='red',linewidth=1)
plt.xlabel('kamera')
plt.ylabel('harga')
plt.show()
\end{lstlisting}

Wednesday, January 10, 2024

Problem Set 2.5 - Chain Rule

 16. $ y= cos^3(\frac{x^2}{1 - x}) $

$ v= \frac{x^2}{1-x}, ~ u=cos \, v, ~ y = u^3 $

$\frac{dy}{dx} = \frac{dv}{dx}. \frac{du}{dv}. \frac{dy}{du}$

$ = (\frac{(1 - x)D_x(x^2) - (x^2) D_x(1 - x)}{(1 - x)^2}). (- sin \, v).(3u^2) $

$ = \frac{(1-x)(2x) -(x^2)(-1)}{(1 - x)^2}. sin(\frac{x^2}{1 -x}). (-3 cos^2 (\frac{x^2}{1 - x}))$

$ = \frac{-3(2x - x^2)}{(1 - x)^2}cos^2(\frac{x^2}{1-x}) sin(\frac{x^2}{1 -x }) $

Sunday, January 7, 2024

Problem Set 2.4 Derivatif Trigonometri

catatan :

$ \frac{d}{dx} sin x~= cos\, x$

$ D_x (cos x)~= - sin\, x$

$ \frac{d}{dx}tanx~=sec^2 x$

$D_x (cot\, x)~=-csc\, x $

$\frac{d}{dx} sec x~=sec\, x\, tan\, x$ 

--------

$ 6. ~y = csc\, x$

$ D_x(csc \, x) = D_x \frac{1}{sin x}$

$ = \frac{sin x\, D_x(1) - (1)\, D_x(sin x)}{sin^2 x}$

$ = \frac{0 - cos\, x}{sin^2 x}~=\frac{-1}{sin x}.\frac{cos\, x}{sin\, x}~= -csc\,x \,cot\, x$


$10.~y= \frac{sin x + cos x}{tan x} $ 

$\frac{d}{dx}(\frac{sin x + cos x}{tan x})$

$=\frac{tanx\, D_x (sin x+ cos x) - (sin x+ cos x)\, D_x (tan x)}{tan^2 x}$

 $= \frac{tanx(cosx-sinx)-(sinx+cosx)sec^2 x}{tan^2x}$

$= \frac{tanx(cosx-sinx)-(sinx+cosx)sec^2 x}{\frac{sin^2x}{cos^2x}}$ 

$ = [sin x - \frac{sin^2 x}{cos x} - \frac{sin x}{cos^2 x} - \frac{1}{cos x}]  : [\frac{sin^2 x}{cos^2 x}]$

$ = [sin x - \frac{sin^2 x}{cos x} - \frac{sin x}{cos^2 x} - \frac{1}{cos x}]  [\frac{cos^2 x}{sin^2 x}]$

$ =\frac{cos^2 x}{sin x} - cos x - \frac{1}{sin x} - \frac{cos x}{sin^2 x} $




Problem Set 1.4 : Limit Involving Trigonometric Functions

$ 7.  \lim_{\theta \to 0} \frac{sin\, 3\theta}{tan \, \theta} $

$= \lim_{\theta \to 0} \frac{sin \, 3\theta}{\frac{sin \theta}{cos \theta}} $

$ = \lim_{\theta \to 0} \frac{cos\theta \, sin 3\theta}{sin \theta} $

$ = \lim_{\theta \to 0} [ \frac{sin 3\theta}{3 \theta}. 3\, cos \theta . \frac{1}{sin \theta} . \theta ] $ 

$ = 3 \lim_{\theta \to 0} [ \frac{sin 3\theta}{3\theta}. cos \theta. \frac{\theta}{sin \theta}] $

$ = 3 (1.1.1)~=~3 $


$ 8.  \lim_{\theta \to 0} \frac{tan 5\theta}{sin 2\theta} $

$ = \lim_{\theta \to 0} \frac{\frac{sin 5\theta}{cos 5\theta}}{sin 2\theta} $

$ = lim_{\theta \to 0} \frac{sin5 \theta}{ cos 5\theta \, sin 2\theta} $

$ = lim_{\theta \to 0} [\frac{sin 5\theta}{5\theta}.\frac{2\theta}{sin 2\theta}.\frac{1}{cos 5\theta}.5\theta. \frac{1}{2\theta}] $

$ = lim_{\theta \to 0} [\frac{sin 5\theta}{5\theta}.\frac{2\theta}{sin 2\theta}.\frac{1}{cos 5\theta}.\frac{5}{2}]  $

$ =  \frac{5}{2} lim_{\theta \to 0} [\frac{sin 5\theta}{5\theta}.\frac{2\theta}{sin 2\theta}.\frac{1}{cos 5\theta}] $

$ = \frac{5}{2} (1.1.1)~=~ \frac{5}{2} $

 

$9. \lim_{\theta \to 0} \frac{cot\, \pi \theta \, sin \theta}{2 sec \theta}$

$ = \lim_{\theta \to 0} \frac{\frac{cos \pi \theta}{sin \pi \theta} sin \theta}{\frac{2}{cos \theta}}$

$ = \lim_{\theta \to 0} \frac{cos \pi \theta \, sin \theta \, cos \theta}{2 sin \pi \theta} $

$= \lim_{\theta \to 0} [\frac{sin \theta}{\theta}. \frac{\pi \theta}{sin \pi \theta}. \frac{1}{\pi}. \frac{cos \pi \theta \, cos \theta}{2}]$

$ = \frac{1}{2\pi} ~\lim_{\theta \to 0}  [\frac{sin \theta}{\theta}. \frac{\pi \theta}{sin \pi \theta}. cos \pi \theta \, cos \theta ]$

$ =\frac{1}{2 \pi}(1.1.1) ~=~\frac{1}{2 \pi}$






Monday, November 20, 2023

Dua Gambar Bersisian Pada LaTeX

 %--------DUA GAMBAR BERSISIAN

\begin{figure}
  \begin{minipage}{0.4\textwidth}
    \centering
    \includegraphics[width=\linewidth]{topologi-1-2023.drawio.png}
    \caption{Topologi Mesh 1 singgle Hop}
    \label{fig:topologi1}
  \end{minipage}%
  \begin{minipage}{0.5\textwidth}
    \centering
    \includegraphics[width=\linewidth]{topologi-2-2023.drawio.png}
    \caption{topologi 2 multiHop}
    \label{fig:topologi2}
  \end{minipage}
\end{figure}




Monday, October 30, 2023

Problem Set 2.5 Chain Rule Aplications

 


69. Sebuah roda berpusat dititik asal dan berjari-jari 10cm, berputar search jarum jam dengan laju 4 putaran/detik. Sebuah titik P burada pada roda di (10,0) saat t = 0

(A) Tentukan koordinat P pada saat t detik

(B) pada laju berapa P naik (atau turun) pada saat t=1


Jawab


💥(a) Untuk menentukan Koordinat P pada t detik perlu ditentukan sudut $ \theta $ pada waktu t detik.


- Karna roda berputar dengan laju 4 putaran/detik. 1 putaran = $ 2\pi ~radian $ 

maka kecepatan sudut $ \omega $ adalah :

$ \omega~=~ 4 \times 2\pi~=~ 8\pi~radian $


- Menentukan $ \theta $ pada waktu t :$~~ \theta=\omega t=8\pi t $


- Dari phitagoras : $ x = r\, cos\, \theta,~~ y = r \, sin\, \theta $


$ x(t)= r \, cos \theta $

$ ~~~~~~~= 10 ~cos 8\pi t $

  
$ y(t)= r \, sin \theta $ 
$ ~~~~~~~= 10\,sin \,8\pi t $

maka koordinat P saat t $(x,y)_t $ adalah $ (10 cos 8 \pi t, 10 sin 8 \pi t) $

💥(B) menentukan  laju dimana P naik atau turun pada $ t = 1 $, maka perlu diturunkan $ y $ terhadap $ t$ 

$ y(t) = 10 \, sin \, 8 \pi t $

$ \frac{dy(t)}{dt} = 10 \frac{d}{dt} sin\, 8\pi t + sin\, 8\pi t \frac{d}{dt}10 $ 

$ V_{(t)}~=~\frac{dy}{dt} = 80\pi \, cos \, 8\pi t $

$ V_{(t)} =  $ saat   $t =1$

$ V_{(t)} = 80\pi \, cos \, ( 8\pi 1)  $

$~~~~~~~= 80\pi \, cos\, 8\pi ~=~ 80\pi \, cm/t $ 

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












Sunday, June 4, 2023

VLAN

 


file : Gdrive

Switch(config)#hostname S1
S1(config)#vlan 10
S1(config-vlan)#name student
S1(config-vlan)#exit
S1(config)#vlan 20
S1(config-vlan)#name admin
S1(config-vlan)#end
S1#copy running-config startup-config
S1#

S1(config)#interface range fa0/1-fa0/9
S1(config-if-range)#switchport mode access
S1(config-if-range)#switchport access vlan 10
S1(config-if-range)#exit
 
S1(config)#interface range fa0/10-fa0/15
S1(config-if-range)#switchport mode access
S1(config-if-range)#switchport access vlan 20
S1(config-if-range)#end
S1#copy running-config startup-config

S1#sh vlan
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/16, Fa0/17, Fa0/18, Fa0/19
                                                Fa0/20, Fa0/21, Fa0/22, Fa0/23
                                                Fa0/24, Gig0/1, Gig0/2
10   student                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/6, Fa0/7, Fa0/8
                                                Fa0/9
20   admin                            active    Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15

S1(config)#
S1(config)#int Gig0/1
S1(config-if)#switchport mode trunk
S1(config-if)#switchport trunk allowed vlan all
S1(config-if)#end
S1#copy running-config startup-config 

-----


Switch(config)#hostname S2
S2(config)#vlan 10
S2(config-vlan)#name student
S2(config-vlan)#exit
S2(config)#vlan 20
S2(config-vlan)#name admin
S2(config-vlan)#end
S2#copy running-config startup-config


S2(config)#interface range fa0/1-fa0/9
S2(config-if-range)#switchport mode access
S2(config-if-range)#switchport access vlan 10
S2(config-if-range)#exit


S2(config)#interface range fa0/10-fa0/15
S2(config-if-range)#switchport mode access
S2(config-if-range)#switchport access vlan 20
S2(config-if-range)#end
S2#copy running-config startup-config

S2#sh vlan
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------

1    default                          active    Fa0/16, Fa0/17, Fa0/18, Fa0/19

                                                Fa0/20, Fa0/21, Fa0/22, Fa0/23
                                                Fa0/24, Gig0/1, Gig0/2

10   student                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4

                                                Fa0/5, Fa0/6, Fa0/7, Fa0/8
                                                Fa0/9
20   admin                            active    Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15

Dynamic Routing Dengan OSPF Menggunakan Multi Area

 


file : Gdrive

R0(config)#router ospf 1
R0(config-router)#network 192.168.200.16 0.0.0.15 area 0
R0(config-router)#network 172.2.1.4 0.0.0.3 area 0
R0(config-router)#network 172.2.1.8 0.0.0.3 area 0
R0(config-router)#end

R1(config)#router ospf 1
R1(config-router)#network 172.2.1.4 0.0.0.3 area 0
R1(config-router)#network 172.2.1.16 0.0.0.3 area 1
R1(config-router)#network 192.168.10.0 0.0.0.255 area 1
R1(config-router)#network 172.2.1.12 0.0.0.3 area 0
R1(config-router)#end

R2(config)#router ospf 1
R2(config-router)#network 172.2.1.16 0.0.0.3 area 1
R2(config-router)#network 192.168.20.0 0.0.0.255 area 1
R2(config-router)#end

R3(config)#router ospf 1
R3(config-router)#network 172.2.1.8 0.0.0.3 are
R3(config-router)#network 172.2.1.8 0.0.0.3 area 0
R3(config-router)#network 172.2.1.12 0.0.0.3 area 0
R3(config-router)#network 192.168.30.0 0.0.0.255 area 2
R3(config-router)#network 172.2.1.20 0.0.0.3 area 2
R3(config-router)#end

R4(config)#router ospf 1
R4(config-router)#network 172.2.1.20 0.0.0.3 area 2
R4(config-router)#network 192.168.40.0 0.0.0.255 area 2
R4(config-router)#end

R1#sh ip route 
     172.2.0.0/30 is subnetted, 5 subnets
C       172.2.1.4 is directly connected, Serial2/0
O       172.2.1.8 [110/128] via 172.2.1.5, 00:14:02, Serial2/0
C       172.2.1.12 is directly connected, FastEthernet0/0
C       172.2.1.16 is directly connected, Serial3/0
O IA    172.2.1.20 [110/192] via 172.2.1.5, 00:03:04, Serial2/0
C    192.168.10.0/24 is directly connected, FastEthernet1/0
O    192.168.20.0/24 [110/65] via 172.2.1.18, 00:07:52, Serial3/0
O IA 192.168.30.0/24 [110/129] via 172.2.1.5, 00:03:33, Serial2/0
O IA 192.168.40.0/24 [110/193] via 172.2.1.5, 00:00:46, Serial2/0
     192.168.200.0/28 is subnetted, 1 subnets
O       192.168.200.16 [110/65] via 172.2.1.5, 00:14:02, Serial2/0

R0#sh ip route 
     172.2.0.0/30 is subnetted, 5 subnets
C       172.2.1.4 is directly connected, Serial2/0
C       172.2.1.8 is directly connected, Serial3/0
O IA    172.2.1.12 [110/65] via 172.2.1.6, 00:11:41, Serial2/0
                   [110/65] via 172.2.1.10, 00:05:01, Serial3/0
O IA    172.2.1.16 [110/128] via 172.2.1.6, 00:13:31, Serial2/0
O IA    172.2.1.20 [110/128] via 172.2.1.10, 00:03:54, Serial3/0
O IA 192.168.10.0/24 [110/65] via 172.2.1.6, 00:12:54, Serial2/0
O IA 192.168.20.0/24 [110/129] via 172.2.1.6, 00:08:37, Serial2/0
O IA 192.168.30.0/24 [110/65] via 172.2.1.10, 00:04:23, Serial3/0
O IA 192.168.40.0/24 [110/129] via 172.2.1.10, 00:01:36, Serial3/0
     192.168.200.0/28 is subnetted, 1 subnets
C       192.168.200.16 is directly connected, FastEthernet4/0

Sunday, May 21, 2023

Dynamic Routing Dengan OSPF

OSPF adalah sebuah routing protocol standard terbuka yang telah diimplementasikan oleh sejumlah besar vendor jaringan, termasuk Cisco. Jika memiliki banyak router dari berbagai vendor maka salah satu pilihan yang baik adalah ospf.

Ospf bekerja dengan sebuah algoritma Djikstra. Pertama sebuah pohon jalur terpendek (shortest path tree) akan dibangun, dan kemudian routing table akan diisi dengan jalur-jalur terbaik yang dihasilkan dari pohon tersebut. OSPF mendukung multiple route dengan cost (biaya) yang sama ke tujuan yang sama.

ospf seharusnya seharusnya dirancang dengan cara heirarkis, yang pada dasarnya berarti bahwa sebuah internetwork yang besar dapat dipecah menjadi internetwork-internetwork yang lebih kecil. Alasan untuk menerapkan OSPF dalam rancangan hierarkis (topologi) antara lain :

- untuk mengurangi overhead (waktu pemrosesan) routing

- untuk mempercepat convergence

- untuk membatasi ketidakstabilan network di sebuah area

Contoh Rancangan OSPF

gambar di atas menunjukkan sebuah rancangan sederhana khas ospf. Setiap router terhubung ke backbone yang disebut area 0 atau area backbone. OSPF harus memiliki area 0 dan semua router harus terhubung ke area ini jika memungkinkan, tetapi router-router yang menghubungkan area-area lain ke backbone di dalam sebuah AS disebut Area Border Routerss (ABRs). Meskipun demikian, paling sedikit satu interface harus berada di area 0.


= = =

MENGKONFIGURASI OSPF



IP address antar router tidak menerapkan VLSM untuk alokasi IP Address

=========================================
IP ADD RA
==========================================
Router>ena
Router#config t
Router(config)#hostname RA
RA(config)#int gigabitEthernet 0/0
RA(config-if)#ip address 192.168.20.1 255.255.255.0
RA(config-if)#no sh

RA(config-if)#exit
RA(config)#int gigabitEthernet 0/1
RA(config-if)#ip address 192.168.10.1 255.255.255.0
RA(config-if)#no sh
RA#copy running-config startup-config 

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

IP ADD RB

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

Router>ena
Router#config t
Router(config)#hostname RB
RB(config)#int gigabitEthernet 0/0
RB(config-if)#ip address 192.168.20.2 255.255.255.0
RB(config-if)#no sh

RB(config-if)#exit
RB(config)#int gigabitEthernet 0/1
RB(config-if)#ip address 192.168.40.1 255.255.255.0
RB(config-if)#no sh
RB(config-if)#exit
RB(config)#int gigabitEthernet 0/2

RB(config-if)#ip address 192.168.30.1 255.255.255.0
RB(config-if)#no sh
RB(config-if)#end
RB#copy running-config startup-config

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

RC IP Add
===============================
Router>ena
Router#config t
Router(config)#hostname RC
RC(config)#int gigabitEthernet 0/0
RC(config-if)#ip address 192.168.40.2 255.255.255.0
RC(config-if)#no sh
RC(config-if)#exit

RC(config)#int gigabitEthernet 0/1
RC(config-if)#ip address 192.168.50.1 255.255.255.0
RC(config-if)#no shutdown 
RC(config-if)#end
RC#copy running-config startup-config

===================================
OSPF
===================================
RA#config t
RA(config)#router ospf 12
RA(config-router)#network 192.168.10.1 0.0.0.0 area 0
RA(config-router)#network 192.168.20.1 0.0.0.0 area 0
RA(config-router)#end
RA#copy running-config startup-config


RB#config t
RB(config)#router ospf 14
RB(config-router)#network 192.168.0.0 0.0.255.255 area 0
RB(config-router)#end
RB#copy running-config startup-config 

RC#configure terminal 
RC(config)#router ospf 20
RC(config-router)#network 192.168.40.0 0.0.0.255 area 0
RC(config-router)#network 192.168.50.0 0.0.0.255 area 0
RC(config-router)#end
RC#copy running-config startup-config 

===
RA#sh ip route 

     192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.10.0/24 is directly connected, GigabitEthernet0/1
L       192.168.10.1/32 is directly connected, GigabitEthernet0/1
     192.168.20.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.20.0/24 is directly connected, GigabitEthernet0/0
L       192.168.20.1/32 is directly connected, GigabitEthernet0/0
O    192.168.30.0/24 [110/2] via 192.168.20.2, 00:03:55, GigabitEthernet0/0
O    192.168.40.0/24 [110/2] via 192.168.20.2, 00:03:55, GigabitEthernet0/0
O    192.168.50.0/24 [110/3] via 192.168.20.2, 00:02:52, GigabitEthernet0/0

Saturday, May 20, 2023

5.1 Integral - Luas Area

Sumber : Calculus (9rd Edition) Dale Varberg, Edwin Purcell

Chapter 5.1
































ada bagian salah tanda +- pada :
$ (-x^2 - x - 2) $ seharusnya $ (-x^2 - x + 2 ) $

bagian lainnya sudah benar

Friday, May 19, 2023

5.4 Thomas Integral

 Beberapa contoh penyelesaian soal-soal Kalkulus

Sumber : Thomas Calculus

Ch : 5.4








Simulasi Static Routing dengan Packet Tracert

 

R2

======

Fa1/0  192.168.30.1 /24

Fa0/0 192.168.1.6/ 30

Se3/0 192.168.1.14 /30

R0

=======

Fa1/0  192.168.10.1 /24

Fa0/0  192.168.1.5 /30

Se2/0  192.168.1.9 /30

PC0    192.168.10.2 /24

R1

=======

Fa1/0  192.168.20.1 /24

Se2/0  192.168.1.10 /30

Se3/0  192.168.1.13 /30


R0

=====

Router>enable 

Router#configure terminal 

Router(config)#hostname R0


R0(config)#interface fa1/0

R0(config-if)#ip address 192.168.10.1 255.255.255.0

R0(config-if)#no shutdown 


R0(config-if)#exit

R0(config)#interface fa0/0

R0(config-if)#ip address 192.168.1.5 255.255.255.252

R0(config-if)#no shutdown 


R0(config)#interface se2/0

R0(config-if)#ip address 192.168.1.9 255.255.255.252

R0(config-if)#no shutdown 

R0(config-if)#end


R0#copy running-config startup-config 

Destination filename [startup-config]? 

Building configuration...


R1

=====

Router>enable 

Router#configure terminal 

Router(config)#hostname R1


R1(config)#interface fa1/0

R1(config-if)#ip address 192.168.20.1 255.255.255.0

R1(config-if)#no shutdown 

R1(config-if)#exit


R1(config)#interface se2/0

R1(config-if)#ip address 192.168.1.10 255.255.255.252

R1(config-if)#no shutdown 

R1(config-if)#exit


R1(config)#interface se3/0

R1(config-if)#ip address 192.168.1.13 255.255.255.252

R1(config-if)#no shutdown 

R1(config-if)#exit

R1(config)#end


R1#copy running-config startup-config 


R2

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

Router>enable 

Router#configure terminal 

Router(config)#hostname R2


R2(config)#interface fa1/0

R2(config-if)# ip address 192.168.30.1 255.255.255.0

R2(config-if)#no shutdown 

R2(config-if)#exit


R2(config)#interface fa0/0

R2(config-if)#ip address 192.168.1.6 255.255.255.252

R2(config-if)#no shutdown 

R2(config-if)#exit


R2(config)#interface se3/0

R2(config-if)#ip address 192.168.1.14 255.255.255.252

R2(config-if)#no shutdown 

R2(config-if)#end

R2#copy running-config startup-config 


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

Static Routing

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

Pada R0, rute menuju network di bawah R2 melalui dua jalur (1 sebagai back up), yaitu melalui 192.168.1.6 dan 192.168.1.10 (R1)

R0>enable 

R0#configure terminal 

R0(config)#ip route 192.168.30.0 255.255.255.0 192.168.1.6

R0(config)#ip route 192.168.30.0 255.255.255.0 192.168.1.10

R0(config)#ip route 192.168.20.0 255.255.255.0 192.168.1.10

R0(config)#ip route 192.168.1.12 255.255.255.252 192.168.1.10

R0(config)#end

R0#copy running-config startup-config 


R1>enable 

R1#configure 

R1(config)#ip route 192.168.10.0 255.255.255.0 192.168.1.9

R1(config)#ip route 192.168.30.0 255.255.255.0 192.168.1.14

R1(config)#end

R1#copy running-config startup-config 


R2#configur

R2(config)#ip route 192.168.10.0 255.255.255.0 192.168.1.13

R2(config)#ip route 192.168.1.8 255.255.255.252 192.168.1.13

R2(config)#ip route 192.168.20.0 255.255.255.0 192.168.1.13

R2(config)#end

R2#copy running-config startup-config 

------

R0#show ip route 

Gateway of last resort is not set

     192.168.1.0/30 is subnetted, 3 subnets

C       192.168.1.4 is directly connected, FastEthernet0/0

C       192.168.1.8 is directly connected, Serial2/0

S       192.168.1.12 [1/0] via 192.168.1.10

C    192.168.10.0/24 is directly connected, FastEthernet1/0

S    192.168.20.0/24 [1/0] via 192.168.1.10

S    192.168.30.0/24 [1/0] via 192.168.1.6

                     [1/0] via 192.168.1.10


R1#show ip route 

     192.168.1.0/30 is subnetted, 2 subnets

C       192.168.1.8 is directly connected, Serial2/0

C       192.168.1.12 is directly connected, Serial3/0

S    192.168.10.0/24 [1/0] via 192.168.1.9

C    192.168.20.0/24 is directly connected, FastEthernet1/0

S    192.168.30.0/24 [1/0] via 192.168.1.14




Monday, May 8, 2023

SVM dan PCA (Principal Component Analisys)

Dataset : https://www.kaggle.com/uciml/pima-indians-diabetes-database

Studi kasus : Klasifikasi Diabetes

jumlah fitur = 8 

  1. Pregnancies: Jumlah kali hamil
  2. Glucose: Konsentrasi glukosa plasma dalam 2 jam saat tes toleransi glukosa oral
  3. BloodPressure: Tekanan darah diastolik (mm Hg)
  4. SkinThickness: Ketebalan lipatan kulit trisep (mm)
  5. Insulin: Insulin serum dalam 2 jam (mu U/ml)
  6. BMI: Indeks massa tubuh (berat dalam kg / (tinggi dalam meter)^2)
  7. DiabetesPedigreeFunction: Nilai fungsi silsilah diabetes
  8. Age: Umur (tahun)
  9. Outcome: Variabel target, 0 untuk tidak menderita diabetes dan 1 untuk menderita diabetes.

PCA berfungsi untuk mereduksi ke 8 fitur tersebut untuk menjadi 2 fitur baru misal PC1 dan PC 2.  Nilai PC1 dan PC2 merupakan kombinasi linear dari seluruh fitur asli pada dataset. Dengan kata lain komponen 1 dan komponen 2 dihasilkan melalui reduksi dimensi dari seluruh fitur pada dataset dengan menggunakan metode PCA. Oleh karena itu, tidak ada fitur spesifik yang ditentukan sebagai komponen 1 atau 2, melainkan merupakan kombinasi linear dari seluruh fitur pada dataset.
 

import pandas as pd

from sklearn.preprocessing import StandardScaler
from sklearn.decomposition import PCA
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score
from sklearn.metrics import confusion_matrix
import numpy as np
import matplotlib.pyplot as plt

# Load dataset
train_data = pd.read_csv("diabetes-train.csv")
test_data = pd.read_csv("diabetes-test.csv")

# Separate attributes and targets
X_train = train_data.iloc[:, :-1].values
y_train = train_data.iloc[:, -1].values
X_test = test_data.iloc[:, :-1].values
y_test = test_data.iloc[:, -1].values


# Standardize the data
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)


# Apply PCA
pca = PCA(n_components=2)
X_train = pca.fit_transform(X_train)
X_test = pca.transform(X_test)


# Print 2 new features from PCA
#print("New feature 1 (PC1):", X_test[:, 0])
#print("New feature 2 (PC2):", X_test[:, 1])


# Print variance ratio of each component
print(pca.explained_variance_ratio_)


# Train SVM
svm = SVC(kernel='linear', random_state=0)
svm.fit(X_train, y_train)


# Make predictions on the test data
y_pred = svm.predict(X_test)


# Calculate accuracy
accuracy = accuracy_score(y_test, y_pred)
print("Accuracy: {:.2f}%".format(accuracy*100))


# Menghitung confusion matrix
cm = confusion_matrix(y_test, y_pred)


# Menampilkan confusion matrix
print("Confusion matrix:")
print(cm)


# Print coefficients of the hyperplane
print("Coefficients of the hyperplane: ", svm.coef_)


# Plot decision boundary
x_min, x_max = X_test[:, 0].min() - 1, X_test[:, 0].max() + 1
y_min, y_max = X_test[:, 1].min() - 1, X_test[:, 1].max() + 1
xx, yy = np.meshgrid(np.arange(x_min, x_max, 0.1), np.arange(y_min, y_max, 0.1))
Z = svm.predict(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)
plt.contourf(xx, yy, Z, alpha=0.4)
plt.scatter(X_test[:, 0], X_test[:, 1], c=y_pred, s=20, edgecolor='k')
plt.xlabel('PC1')
plt.ylabel('PC2')
plt.title('SVM Decision Boundary')
plt.show()


# Print actual and predicted values for each test data point
#print("{:<10} {:<15} {}".format('Index', 'Actual Value', 'Predicted Value'))
#for i in range(len(y_test)):
#    print("{:<10} {:<15} {}".format(i+1, y_test[i], y_pred[i]))


# Save actual and predicted values to txt file
with open('actual_pred.txt''w'as f:
    f.write("{:<10} {:<15} {}\n".format('Index''Actual Value''Predicted Value'))
    for i in range(len(y_test)):
        f.write("{:<10} {:<15} {}\n".format(i+1, y_test[i], y_pred[i]))
print("Actual and predicted values saved to actual_pred.txt file")


# Save 2 new features to excel file
new_features = pd.DataFrame({'New feature 1 (PC1)': X_test[:, 0], 'New feature 2 (PC2)': X_test[:, 1]})
new_features.to_excel('new-features.xlsx', index=False)

Hasil Running Program





Dua Fitur yang Dihasilkan oleh PCA




Penjelasan Program

# Standardize the data
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)

- - -
Baris kode scaler = StandardScaler() digunakan untuk membuat objek scaler yang akan digunakan untuk melakukan standardisasi pada data, 

pada baris kode X_train = scaler.fit_transform(X_train), objek scaler digunakan untuk melakukan proses standardisasi pada data latih (X_train). Proses standardisasi ini dilakukan dengan mengubah skala nilai pada setiap fitur sehingga memiliki mean (rerata) 0 dan standar deviasi (simpangan baku) 1. Hal ini bertujuan untuk memastikan bahwa semua fitur memiliki pengaruh yang setara terhadap model yang akan dibangun

Baris kode X_test = scaler.transform(X_test) digunakan untuk melakukan proses standardisasi yang sama pada data uji (X_test) menggunakan objek scaler yang sama dengan yang digunakan pada data latih.

Menuliskan hasil Standarisasi Fitur pada File

import pandas as pd
from sklearn.preprocessing import StandardScaler

# Read data train and test
train_data = pd.read_csv('diabetes-train.csv')
test_data = pd.read_csv('diabetes-test.csv')

# Separate features and target variable
X_train = train_data.iloc[:, :-1].values
y_train = train_data.iloc[:, -1].values
X_test = test_data.iloc[:, :-1].values
y_test = test_data.iloc[:, -1].values

# Standardize the data
scaler = StandardScaler()
X_train_std = scaler.fit_transform(X_train)
X_test_std = scaler.transform(X_test)

# Create standardized dataframes
train_data_std = pd.DataFrame(data=X_train_std, columns=train_data.columns[:-1])
test_data_std = pd.DataFrame(data=X_test_std, columns=test_data.columns[:-1])
train_data_std['Outcome'] = y_train
test_data_std['Outcome'] = y_test

# Save to Excel
with pd.ExcelWriter('diabetes-std.xlsx', engine='xlsxwriter') as writer:
    train_data_std.to_excel(writer, sheet_name='Train', index=False)
    test_data_std.to_excel(writer, sheet_name='Test', index=False)
----
Standarisasi Nilai-Nilai Fitur

# Apply PCA
pca = PCA(n_components=2)
X_train = pca.fit_transform(X_train)
X_test = pca.transform(X_test)

Bars program di atas bertujuan untuk mengimplementasikan PCA (Principal Component Analysis) pada data. PCA adalah salah satu teknik reduksi dimensi yang berguna dalam mengatasi masalah overfitting dan mengurangi kompleksitas model. PCA diaplikasikan pada data latih dan data uji dengan memanggil objek PCA dari library scikit-learn. Argumen n_components diatur menjadi 2 untuk menghasilkan 2 fitur baru yang merupakan kombinasi linier dari fitur asli yang paling signifikan dalam menjelaskan varian data.

Setelah PCA diaplikasikan, fitur-fitur asli pada data latih dan data uji diubah ke dalam representasi fitur-fitur baru yang dihasilkan oleh PCA. Ini dilakukan dengan memanggil metode fit_transform() pada data latih dan transform() pada data uji.

----
Bersambung