Vishal MC EXP 02 TO 10 Without8
Vishal MC EXP 02 TO 10 Without8
android:textSize="30sp" />
MainActivity.java:
package com.example.myapplication;
import com.example.myapplication.R;
import com.example.myapplication.SecondActivity;
CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("New Message") .setContentText(e.getText().toString())
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(pendingIntent)
.setAutoCancel(true);
}
}
}
}
SecondActivity.java: package
com.example.myapplication;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
OUTPUT:
/*******************************************************************************************
NAME: Vishal Murugiah CLASS: TE-CMPN-02 BATCH:C6 ROLL NO: 53
AIM: Develop an application that uses GUI components. (EXP-03)
*******************************************************************************************/
Activity_main.xml: -
MainAcitvity.java: -
package com.example.myapplication;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View; import
android.widget.Button; import
android.widget.TextView; public class MainActivity
extends AppCompatActivity {
private int ch = 1;
private float font = 30f;
b1.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
t.setTextSize(font);
font += 5;
if (font >= 50) font = 30; // Fix the reset logic
}
});
b2.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
int[] colors = {Color.RED, Color.GREEN, Color.BLUE, Color.CYAN, Color.YELLOW, Color.MAGENTA};
t.setTextColor(colors[ch % colors.length]);
ch++;
}
});
}
}
Output:-
/*******************************************************************************************
NAME: Vishal Murugiah CLASS: TE-CMPN-02 BATCH:C6 ROLL NO: 53
AIM: To make an application that draws basic graphical primitives on the screen. (EXP-04)
*******************************************************************************************/
Activity_main.xml: -
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView" />
</RelativeLayout>
MainActiviyt.java: - package
com.example.myapplication;
import android.app.Activity;
import android.graphics.Bitmap; import
android.graphics.Canvas; import
android.graphics.Color; import
android.graphics.Paint; import
android.graphics.drawable.BitmapDrawable;
import android.os.Bundle; import
android.widget.ImageView; public class MainActivity
extends AppCompatActivity {
// Creating a Bitmap
Bitmap bg = Bitmap.createBitmap(720, 1280, Bitmap.Config.ARGB_8888);
// Creating the Paint Object and setting its color & TextSize
Paint paint = new Paint(); paint.setColor(Color.BLUE);
paint.setTextSize(50);
// Drawing a Rectangle
canvas.drawText("Rectangle", 420, 150,
paint); canvas.drawRect(400, 200, 650, 700,
paint);
// Drawing a Circle
canvas.drawText("Circle", 120, 150, paint);
canvas.drawCircle(200, 350, 150, paint);
// Drawing a Square
canvas.drawText("Square", 120, 800, paint);
canvas.drawRect(50, 850, 350, 1150, paint);
OUTPUT:
/*******************************************************************************************
NAME: Vishal Murugiah CLASS: TE-CMPN-02 BATCH:C6 ROLL NO: 53
AIM: Develop an application that makes use of database. (EXP-05)
*******************************************************************************************/
Activity_main.xml: -
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<EditText
android:id="@+id/Rollno"
android:inputType="text"
android:textSize="20sp" />
<EditText android:id="@+id/Marks"
android:layout_width="150dp"
android:layout_height="wrap_content
" android:layout_x="175dp"
android:layout_y="200dp"
android:inputType="number"
android:textSize="20sp" />
<Button android:id="@+id/Insert"
android:layout_width="150dp"
android:layout_height="wrap_content
" android:layout_x="25dp"
android:layout_y="300dp"
android:text="Insert"
android:textSize="30dp" />
<Button android:id="@+id/Delete" android:layout_width="150dp"
android:layout_x="200dp" android:layout_y="300dp"
android:text="Delete" android:textSize="30dp" />
<Button
android:id="@+id/Update"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="25dp"
android:layout_y="400dp"
android:text="Update"
android:textSize="30dp" />
</AbsoluteLayout>
MainActivity.java package
com.example.exno5;
DatabaseHelper dbHelper;
DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE " +
TABLE_NAME + " (rollno TEXT PRIMARY KEY, name TEXT, marks TEXT)");
}
# Define orthogonal spreading codes c1 = [1, 1, 1, 1] c2 = [1, -1, 1, -1] c3 = [1, 1, -1, -1] c4 = [1, -1, -1, 1]
kbl = kb[:64]
kbr = kb[64:] mbl
= mb[:64] mbr =
mb[64:]
a1 = int(kbl, 2)
a2 = int(kbr, 2)
a3 = a1 ^ a2 # XOR operation
a4 = bin(a3)[2:].zfill(64)
# Convert back to binary
a5 = a4[:32]
a6 = a4[32:]
a7 = int(a5, 2)
reg_x = [] reg_y
= [] reg_z = []
key_one = ""
def loading_registers(key):
global reg_x, reg_y, reg_z i,
j, k, r = 0, 0, 0, 0
reg_x = [int(key[i]) for i in
range(reg_x_length)] reg_y
= [int(key[i + reg_x_length])
for i in
range(reg_y_length)] reg_z
= [int(key[i + reg_x_length
+ reg_y_length]) for i in
range(reg_z_length)] def
set_key(key):
global key_one if len(key) == 64 and
re.match("^([01])+", key):
key_one = key loading_registers(key)
return True return
False
for _ in range(length):
majority = (reg_x_temp[8] + reg_y_temp[10] + reg_z_temp[10]) > 1
for c in plain)
return cipher print("Invalid ciphertext! Try again.") def main(): a3_algorithm() # Run
while True:
choice = user_input_choice() if choice == '0': print("Have an awesome day!") sys.exit(0) elif choice
== '1': plaintext = user_input_plaintext() print("Ciphertext:", encrypt(plaintext)) elif choice
== '2':
ciphertext = user_input_ciphertext() print("Decrypted text:",
decrypt(ciphertext)) # Run the main function if name == " main ": main()
OUTPUT:
/*******************************************************************************************
NAME: Vishal Murugiah CLASS: TE-CMPN-02 BATCH: C6 ROLL NO: 53
AIM: Illustration of Hidden Terminal Problem (NS-2). (EXP-9)
*******************************************************************************************/
Input:
BEGIN{
sim_end = 200; i=0;
while (i<=sim_end) {sec[i]=0; i+=1;};
}
{
if ($1=="r" && $7=="cbr"&& $3=="_0_") {sec[int($2)]+=$8; };
}
END{i=0;
while (i<=sim_end) {print i " " sec[i]; i+=1;};
}# Define options
set val(chan) Channel/WirelessChannel ;# channel type setval(prop) Propagation/FreeSpace ;# radio-propagation
modelset val(netif) Phy/WirelessPhy ;# network interface typeset val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queuetype set val(ll) LL ;# link layer type set val(ant)
Antenna/OmniAntenna ;# antenna model set val(ifqlen) 10000 ;# max packet in ifq set val(nn) 5 ;#number of
mobilenodes
set val(rp) DSR ;# routing protocol
set val(x) 600 ;# X dimension of topography set val(y) 600
;# Y dimension of topography set val(stop) 100 ;# time ofsimulation end set val(R) 300 set
opt(tr) out.tr
set ns [new Simulator] set tracefd [open $opt(tr) w]set windowVsTime2 [open win.tr w] set namtrace [open
simwrls.nam w] Mac/802_11 set dataRate_ 1.2e6 Mac/802_11set RTSThreshold_ 100 $ns trace-all $tracefd #$ns
use- newtrace
$ns namtrace-all-wireless $namtrace $val(x) $val(y) # set up topography objectset topo [new Topography] $topo
load_flatgrid $val(x) $val(y) create-god $val(nn)
#
# Create nn mobilenodes [$val(nn)] and attach them tothe channel. # # configure the nodes $ns
node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON Phy/WirelessPhy set CSThresh 30.5e-10 for
{set i 0} {$i < $val(nn) } { incr i } { setnode_($i) [$ns node] }
$node_(0) set X_ $val(R)
$node_(0) set Y_ $val(R)
$node_(0) set Z_ 0
$node_(1) set X_ $val(R)
$node_(1) set Y_ 0
$node_(1) set Z_ 0
$node_(2) set X_ 0
$node_(2) set Y_ $val(R)
$node_(2) set Z_ 0
$node_(3) set X_ [expr $val(R) *2]
$node_(3) set Y_ $val(R)
$node_(3) set Z_ 0
$node_(4) set X_ $val(R)
$node_(4) set Y_ [expr $val(R) *2]
$node_(4) set Z_ 0
for {set i 0} {$i<$val(nn)} {incr i} {
$ns initial_node_pos $node_($i) 30
}
# Generation of movements
$ns at 0 "$node_(1) setdest $val(R) $val(R) 3.0"
$ns at 0 "$node_(2) setdest $val(R) $val(R) 3.0"
$ns at 0 "$node_(3) setdest $val(R) $val(R) 3.0"
$ns at 0 "$node_(4) setdest $val(R) $val(R) 3.0"
# Set a TCP connection between node_(0) and node_(1) set tcp[new Agent/TCP/Newreno] #$tcp set class_ 2 set
tcp [new Agent/UDP]
$ns at $val(stop) "puts \"end simulation\" ; $ns halt"proc stop {} { exec awk -f fil.awk out.tr
> out.xgr exec xgraph out.xgr & global
ns tracefd namtrace
$ns flush-trace close $tracefd close $namtraceexec nam simwrls.nam &
}
$ns run
OUTPUT:
/*******************************************************************************************
NAME: Vishal Murugiah CLASS: TE-CMPN-02 BATCH: C6 ROLL NO: 53
AIM: To setup & configuration of Wireless Access Point (AP) using NS3. Analyze the Wi-Fi communication range in
the presence of the access point (AP) and the base station (BS). (EXP-10)
*******************************************************************************************/
INPUT:
std::cout << "PHYRXOK mode=" << mode << " snr=" << snr << " " << *packet
<< std::endl;
} } void
PhyRxErrorTrace (std::string context, Ptr<const Packet> packet,double snr)
{
if (g_verbose)
{
std::cout << "PHYRXERROR snr=" << snr << " " << *packet <<std::endl;
} } void
PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiModemode, WifiPreamble preamble, uint8_t
txPower)
{
if (g_verbose)
{
std::cout << "PHYTX mode=" << mode << " " << *packet << std::endl;
} } void
PhyStateTrace (std::string context, Time start, Time duration,WifiPhyState state)
{
if (g_verbose)
{
std::cout << " state=" << state << " start=" << start << "duration=" << duration << std::endl;
}
}
static void
SetPosition (Ptr<Node> node, Vector position)
{
Ptr<MobilityModel> mobility = node->GetObject<MobilityModel> ();mobility->SetPosition (position);
}
static Vector
GetPosition (Ptr<Node> node)
{
Ptr<MobilityModel> mobility = node->GetObject<MobilityModel> ();return mobility- >GetPosition
();
}
static void AdvancePosition (Ptr<Node> node)
{
Vector pos = GetPosition (node); pos.x += 5.0; if (pos.x >= 210.0)
{ return;
}
SetPosition (node, pos); Simulator::Schedule (Seconds (1.0), &AdvancePosition, node);
}
int main (int argc, char *argv[])
{
CommandLine cmd;
cmd.AddValue ("verbose", "Print trace information if true",g_verbose); cmd.Parse (argc, argv);
Packet::EnablePrinting ();
WifiHelper wifi; MobilityHelper mobility; NodeContainer stas; NodeContainer ap; NetDeviceContainer staDevs;
PacketSocketHelper packetSocket;stas.Create (2); ap.Create
(1);
// give packet socket powers to nodes. packetSocket.Install (stas);packetSocket.Install (ap); WifiMacHelper wifiMac;
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper
wifiChannel = YansWifiChannelHelper::Default(); wifiPhy.SetChannel (wifiChannel.Create ()); Ssid ssid = Ssid ("wifi-
default"); wifi.SetRemoteStationManager ("ns3::ArfWifiManager"); // setup stas. wifiMac.SetType
("ns3::StaWifiMac", "ActiveProbing", BooleanValue(true), "Ssid", SsidValue (ssid)); staDevs = wifi.Install (wifiPhy,
wifiMac, stas); // setup ap. wifiMac.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid));wifi.Install (wifiPhy,
wifiMac, ap);
// mobility. mobility.Install (stas); mobility.Install (ap);
Simulator::Schedule (Seconds (1.0), &AdvancePosition, ap.Get (0));PacketSocketAddress socket;
socket.SetSingleDevice (staDevs.Get (0)->GetIfIndex ()); socket.SetPhysicalAddress (staDevs.Get (1)->GetAddress
());socket.SetProtocol (1);
OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket));onoff.SetConstantRate (DataRate
("500kb/s")); ApplicationContainer apps = onoff.Install (stas.Get (0)); apps.Start(Seconds (0.5)); apps.Stop
(Seconds (43.0)); Simulator::Stop (Seconds (44.0));
Config::Connect ("/NodeList/*/DeviceList/*/Mac/MacTx", MakeCallback(&DevTxTrace)); Config::Connect
("/NodeList/*/DeviceList/*/Mac/MacRx", MakeCallback(&DevRxTrace)); Config::Connect
("/NodeList/*/DeviceList/*/Phy/State/RxOk",MakeCallback (&PhyRxOkTrace));
Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/RxError",
MakeCallback (&PhyRxErrorTrace));
Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/Tx",MakeCallback (&PhyTxTrace));
Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/State",MakeCallback (&PhyStateTrace));
AthstatsHelper athstats; athstats.EnableAthstats ("athstats-sta", stas); athstats.EnableAthstats ("athstats-ap", ap);
Simulator::Run (); Simulator::Destroy ();return 0;
}
OUTPUT: