Notes, summaries, assignments, exams, and problems for Computers

Sort by
Subject
Level

Core Concepts in Network Layer Protocols and Routing

Posted by Anonymous and classified in Computers

Written on in English with a size of 578.11 KB

1)A virtual-circuit network (VCN) is a hybrid network model that combines features of both circuit-switched and datagram networks. It provides a balance between connection-oriented and connectionless transmission methods :-Three Phases in a Virtual-Circuit Network In a virtual-circuit network, the communication between a source and destination involves three phases: setup, data transfer, and teardown. These phases ensure that a reliable path is established and maintained for the communication session. 1. Setup Phase: o The source and destination use their global addresses to establish a connection. During this phase, switches along the path create table entries to store information about the virtual circuit. This phase ensures that each switch... Continue reading "Core Concepts in Network Layer Protocols and Routing" »

Essential Linux Commands & File System Structure

Classified in Computers

Written on in English with a size of 7.16 KB

Linux File System Structure: An archive of Linux is associated with 3 parts: superblock, inode table, and data blocks.

Network Ports: To see the ports assigned to services.

Display Active TCP/IP Connections: netstat -a

User Management:

  • Create password: passwd (user)
  • Add user to group: usermod -g group_name
  • Disable: 60001
  • Enable: 60002

Practical Commands:

Add User: adduser

  1. Change folder privileges: chmod
  2. Check privileges: ls -de (see if you changed privileges)
  1. Create a user: useradd newuser
    passwd newuser
  2. Create a directory: The command mkdir is used to create directories:
    mkdir mydirectory
  3. Create a report: ps -aux >> reporte.txt
  4. Directories associated with the user: -d dirname
  5. Changing permission: chmod 744 file.txt /file.txt
  6. Change owner: chown
    Entering
... Continue reading "Essential Linux Commands & File System Structure" »

C TCP Sliding Window Client Example with Timeout

Classified in Computers

Written on in English with a size of 3.49 KB

C TCP Sliding Window Client Example

Source code with timeout and acknowledgment handling

Note: This example demonstrates socket programming in C using a sliding window and a receive timeout. It sends numbered frames, waits for acknowledgments, and resends frames on timeout.

Key points

  • Uses setsockopt to set a receive timeout (SO_RCVTIMEO)
  • Sends sequential frames and handles acknowledgments
  • Resends a window of frames when acknowledgments are not received
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
#include <arpa/inet.h>
#define MAX 80
#define PORT 8080
#define SA struct sockaddr
... Continue reading "C TCP Sliding Window Client Example with Timeout" »

Essential IoT Wireless Communication Protocols Explained

Posted by Anonymous and classified in Computers

Written on in English with a size of 4.63 KB

1. MQTT Protocol and Architecture

MQTT is a lightweight messaging protocol designed for M2M IoT communication. It utilizes a publish–subscribe model, eliminating the need for direct device-to-device communication. Key features include low power consumption, low bandwidth usage, scalability, reliability (via QoS 0/1/2), and security (TLS). The architecture consists of a Client (publisher/subscriber device), a Broker (central server for message management, filtering, and routing), and a TCP/IP connection (CONNECT–CONNACK).

2. 6LoWPAN Working and Importance

6LoWPAN stands for IPv6 over low-power wireless personal area networks (IEEE 802.15.4). Its working mechanism involves header compression, packet fragmentation, an adaptation layer, mesh routing,... Continue reading "Essential IoT Wireless Communication Protocols Explained" »

Implementing REINFORCE Policy Gradient for CartPole-v1

Posted by Anonymous and classified in Computers

Written on in English with a size of 3.14 KB

############################### lAB 9 ####################3
import gymnasium as gym
import numpy as np
import tensorflow as tf

# Create the environment
env = gym.Make("CartPole-v1")

# Define a simple neural network model for the policy
model = tf.Keras.Sequential([
    tf.Keras.Layers.Dense(16, activation='relu', input_shape=(env.Observation_space.Shape[0],)),
    tf.Keras.Layers.Dense(env.Action_space.N, activation='softmax')
])

# Define the optimizer
optimizer = tf.Keras.Optimizers.Adam(learning_rate=0.01)

# Function to choose an action based on the current policy
def choose_action(state):
    """
    Chooses an action based on the probabilities output by the policy model.
    Args:
        state (np.Array): The current observation/state from... Continue reading "Implementing REINFORCE Policy Gradient for CartPole-v1" »

How the World Wide Web Works: A Technical Breakdown

Classified in Computers

Written on in English with a size of 2.84 KB

How the World Wide Web Works

The World Wide Web is the most widely used part of the internet. When you browse the web, you view multimedia pages containing text, pictures, graphics, sounds, and videos. The web uses hypertext links to allow you to navigate from one place to another.

The web operates on a client/server model: client software (the web browser) runs on your computer, while server software runs on a web host.

To use the web, you need an internet connection and a web browser. You type the URL for the website you wish to visit, and your browser sends a request using the HTTP protocol. This is how the browser and server communicate. When the server finds the requested page, it sends it back to the browser.

How Web Pages Are Organized

The... Continue reading "How the World Wide Web Works: A Technical Breakdown" »

File Systems, Kernels, and High-Performance Networking

Posted by Anonymous and classified in Computers

Written on in English with a size of 25.6 KB

Fast File System (FFS)

Writes

Writes: Writes data to blocks chosen by cylinder groups. Tries to place related blocks near each other and rotationally optimize access. Metadata updates (inodes, directories) are also written in-place within the same group.

Reads

Reads: Very fast because data is grouped by cylinder, minimizing seeks. Sequential reads benefit from rotational optimization and large block sizes (4–8 KB). The first read goes through the inode, then the inode's data block pointers.

Appends

Appends: Allocates the next block near the previous one. Uses rotational delay tables to place the next block just in time for the disk head. Large blocks plus fragments allow efficient small-file appends.

Crash Recovery

Crash Recovery: Uses fsck to walk... Continue reading "File Systems, Kernels, and High-Performance Networking" »

Internet Fundamentals: Protocols, Web Browsers, and Network Architecture

Posted by Anonymous and classified in Computers

Written on in English with a size of 7.49 KB

Internet vs. World Wide Web (WWW)

  • Internet: A global network infrastructure that uses TCP/IP to connect devices worldwide.
  • WWW (World Wide Web): A multimedia service built upon the Internet, utilizing HTML, CSS, web browsers, and hyperlinks.
  • Webpage: A single document accessible via the WWW. | Website: A collection or group of related webpages.

History and Evolution of the Internet

  • 1960s: Development of ARPANET (Advanced Research Projects Agency Network).
  • 1983: Adoption of the TCP/IP protocol suite (developed by Vint Cerf and Bob Kahn).
  • 1989: Invention of the World Wide Web (WWW) by Tim Berners-Lee.
  • 1992: Release of the Mosaic browser (developed at UIUC), popularizing the graphical web.

Understanding the Client-Server Model

  • Client: Initiates a request
... Continue reading "Internet Fundamentals: Protocols, Web Browsers, and Network Architecture" »

Web Application Security: Vulnerabilities and Mitigations

Posted by Anonymous and classified in Computers

Written on in English with a size of 1.73 MB

Web Security Fundamentals

Vte60I22Y4rloTJJkNobQnzfKnvzVllIg5VXseVlb8Oo0lemK0wbVL2Ro4ylzQ96mYBvg7I3FlW9EaUPdsbPXfehlUZYxr6v7kaIgq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AAAAASUVORK5CYII= ntAAAAAElFTkSuQmCC wcCnzcg8p0c5gAAAABJRU5ErkJggg==

Common Cross-Site Scripting (XSS) Types

XSS TypeExample PayloadDescription
Reflected XSS<script>alert(1)</script>Injected payload reflected immediately in server response.
Stored XSS<img src="x" onerror="alert(1)">Payload stored on server (e.g., in database), executed later.
DOM-Based XSSURL: #<script>alert(1)</script>Payload executed via client-side JavaScript manipulation.
Event Handler XSS<a onclick="alert(1)">Click</a>Injects event attributes to run JS on user actions.
Attribute Injection"><script>alert(1)</script>Breaks out of HTML attribute to inject malicious code.
JavaScript URI XSS<a href="javascript:alert(1)">Click</a>Runs JS via link clicks
... Continue reading "Web Application Security: Vulnerabilities and Mitigations" »

Shell script

Classified in Computers

Written on in English with a size of 2.47 KB

Ejercicio de descuentos:

#!/bin/bash

read -p "¿Desea el billete también de vuelta? (s/n): " idavuelta

until [ $idavuelta=="s" ] || [ $idavuelta=="n" ]; do

read -p "¿Desea el billete también de vuelta? (s/n): " idavuelta

done

read -p "¿Tiene carnet joven? (s/n): " carnetjoven

until [ $carnetjoven="s" ] || [ $carnetjoven="n" ]; do

read -p "¿Tiene carnet joven? (s/n): " carnetjoven

done

descuento=0 billete=20

if [ $idavuelta="s" ]; then

descuento=20

billete=" expr $billete \* 2'

fi

if [ $carnetjoven="s" ]j then

descuento=30

fi

costefinal=`expr $billete \* \( 100 - $descuento \) / 100`

echo "El precio final del billete es $costefinal"



Ejercicio de medias:

#!/bin/bash

acu=0

cont=0

read -p "Introduce un numero: " num

while [ $num -ne 0 ]; do

acu=`expr $acu + $num`

cont=... Continue reading "Shell script" »