E-Commerce Communication Infrastructure
E-Commerce Communication Infrastructure
Objectives
Mathematics foundation for computer network
Number systems, data representation
Number system
Numbers are usually base-10 numbers in daily life There are many other possible number systems
Example:
base-2 numbers (1011011) Base-8 numbers (133)
Number representation
Format
354(8)
Base-8 numbers The digits here describe the magnitude of the represented value
Translating to base-n
Example:
307(10) = 463(8)
8 | 307 |_______ | 38 |_______ | 4 |_______ 0
..
... 6 ... 4
Goal: find x1, x2, ., xn (< b) such that x(b) = x1 * bn-1 + x2 * bn-2 + xn-1 * b1 + xn * b0 Compute y/b
Quotient: x1 * bn-2 + x2 * bn-3 + xn-1 * b0 repeating case Remainder: xn
Overall effect: we obtain the rightmost digit
Base-11 or higher
Arabic numbers has 10 symbols/digits only
For higher based numbers, a common practice is to use alphabets
Example:
`A represents 10 `B represents 11 `C represents 12 `F represents 15
Exercise
65(7) = ???(5) ACC(16) = ???(8) 50(10) = ???(2)
Numbers in computer
Signal in computer is either high or low
Binary representation
Voltage
Data in computer
Everything in computer is binary data!
Image
Example: each pixel is defined by RGB values (red, green blue)
Sound
Digital signal
Data in computer
Text
ASCII 1 bytes representation
http://en.wikipedia.org/wiki/ASCII - SS
Data size
Measured by number of binary digit (bit)
1 byte = 8 bits 1kB (kilobyte) = 1024 bytes 1MB (Megabyte) = 1024kB 1GB (Gigabyte) = 1024MB
Overflow - SS
Data in computer is usually fix-sized
An integer is usually 4 bytes (unsigned) At most 232 1 = 4,294,967,295
Underflow - SS
Fix-sized floating point numbers
Not possible to represent very long real numbers
Example, 1/3 cannot be represented precisely in computer 1/3 = 0.010101010(2)
If we use only 5 bits, we have 0.01010(2) = 0.3125
Underflow
The value is too small to be represented in computers
Example
Encryption keys/values Binary editor software IPv6
Computer Network
Allow people to connect computers to each other Internet
A large system of interconnected computer networks spanning the globe
19
20
21
Identification of nodes
IP address
Identify a computer in a computer network
IPv4
A 4-bytes code (32 digits in binary) Example: 10.107.149.101
IPv6
Connection to a computer
Port: differentiate different connections to the same computer Max: 65535 (216 1) (2 bytes)
MSN Port: 51456
Windows Update
Port: 36785 Web Port: 33485
IE
Content
10.107.149.101:54678
25
26
Domain name
A human-readable format for identifying the address
Example: hsmc.edu.hk
27
DNS server
29
30
Question
My company wants to set up a web. I want to have 3 different domain names. Do I need 3 machines and 3 IP addresses to setup 3 different webs of the same content?
31
Protocol
Protocol
Message formats and rules in information exchange
33
Common protocols - SS
HTTP: for accessing webpages FTP: for file transfer SMTP, POP3: for email services
34
request line
GET /somedir/page.html HTTP/1.1 Host: www.someschool.edu User-agent: Mozilla/4.0 header Connection: close lines Accept-language:fr Carriage return, line feed indicates end of message (extra carriage return, line feed)
35
36
Experiment - SS
Telnet to your favorite Web server:
telnet www.yahoo.com 80
38
39
Router
PC #2
Mobile
IP address in LAN
LAN is itself a complete network
Not necessary to be connected to the Internet
PC #1 PC #2 172.168.0.100 172.168.0.101
41
WAN / Internet
Wide area network (WAN) is a computer network in a board area
Connect different LANs together
LAN2 LAN1
42
Global IP address
On Internet, your IP address has to be unique Internet Service Provider (ISP) will assign to you a unique global IP address
Typical scenario:
Every client has only 1 global IP address
LAN in WAN
Proxy servers, routers will help to distribute the communication channels Example: home network
Any message to your global IP will first reach the router Router The messages will be distributed to machines in LAN accordingly
PC #1
44
PC #2
Mobile
Questions
I want to launch an e-shop on my PC at my home. I have obtained an e-shop software already. What else do I need to do? I would like to invite my friend to play a computer game with me. I have started the server already and have told my friend my IP address. But my friend said he/she cannot connect to my server. What are the potential problem(s)?
46
Client-Server Architecture
Two-tier client/server architecture has only one client and one server (in each service delivery) The server hosts certain types of services
Email: email server
Receive and send emails for users
47
Client-Server Architecture
The same server may serve many clients at the same time
Server
Client
Client
48
Client
Hardware
Different machines are designed for different purposes
PC: general-purpose machines Game console: optimized for graphic processing
GPU: highly parallel structure
Database server
Oracle IBM DB2 MySQL
50
N-tier architecture
Dividing an application into different layers Example:
An e-shop with 3-tier architecture
Client
Web server
Database server
Note: the above 3-tier architecture is also a popular model for many other applications
51
Client
Client
Web server
Database server
Client
52
53
54
55
More clients can be served at the same time Not necessary to be online 24/7
In file sharing case, after the file is copied, the file owner can go offline while other clients can still obtain the file from other sources
56
57
Disadvantages of P2P
Limited access for certain resources sometimes
In file sharing, there is hardly any parties sharing some old files
58